Merge pull request #114 from TheBlueMatt/main
[ldk-java] / src / main / jni / bindings.c
1 #define LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ LDKCVec_TransactionOutputsZ
2 #define CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free CVec_TransactionOutputsZ_free
3 #include <jni.h>
4 // On OSX jlong (ie long long) is not equivalent to int64_t, so we override here
5 #define int64_t jlong
6 #include "org_ldk_impl_bindings.h"
7 #include <lightning.h>
8 #include <string.h>
9 #include <stdatomic.h>
10 #include <stdlib.h>
11
12 #define LIKELY(v) __builtin_expect(!!(v), 1)
13 #define UNLIKELY(v) __builtin_expect(!!(v), 0)
14
15 #define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
16 #define MALLOC(a, _) malloc(a)
17 #define FREE(p) if ((uint64_t)(p) > 4096) { free(p); }
18 #define CHECK_ACCESS(p)
19 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
20 #define DO_ASSERT(a) (void)(a)
21 #define CHECK(a)
22
23 static jmethodID ordinal_meth = NULL;
24 static jmethodID slicedef_meth = NULL;
25 static jclass slicedef_cls = NULL;
26 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class, jclass slicedef_class) {
27         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
28         CHECK(ordinal_meth != NULL);
29         slicedef_meth = (*env)->GetMethodID(env, slicedef_class, "<init>", "(JJJ)V");
30         CHECK(slicedef_meth != NULL);
31         slicedef_cls = (*env)->NewGlobalRef(env, slicedef_class);
32         CHECK(slicedef_cls != NULL);
33 }
34
35 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_deref_1bool (JNIEnv * env, jclass _a, jlong ptr) {
36         return *((bool*)ptr);
37 }
38 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_deref_1long (JNIEnv * env, jclass _a, jlong ptr) {
39         return *((long*)ptr);
40 }
41 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_free_1heap_1ptr (JNIEnv * env, jclass _a, jlong ptr) {
42         FREE((void*)ptr);
43 }
44 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_read_1bytes (JNIEnv * env, jclass _b, jlong ptr, jlong len) {
45         jbyteArray ret_arr = (*env)->NewByteArray(env, len);
46         (*env)->SetByteArrayRegion(env, ret_arr, 0, len, (unsigned char*)ptr);
47         return ret_arr;
48 }
49 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes (JNIEnv * env, jclass _b, jlong slice_ptr) {
50         LDKu8slice *slice = (LDKu8slice*)slice_ptr;
51         jbyteArray ret_arr = (*env)->NewByteArray(env, slice->datalen);
52         (*env)->SetByteArrayRegion(env, ret_arr, 0, slice->datalen, slice->data);
53         return ret_arr;
54 }
55 JNIEXPORT int64_t impl_bindings_bytes_1to_1u8_1vec (JNIEnv * env, jclass _b, jbyteArray bytes) {
56         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8");
57         vec->datalen = (*env)->GetArrayLength(env, bytes);
58         vec->data = (uint8_t*)MALLOC(vec->datalen, "LDKCVec_u8Z Bytes");
59         (*env)->GetByteArrayRegion (env, bytes, 0, vec->datalen, vec->data);
60         return (uint64_t)vec;
61 }
62 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_txpointer_1get_1buffer (JNIEnv * env, jclass _b, jlong ptr) {
63         LDKTransaction *txdata = (LDKTransaction*)ptr;
64         LDKu8slice slice;
65         slice.data = txdata->data;
66         slice.datalen = txdata->datalen;
67         return Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes(env, _b, (uint64_t)&slice);
68 }
69 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data (JNIEnv * env, jclass _b, jbyteArray bytes) {
70         LDKTransaction *txdata = (LDKTransaction*)MALLOC(sizeof(LDKTransaction), "LDKTransaction");
71         txdata->datalen = (*env)->GetArrayLength(env, bytes);
72         txdata->data = (uint8_t*)MALLOC(txdata->datalen, "Tx Data Bytes");
73         txdata->data_is_owned = false;
74         (*env)->GetByteArrayRegion (env, bytes, 0, txdata->datalen, txdata->data);
75         return (uint64_t)txdata;
76 }
77 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_txpointer_1free (JNIEnv * env, jclass _b, jlong ptr) {
78         LDKTransaction *tx = (LDKTransaction*)ptr;
79         tx->data_is_owned = true;
80         Transaction_free(*tx);
81         FREE((void*)ptr);
82 }
83 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env, jclass _a, jlong ptr) {
84         // Check offsets of a few Vec types are all consistent as we're meant to be generic across types
85         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_SignatureZ, datalen), "Vec<*> needs to be mapped identically");
86         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_MessageSendEventZ, datalen), "Vec<*> needs to be mapped identically");
87         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically");
88         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically");
89         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
90         return (uint64_t)vec->datalen;
91 }
92 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * env, jclass _b) {
93         // Check sizes of a few Vec types are all consistent as we're meant to be generic across types
94         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
95         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
96         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
97         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
98         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
99         vec->data = NULL;
100         vec->datalen = 0;
101         return (uint64_t)vec;
102 }
103
104 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
105 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
106 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
107 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
108
109 _Static_assert(sizeof(jlong) == sizeof(int64_t), "We assume that j-types are the same as C types");
110 _Static_assert(sizeof(jbyte) == sizeof(char), "We assume that j-types are the same as C types");
111 _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits");
112
113 typedef jlongArray int64_tArray;
114 typedef jbyteArray int8_tArray;
115
116 static inline jstring str_ref_to_java(JNIEnv *env, const char* chars, size_t len) {
117         // Sadly we need to create a temporary because Java can't accept a char* without a 0-terminator
118         char* conv_buf = MALLOC(len + 1, "str conv buf");
119         memcpy(conv_buf, chars, len);
120         conv_buf[len] = 0;
121         jstring ret = (*env)->NewStringUTF(env, conv_buf);
122         FREE(conv_buf);
123         return ret;
124 }
125 static inline LDKStr java_to_owned_str(JNIEnv *env, jstring str) {
126         uint64_t str_len = (*env)->GetStringUTFLength(env, str);
127         char* newchars = MALLOC(str_len + 1, "String chars");
128         const char* jchars = (*env)->GetStringUTFChars(env, str, NULL);
129         memcpy(newchars, jchars, str_len);
130         newchars[str_len] = 0;
131         (*env)->ReleaseStringUTFChars(env, str, jchars);
132         LDKStr res = {
133                 .chars = newchars,
134                 .len = str_len,
135                 .chars_is_owned = true
136         };
137         return res;
138 }
139
140 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) {
141         return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version()));
142 }
143 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1version(JNIEnv *env, jclass _c) {
144         return str_ref_to_java(env, check_get_ldk_version(), strlen(check_get_ldk_version()));
145 }
146 #include "version.c"
147 static jclass arr_of_B_clz = NULL;
148 static jclass arr_of_J_clz = NULL;
149 JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) {
150         arr_of_B_clz = (*env)->FindClass(env, "[B");
151         CHECK(arr_of_B_clz != NULL);
152         arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz);
153         arr_of_J_clz = (*env)->FindClass(env, "[J");
154         CHECK(arr_of_J_clz != NULL);
155         arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_clz);
156 }
157 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
158
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 static jclass LDKBech32Error_MissingSeparator_class = NULL;
945 static jmethodID LDKBech32Error_MissingSeparator_meth = NULL;
946 static jclass LDKBech32Error_InvalidChecksum_class = NULL;
947 static jmethodID LDKBech32Error_InvalidChecksum_meth = NULL;
948 static jclass LDKBech32Error_InvalidLength_class = NULL;
949 static jmethodID LDKBech32Error_InvalidLength_meth = NULL;
950 static jclass LDKBech32Error_InvalidChar_class = NULL;
951 static jmethodID LDKBech32Error_InvalidChar_meth = NULL;
952 static jclass LDKBech32Error_InvalidData_class = NULL;
953 static jmethodID LDKBech32Error_InvalidData_meth = NULL;
954 static jclass LDKBech32Error_InvalidPadding_class = NULL;
955 static jmethodID LDKBech32Error_InvalidPadding_meth = NULL;
956 static jclass LDKBech32Error_MixedCase_class = NULL;
957 static jmethodID LDKBech32Error_MixedCase_meth = NULL;
958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBech32Error_init (JNIEnv *env, jclass clz) {
959         LDKBech32Error_MissingSeparator_class =
960                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MissingSeparator"));
961         CHECK(LDKBech32Error_MissingSeparator_class != NULL);
962         LDKBech32Error_MissingSeparator_meth = (*env)->GetMethodID(env, LDKBech32Error_MissingSeparator_class, "<init>", "()V");
963         CHECK(LDKBech32Error_MissingSeparator_meth != NULL);
964         LDKBech32Error_InvalidChecksum_class =
965                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChecksum"));
966         CHECK(LDKBech32Error_InvalidChecksum_class != NULL);
967         LDKBech32Error_InvalidChecksum_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChecksum_class, "<init>", "()V");
968         CHECK(LDKBech32Error_InvalidChecksum_meth != NULL);
969         LDKBech32Error_InvalidLength_class =
970                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidLength"));
971         CHECK(LDKBech32Error_InvalidLength_class != NULL);
972         LDKBech32Error_InvalidLength_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidLength_class, "<init>", "()V");
973         CHECK(LDKBech32Error_InvalidLength_meth != NULL);
974         LDKBech32Error_InvalidChar_class =
975                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChar"));
976         CHECK(LDKBech32Error_InvalidChar_class != NULL);
977         LDKBech32Error_InvalidChar_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChar_class, "<init>", "(I)V");
978         CHECK(LDKBech32Error_InvalidChar_meth != NULL);
979         LDKBech32Error_InvalidData_class =
980                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidData"));
981         CHECK(LDKBech32Error_InvalidData_class != NULL);
982         LDKBech32Error_InvalidData_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidData_class, "<init>", "(B)V");
983         CHECK(LDKBech32Error_InvalidData_meth != NULL);
984         LDKBech32Error_InvalidPadding_class =
985                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidPadding"));
986         CHECK(LDKBech32Error_InvalidPadding_class != NULL);
987         LDKBech32Error_InvalidPadding_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidPadding_class, "<init>", "()V");
988         CHECK(LDKBech32Error_InvalidPadding_meth != NULL);
989         LDKBech32Error_MixedCase_class =
990                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MixedCase"));
991         CHECK(LDKBech32Error_MixedCase_class != NULL);
992         LDKBech32Error_MixedCase_meth = (*env)->GetMethodID(env, LDKBech32Error_MixedCase_class, "<init>", "()V");
993         CHECK(LDKBech32Error_MixedCase_meth != NULL);
994 }
995 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBech32Error_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
996         LDKBech32Error *obj = (LDKBech32Error*)untag_ptr(ptr);
997         switch(obj->tag) {
998                 case LDKBech32Error_MissingSeparator: {
999                         return (*env)->NewObject(env, LDKBech32Error_MissingSeparator_class, LDKBech32Error_MissingSeparator_meth);
1000                 }
1001                 case LDKBech32Error_InvalidChecksum: {
1002                         return (*env)->NewObject(env, LDKBech32Error_InvalidChecksum_class, LDKBech32Error_InvalidChecksum_meth);
1003                 }
1004                 case LDKBech32Error_InvalidLength: {
1005                         return (*env)->NewObject(env, LDKBech32Error_InvalidLength_class, LDKBech32Error_InvalidLength_meth);
1006                 }
1007                 case LDKBech32Error_InvalidChar: {
1008                         int32_t invalid_char_conv = obj->invalid_char;
1009                         return (*env)->NewObject(env, LDKBech32Error_InvalidChar_class, LDKBech32Error_InvalidChar_meth, invalid_char_conv);
1010                 }
1011                 case LDKBech32Error_InvalidData: {
1012                         int8_t invalid_data_conv = obj->invalid_data;
1013                         return (*env)->NewObject(env, LDKBech32Error_InvalidData_class, LDKBech32Error_InvalidData_meth, invalid_data_conv);
1014                 }
1015                 case LDKBech32Error_InvalidPadding: {
1016                         return (*env)->NewObject(env, LDKBech32Error_InvalidPadding_class, LDKBech32Error_InvalidPadding_meth);
1017                 }
1018                 case LDKBech32Error_MixedCase: {
1019                         return (*env)->NewObject(env, LDKBech32Error_MixedCase_class, LDKBech32Error_MixedCase_meth);
1020                 }
1021                 default: abort();
1022         }
1023 }
1024 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
1025         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
1026         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
1027         return ret;
1028 }
1029 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) {
1030         LDKTxOut* thing_conv = (LDKTxOut*)untag_ptr(thing);
1031         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
1032         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
1033         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
1034         CVec_u8Z_free(ret_var);
1035         return ret_arr;
1036 }
1037
1038 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) {
1039         LDKTxOut* thing_conv = (LDKTxOut*)untag_ptr(thing);
1040         int64_t ret_conv = TxOut_get_value(thing_conv);
1041         return ret_conv;
1042 }
1043
1044 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
1045 CHECK(owner->result_ok);
1046         return *owner->contents.result;
1047 }
1048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1049         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)untag_ptr(owner);
1050         CResult_NoneNoneZ_get_ok(owner_conv);
1051 }
1052
1053 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
1054 CHECK(!owner->result_ok);
1055         return *owner->contents.err;
1056 }
1057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1058         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)untag_ptr(owner);
1059         CResult_NoneNoneZ_get_err(owner_conv);
1060 }
1061
1062 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
1063 CHECK(owner->result_ok);
1064         return CounterpartyCommitmentSecrets_clone(&*owner->contents.result);
1065 }
1066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1067         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(owner);
1068         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
1069         int64_t ret_ref = 0;
1070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1071         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1072         return ret_ref;
1073 }
1074
1075 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
1076 CHECK(!owner->result_ok);
1077         return DecodeError_clone(&*owner->contents.err);
1078 }
1079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1080         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(owner);
1081         LDKDecodeError ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
1082         int64_t ret_ref = 0;
1083         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1084         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1085         return ret_ref;
1086 }
1087
1088 static inline struct LDKSecretKey CResult_SecretKeyErrorZ_get_ok(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
1089 CHECK(owner->result_ok);
1090         return *owner->contents.result;
1091 }
1092 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1093         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)untag_ptr(owner);
1094         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
1095         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyErrorZ_get_ok(owner_conv).bytes);
1096         return ret_arr;
1097 }
1098
1099 static inline enum LDKSecp256k1Error CResult_SecretKeyErrorZ_get_err(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
1100 CHECK(!owner->result_ok);
1101         return *owner->contents.err;
1102 }
1103 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1104         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)untag_ptr(owner);
1105         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_SecretKeyErrorZ_get_err(owner_conv));
1106         return ret_conv;
1107 }
1108
1109 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
1110 CHECK(owner->result_ok);
1111         return *owner->contents.result;
1112 }
1113 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1114         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(owner);
1115         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
1116         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form);
1117         return ret_arr;
1118 }
1119
1120 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
1121 CHECK(!owner->result_ok);
1122         return *owner->contents.err;
1123 }
1124 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1125         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(owner);
1126         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PublicKeyErrorZ_get_err(owner_conv));
1127         return ret_conv;
1128 }
1129
1130 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1131 CHECK(owner->result_ok);
1132         return TxCreationKeys_clone(&*owner->contents.result);
1133 }
1134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1135         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(owner);
1136         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
1137         int64_t ret_ref = 0;
1138         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1139         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1140         return ret_ref;
1141 }
1142
1143 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1144 CHECK(!owner->result_ok);
1145         return DecodeError_clone(&*owner->contents.err);
1146 }
1147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1148         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(owner);
1149         LDKDecodeError ret_var = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
1150         int64_t ret_ref = 0;
1151         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1152         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1153         return ret_ref;
1154 }
1155
1156 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1157 CHECK(owner->result_ok);
1158         return ChannelPublicKeys_clone(&*owner->contents.result);
1159 }
1160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1161         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(owner);
1162         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
1163         int64_t ret_ref = 0;
1164         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1165         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1166         return ret_ref;
1167 }
1168
1169 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1170 CHECK(!owner->result_ok);
1171         return DecodeError_clone(&*owner->contents.err);
1172 }
1173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1174         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(owner);
1175         LDKDecodeError ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
1176         int64_t ret_ref = 0;
1177         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1178         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1179         return ret_ref;
1180 }
1181
1182 static inline struct LDKTxCreationKeys CResult_TxCreationKeysErrorZ_get_ok(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
1183 CHECK(owner->result_ok);
1184         return TxCreationKeys_clone(&*owner->contents.result);
1185 }
1186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1187         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)untag_ptr(owner);
1188         LDKTxCreationKeys ret_var = CResult_TxCreationKeysErrorZ_get_ok(owner_conv);
1189         int64_t ret_ref = 0;
1190         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1191         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1192         return ret_ref;
1193 }
1194
1195 static inline enum LDKSecp256k1Error CResult_TxCreationKeysErrorZ_get_err(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
1196 CHECK(!owner->result_ok);
1197         return *owner->contents.err;
1198 }
1199 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1200         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)untag_ptr(owner);
1201         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_TxCreationKeysErrorZ_get_err(owner_conv));
1202         return ret_conv;
1203 }
1204
1205 static jclass LDKCOption_u32Z_Some_class = NULL;
1206 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
1207 static jclass LDKCOption_u32Z_None_class = NULL;
1208 static jmethodID LDKCOption_u32Z_None_meth = NULL;
1209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
1210         LDKCOption_u32Z_Some_class =
1211                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$Some"));
1212         CHECK(LDKCOption_u32Z_Some_class != NULL);
1213         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
1214         CHECK(LDKCOption_u32Z_Some_meth != NULL);
1215         LDKCOption_u32Z_None_class =
1216                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$None"));
1217         CHECK(LDKCOption_u32Z_None_class != NULL);
1218         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
1219         CHECK(LDKCOption_u32Z_None_meth != NULL);
1220 }
1221 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1222         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)untag_ptr(ptr);
1223         switch(obj->tag) {
1224                 case LDKCOption_u32Z_Some: {
1225                         int32_t some_conv = obj->some;
1226                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, some_conv);
1227                 }
1228                 case LDKCOption_u32Z_None: {
1229                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
1230                 }
1231                 default: abort();
1232         }
1233 }
1234 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1235 CHECK(owner->result_ok);
1236         return HTLCOutputInCommitment_clone(&*owner->contents.result);
1237 }
1238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1239         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(owner);
1240         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
1241         int64_t ret_ref = 0;
1242         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1243         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1244         return ret_ref;
1245 }
1246
1247 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1248 CHECK(!owner->result_ok);
1249         return DecodeError_clone(&*owner->contents.err);
1250 }
1251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1252         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(owner);
1253         LDKDecodeError ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_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 LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1261 CHECK(owner->result_ok);
1262         return CounterpartyChannelTransactionParameters_clone(&*owner->contents.result);
1263 }
1264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1265         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1266         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1267         int64_t ret_ref = 0;
1268         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1269         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1270         return ret_ref;
1271 }
1272
1273 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1274 CHECK(!owner->result_ok);
1275         return DecodeError_clone(&*owner->contents.err);
1276 }
1277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1278         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1279         LDKDecodeError ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1280         int64_t ret_ref = 0;
1281         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1282         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1283         return ret_ref;
1284 }
1285
1286 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1287 CHECK(owner->result_ok);
1288         return ChannelTransactionParameters_clone(&*owner->contents.result);
1289 }
1290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1291         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1292         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1293         int64_t ret_ref = 0;
1294         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1295         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1296         return ret_ref;
1297 }
1298
1299 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1300 CHECK(!owner->result_ok);
1301         return DecodeError_clone(&*owner->contents.err);
1302 }
1303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1304         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1305         LDKDecodeError ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1306         int64_t ret_ref = 0;
1307         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1308         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1309         return ret_ref;
1310 }
1311
1312 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1313 CHECK(owner->result_ok);
1314         return HolderCommitmentTransaction_clone(&*owner->contents.result);
1315 }
1316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1317         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1318         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1319         int64_t ret_ref = 0;
1320         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1321         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1322         return ret_ref;
1323 }
1324
1325 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1326 CHECK(!owner->result_ok);
1327         return DecodeError_clone(&*owner->contents.err);
1328 }
1329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1330         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1331         LDKDecodeError ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1332         int64_t ret_ref = 0;
1333         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1334         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1335         return ret_ref;
1336 }
1337
1338 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1339 CHECK(owner->result_ok);
1340         return BuiltCommitmentTransaction_clone(&*owner->contents.result);
1341 }
1342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1343         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1344         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1345         int64_t ret_ref = 0;
1346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1347         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1348         return ret_ref;
1349 }
1350
1351 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1352 CHECK(!owner->result_ok);
1353         return DecodeError_clone(&*owner->contents.err);
1354 }
1355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1356         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1357         LDKDecodeError ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1358         int64_t ret_ref = 0;
1359         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1360         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1361         return ret_ref;
1362 }
1363
1364 static inline struct LDKTrustedClosingTransaction *CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1365 CHECK(owner->result_ok);
1366         return &*owner->contents.result;
1367 }
1368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1369         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(owner);
1370         LDKTrustedClosingTransaction ret_var = *CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
1371         int64_t ret_ref = 0;
1372         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1373         ret_ref = tag_ptr(ret_var.inner, false);
1374         return ret_ref;
1375 }
1376
1377 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1378 CHECK(!owner->result_ok);
1379         return *owner->contents.err;
1380 }
1381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1382         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(owner);
1383         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
1384 }
1385
1386 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1387 CHECK(owner->result_ok);
1388         return CommitmentTransaction_clone(&*owner->contents.result);
1389 }
1390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1391         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1392         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1393         int64_t ret_ref = 0;
1394         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1395         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1396         return ret_ref;
1397 }
1398
1399 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1400 CHECK(!owner->result_ok);
1401         return DecodeError_clone(&*owner->contents.err);
1402 }
1403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1404         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1405         LDKDecodeError ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1406         int64_t ret_ref = 0;
1407         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1408         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1409         return ret_ref;
1410 }
1411
1412 static inline struct LDKTrustedCommitmentTransaction *CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1413 CHECK(owner->result_ok);
1414         return &*owner->contents.result;
1415 }
1416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1417         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(owner);
1418         LDKTrustedCommitmentTransaction ret_var = *CResult_TrustedCommitmentTransactionNoneZ_get_ok(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, false);
1422         return ret_ref;
1423 }
1424
1425 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1426 CHECK(!owner->result_ok);
1427         return *owner->contents.err;
1428 }
1429 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1430         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(owner);
1431         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
1432 }
1433
1434 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1435 CHECK(owner->result_ok);
1436         return *owner->contents.result;
1437 }
1438 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1439         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(owner);
1440         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
1441         jobjectArray ret_arr = NULL;
1442         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
1443         ;
1444         for (size_t i = 0; i < ret_var.datalen; i++) {
1445                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
1446                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
1447                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
1448         }
1449         
1450         return ret_arr;
1451 }
1452
1453 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1454 CHECK(!owner->result_ok);
1455         return *owner->contents.err;
1456 }
1457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1458         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(owner);
1459         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
1460 }
1461
1462 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1463 CHECK(owner->result_ok);
1464         return ShutdownScript_clone(&*owner->contents.result);
1465 }
1466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1467         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(owner);
1468         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
1469         int64_t ret_ref = 0;
1470         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1471         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1472         return ret_ref;
1473 }
1474
1475 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1476 CHECK(!owner->result_ok);
1477         return DecodeError_clone(&*owner->contents.err);
1478 }
1479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1480         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(owner);
1481         LDKDecodeError ret_var = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
1482         int64_t ret_ref = 0;
1483         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1484         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1485         return ret_ref;
1486 }
1487
1488 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1489 CHECK(owner->result_ok);
1490         return ShutdownScript_clone(&*owner->contents.result);
1491 }
1492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1493         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(owner);
1494         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
1495         int64_t ret_ref = 0;
1496         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1497         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1498         return ret_ref;
1499 }
1500
1501 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1502 CHECK(!owner->result_ok);
1503         return InvalidShutdownScript_clone(&*owner->contents.err);
1504 }
1505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1506         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(owner);
1507         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
1508         int64_t ret_ref = 0;
1509         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1510         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1511         return ret_ref;
1512 }
1513
1514 static inline void CResult_NoneErrorZ_get_ok(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
1515 CHECK(owner->result_ok);
1516         return *owner->contents.result;
1517 }
1518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1519         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)untag_ptr(owner);
1520         CResult_NoneErrorZ_get_ok(owner_conv);
1521 }
1522
1523 static inline enum LDKIOError CResult_NoneErrorZ_get_err(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
1524 CHECK(!owner->result_ok);
1525         return *owner->contents.err;
1526 }
1527 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1528         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)untag_ptr(owner);
1529         jclass ret_conv = LDKIOError_to_java(env, CResult_NoneErrorZ_get_err(owner_conv));
1530         return ret_conv;
1531 }
1532
1533 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
1534 CHECK(owner->result_ok);
1535         return RouteHop_clone(&*owner->contents.result);
1536 }
1537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1538         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(owner);
1539         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_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 struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
1547 CHECK(!owner->result_ok);
1548         return DecodeError_clone(&*owner->contents.err);
1549 }
1550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1551         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(owner);
1552         LDKDecodeError ret_var = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
1553         int64_t ret_ref = 0;
1554         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1555         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1556         return ret_ref;
1557 }
1558
1559 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1560         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1561         for (size_t i = 0; i < ret.datalen; i++) {
1562                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1563         }
1564         return ret;
1565 }
1566 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1567         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1568         for (size_t i = 0; i < ret.datalen; i++) {
1569                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1570         }
1571         return ret;
1572 }
1573 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1574 CHECK(owner->result_ok);
1575         return Route_clone(&*owner->contents.result);
1576 }
1577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1578         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(owner);
1579         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
1580         int64_t ret_ref = 0;
1581         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1582         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1583         return ret_ref;
1584 }
1585
1586 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1587 CHECK(!owner->result_ok);
1588         return DecodeError_clone(&*owner->contents.err);
1589 }
1590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1591         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(owner);
1592         LDKDecodeError ret_var = CResult_RouteDecodeErrorZ_get_err(owner_conv);
1593         int64_t ret_ref = 0;
1594         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1595         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1596         return ret_ref;
1597 }
1598
1599 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1600 CHECK(owner->result_ok);
1601         return RouteParameters_clone(&*owner->contents.result);
1602 }
1603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1604         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(owner);
1605         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
1606         int64_t ret_ref = 0;
1607         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1608         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1609         return ret_ref;
1610 }
1611
1612 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1613 CHECK(!owner->result_ok);
1614         return DecodeError_clone(&*owner->contents.err);
1615 }
1616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1617         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(owner);
1618         LDKDecodeError ret_var = CResult_RouteParametersDecodeErrorZ_get_err(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 LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1626         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1627         for (size_t i = 0; i < ret.datalen; i++) {
1628                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1629         }
1630         return ret;
1631 }
1632 static jclass LDKCOption_u64Z_Some_class = NULL;
1633 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1634 static jclass LDKCOption_u64Z_None_class = NULL;
1635 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1637         LDKCOption_u64Z_Some_class =
1638                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$Some"));
1639         CHECK(LDKCOption_u64Z_Some_class != NULL);
1640         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1641         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1642         LDKCOption_u64Z_None_class =
1643                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$None"));
1644         CHECK(LDKCOption_u64Z_None_class != NULL);
1645         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1646         CHECK(LDKCOption_u64Z_None_meth != NULL);
1647 }
1648 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1649         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)untag_ptr(ptr);
1650         switch(obj->tag) {
1651                 case LDKCOption_u64Z_Some: {
1652                         int64_t some_conv = obj->some;
1653                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, some_conv);
1654                 }
1655                 case LDKCOption_u64Z_None: {
1656                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1657                 }
1658                 default: abort();
1659         }
1660 }
1661 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
1662         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
1663         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
1664         return ret;
1665 }
1666 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1667 CHECK(owner->result_ok);
1668         return PaymentParameters_clone(&*owner->contents.result);
1669 }
1670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1671         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(owner);
1672         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
1673         int64_t ret_ref = 0;
1674         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1675         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1676         return ret_ref;
1677 }
1678
1679 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1680 CHECK(!owner->result_ok);
1681         return DecodeError_clone(&*owner->contents.err);
1682 }
1683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1684         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(owner);
1685         LDKDecodeError ret_var = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
1686         int64_t ret_ref = 0;
1687         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1688         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1689         return ret_ref;
1690 }
1691
1692 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
1693         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
1694         for (size_t i = 0; i < ret.datalen; i++) {
1695                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
1696         }
1697         return ret;
1698 }
1699 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1700 CHECK(owner->result_ok);
1701         return RouteHint_clone(&*owner->contents.result);
1702 }
1703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1704         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(owner);
1705         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
1706         int64_t ret_ref = 0;
1707         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1708         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1709         return ret_ref;
1710 }
1711
1712 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1713 CHECK(!owner->result_ok);
1714         return DecodeError_clone(&*owner->contents.err);
1715 }
1716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1717         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(owner);
1718         LDKDecodeError ret_var = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
1719         int64_t ret_ref = 0;
1720         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1721         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1722         return ret_ref;
1723 }
1724
1725 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1726 CHECK(owner->result_ok);
1727         return RouteHintHop_clone(&*owner->contents.result);
1728 }
1729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1730         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(owner);
1731         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
1732         int64_t ret_ref = 0;
1733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1734         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1735         return ret_ref;
1736 }
1737
1738 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1739 CHECK(!owner->result_ok);
1740         return DecodeError_clone(&*owner->contents.err);
1741 }
1742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1743         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(owner);
1744         LDKDecodeError ret_var = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
1745         int64_t ret_ref = 0;
1746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1747         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1748         return ret_ref;
1749 }
1750
1751 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1752         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1753         for (size_t i = 0; i < ret.datalen; i++) {
1754                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1755         }
1756         return ret;
1757 }
1758 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1759 CHECK(owner->result_ok);
1760         return Route_clone(&*owner->contents.result);
1761 }
1762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1763         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(owner);
1764         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
1765         int64_t ret_ref = 0;
1766         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1767         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1768         return ret_ref;
1769 }
1770
1771 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1772 CHECK(!owner->result_ok);
1773         return LightningError_clone(&*owner->contents.err);
1774 }
1775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1776         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(owner);
1777         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
1778         int64_t ret_ref = 0;
1779         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1780         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1781         return ret_ref;
1782 }
1783
1784 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
1785 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
1786 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
1787 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
1788 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
1789         LDKPaymentPurpose_InvoicePayment_class =
1790                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment"));
1791         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
1792         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[B)V");
1793         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
1794         LDKPaymentPurpose_SpontaneousPayment_class =
1795                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment"));
1796         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
1797         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
1798         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
1799 }
1800 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1801         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)untag_ptr(ptr);
1802         switch(obj->tag) {
1803                 case LDKPaymentPurpose_InvoicePayment: {
1804                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
1805                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
1806                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
1807                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
1808                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr);
1809                 }
1810                 case LDKPaymentPurpose_SpontaneousPayment: {
1811                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
1812                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
1813                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
1814                 }
1815                 default: abort();
1816         }
1817 }
1818 static inline struct LDKPaymentPurpose CResult_PaymentPurposeDecodeErrorZ_get_ok(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
1819 CHECK(owner->result_ok);
1820         return PaymentPurpose_clone(&*owner->contents.result);
1821 }
1822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1823         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(owner);
1824         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
1825         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_ok(owner_conv);
1826         int64_t ret_ref = tag_ptr(ret_copy, true);
1827         return ret_ref;
1828 }
1829
1830 static inline struct LDKDecodeError CResult_PaymentPurposeDecodeErrorZ_get_err(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
1831 CHECK(!owner->result_ok);
1832         return DecodeError_clone(&*owner->contents.err);
1833 }
1834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1835         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(owner);
1836         LDKDecodeError ret_var = CResult_PaymentPurposeDecodeErrorZ_get_err(owner_conv);
1837         int64_t ret_ref = 0;
1838         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1839         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1840         return ret_ref;
1841 }
1842
1843 static jclass LDKClosureReason_CounterpartyForceClosed_class = NULL;
1844 static jmethodID LDKClosureReason_CounterpartyForceClosed_meth = NULL;
1845 static jclass LDKClosureReason_HolderForceClosed_class = NULL;
1846 static jmethodID LDKClosureReason_HolderForceClosed_meth = NULL;
1847 static jclass LDKClosureReason_CooperativeClosure_class = NULL;
1848 static jmethodID LDKClosureReason_CooperativeClosure_meth = NULL;
1849 static jclass LDKClosureReason_CommitmentTxConfirmed_class = NULL;
1850 static jmethodID LDKClosureReason_CommitmentTxConfirmed_meth = NULL;
1851 static jclass LDKClosureReason_FundingTimedOut_class = NULL;
1852 static jmethodID LDKClosureReason_FundingTimedOut_meth = NULL;
1853 static jclass LDKClosureReason_ProcessingError_class = NULL;
1854 static jmethodID LDKClosureReason_ProcessingError_meth = NULL;
1855 static jclass LDKClosureReason_DisconnectedPeer_class = NULL;
1856 static jmethodID LDKClosureReason_DisconnectedPeer_meth = NULL;
1857 static jclass LDKClosureReason_OutdatedChannelManager_class = NULL;
1858 static jmethodID LDKClosureReason_OutdatedChannelManager_meth = NULL;
1859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init (JNIEnv *env, jclass clz) {
1860         LDKClosureReason_CounterpartyForceClosed_class =
1861                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CounterpartyForceClosed"));
1862         CHECK(LDKClosureReason_CounterpartyForceClosed_class != NULL);
1863         LDKClosureReason_CounterpartyForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_CounterpartyForceClosed_class, "<init>", "(Ljava/lang/String;)V");
1864         CHECK(LDKClosureReason_CounterpartyForceClosed_meth != NULL);
1865         LDKClosureReason_HolderForceClosed_class =
1866                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$HolderForceClosed"));
1867         CHECK(LDKClosureReason_HolderForceClosed_class != NULL);
1868         LDKClosureReason_HolderForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_HolderForceClosed_class, "<init>", "()V");
1869         CHECK(LDKClosureReason_HolderForceClosed_meth != NULL);
1870         LDKClosureReason_CooperativeClosure_class =
1871                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CooperativeClosure"));
1872         CHECK(LDKClosureReason_CooperativeClosure_class != NULL);
1873         LDKClosureReason_CooperativeClosure_meth = (*env)->GetMethodID(env, LDKClosureReason_CooperativeClosure_class, "<init>", "()V");
1874         CHECK(LDKClosureReason_CooperativeClosure_meth != NULL);
1875         LDKClosureReason_CommitmentTxConfirmed_class =
1876                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CommitmentTxConfirmed"));
1877         CHECK(LDKClosureReason_CommitmentTxConfirmed_class != NULL);
1878         LDKClosureReason_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKClosureReason_CommitmentTxConfirmed_class, "<init>", "()V");
1879         CHECK(LDKClosureReason_CommitmentTxConfirmed_meth != NULL);
1880         LDKClosureReason_FundingTimedOut_class =
1881                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$FundingTimedOut"));
1882         CHECK(LDKClosureReason_FundingTimedOut_class != NULL);
1883         LDKClosureReason_FundingTimedOut_meth = (*env)->GetMethodID(env, LDKClosureReason_FundingTimedOut_class, "<init>", "()V");
1884         CHECK(LDKClosureReason_FundingTimedOut_meth != NULL);
1885         LDKClosureReason_ProcessingError_class =
1886                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$ProcessingError"));
1887         CHECK(LDKClosureReason_ProcessingError_class != NULL);
1888         LDKClosureReason_ProcessingError_meth = (*env)->GetMethodID(env, LDKClosureReason_ProcessingError_class, "<init>", "(Ljava/lang/String;)V");
1889         CHECK(LDKClosureReason_ProcessingError_meth != NULL);
1890         LDKClosureReason_DisconnectedPeer_class =
1891                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$DisconnectedPeer"));
1892         CHECK(LDKClosureReason_DisconnectedPeer_class != NULL);
1893         LDKClosureReason_DisconnectedPeer_meth = (*env)->GetMethodID(env, LDKClosureReason_DisconnectedPeer_class, "<init>", "()V");
1894         CHECK(LDKClosureReason_DisconnectedPeer_meth != NULL);
1895         LDKClosureReason_OutdatedChannelManager_class =
1896                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$OutdatedChannelManager"));
1897         CHECK(LDKClosureReason_OutdatedChannelManager_class != NULL);
1898         LDKClosureReason_OutdatedChannelManager_meth = (*env)->GetMethodID(env, LDKClosureReason_OutdatedChannelManager_class, "<init>", "()V");
1899         CHECK(LDKClosureReason_OutdatedChannelManager_meth != NULL);
1900 }
1901 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1902         LDKClosureReason *obj = (LDKClosureReason*)untag_ptr(ptr);
1903         switch(obj->tag) {
1904                 case LDKClosureReason_CounterpartyForceClosed: {
1905                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
1906                         jstring peer_msg_conv = str_ref_to_java(env, peer_msg_str.chars, peer_msg_str.len);
1907                         return (*env)->NewObject(env, LDKClosureReason_CounterpartyForceClosed_class, LDKClosureReason_CounterpartyForceClosed_meth, peer_msg_conv);
1908                 }
1909                 case LDKClosureReason_HolderForceClosed: {
1910                         return (*env)->NewObject(env, LDKClosureReason_HolderForceClosed_class, LDKClosureReason_HolderForceClosed_meth);
1911                 }
1912                 case LDKClosureReason_CooperativeClosure: {
1913                         return (*env)->NewObject(env, LDKClosureReason_CooperativeClosure_class, LDKClosureReason_CooperativeClosure_meth);
1914                 }
1915                 case LDKClosureReason_CommitmentTxConfirmed: {
1916                         return (*env)->NewObject(env, LDKClosureReason_CommitmentTxConfirmed_class, LDKClosureReason_CommitmentTxConfirmed_meth);
1917                 }
1918                 case LDKClosureReason_FundingTimedOut: {
1919                         return (*env)->NewObject(env, LDKClosureReason_FundingTimedOut_class, LDKClosureReason_FundingTimedOut_meth);
1920                 }
1921                 case LDKClosureReason_ProcessingError: {
1922                         LDKStr err_str = obj->processing_error.err;
1923                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
1924                         return (*env)->NewObject(env, LDKClosureReason_ProcessingError_class, LDKClosureReason_ProcessingError_meth, err_conv);
1925                 }
1926                 case LDKClosureReason_DisconnectedPeer: {
1927                         return (*env)->NewObject(env, LDKClosureReason_DisconnectedPeer_class, LDKClosureReason_DisconnectedPeer_meth);
1928                 }
1929                 case LDKClosureReason_OutdatedChannelManager: {
1930                         return (*env)->NewObject(env, LDKClosureReason_OutdatedChannelManager_class, LDKClosureReason_OutdatedChannelManager_meth);
1931                 }
1932                 default: abort();
1933         }
1934 }
1935 static jclass LDKCOption_ClosureReasonZ_Some_class = NULL;
1936 static jmethodID LDKCOption_ClosureReasonZ_Some_meth = NULL;
1937 static jclass LDKCOption_ClosureReasonZ_None_class = NULL;
1938 static jmethodID LDKCOption_ClosureReasonZ_None_meth = NULL;
1939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ClosureReasonZ_init (JNIEnv *env, jclass clz) {
1940         LDKCOption_ClosureReasonZ_Some_class =
1941                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$Some"));
1942         CHECK(LDKCOption_ClosureReasonZ_Some_class != NULL);
1943         LDKCOption_ClosureReasonZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_Some_class, "<init>", "(J)V");
1944         CHECK(LDKCOption_ClosureReasonZ_Some_meth != NULL);
1945         LDKCOption_ClosureReasonZ_None_class =
1946                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$None"));
1947         CHECK(LDKCOption_ClosureReasonZ_None_class != NULL);
1948         LDKCOption_ClosureReasonZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_None_class, "<init>", "()V");
1949         CHECK(LDKCOption_ClosureReasonZ_None_meth != NULL);
1950 }
1951 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ClosureReasonZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1952         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)untag_ptr(ptr);
1953         switch(obj->tag) {
1954                 case LDKCOption_ClosureReasonZ_Some: {
1955                         int64_t some_ref = tag_ptr(&obj->some, false);
1956                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_Some_class, LDKCOption_ClosureReasonZ_Some_meth, some_ref);
1957                 }
1958                 case LDKCOption_ClosureReasonZ_None: {
1959                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_None_class, LDKCOption_ClosureReasonZ_None_meth);
1960                 }
1961                 default: abort();
1962         }
1963 }
1964 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
1965 CHECK(owner->result_ok);
1966         return COption_ClosureReasonZ_clone(&*owner->contents.result);
1967 }
1968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1969         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(owner);
1970         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
1971         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
1972         int64_t ret_ref = tag_ptr(ret_copy, true);
1973         return ret_ref;
1974 }
1975
1976 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
1977 CHECK(!owner->result_ok);
1978         return DecodeError_clone(&*owner->contents.err);
1979 }
1980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1981         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(owner);
1982         LDKDecodeError ret_var = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
1983         int64_t ret_ref = 0;
1984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1985         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1986         return ret_ref;
1987 }
1988
1989 static jclass LDKHTLCDestination_NextHopChannel_class = NULL;
1990 static jmethodID LDKHTLCDestination_NextHopChannel_meth = NULL;
1991 static jclass LDKHTLCDestination_UnknownNextHop_class = NULL;
1992 static jmethodID LDKHTLCDestination_UnknownNextHop_meth = NULL;
1993 static jclass LDKHTLCDestination_FailedPayment_class = NULL;
1994 static jmethodID LDKHTLCDestination_FailedPayment_meth = NULL;
1995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCDestination_init (JNIEnv *env, jclass clz) {
1996         LDKHTLCDestination_NextHopChannel_class =
1997                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$NextHopChannel"));
1998         CHECK(LDKHTLCDestination_NextHopChannel_class != NULL);
1999         LDKHTLCDestination_NextHopChannel_meth = (*env)->GetMethodID(env, LDKHTLCDestination_NextHopChannel_class, "<init>", "([B[B)V");
2000         CHECK(LDKHTLCDestination_NextHopChannel_meth != NULL);
2001         LDKHTLCDestination_UnknownNextHop_class =
2002                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$UnknownNextHop"));
2003         CHECK(LDKHTLCDestination_UnknownNextHop_class != NULL);
2004         LDKHTLCDestination_UnknownNextHop_meth = (*env)->GetMethodID(env, LDKHTLCDestination_UnknownNextHop_class, "<init>", "(J)V");
2005         CHECK(LDKHTLCDestination_UnknownNextHop_meth != NULL);
2006         LDKHTLCDestination_FailedPayment_class =
2007                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$FailedPayment"));
2008         CHECK(LDKHTLCDestination_FailedPayment_class != NULL);
2009         LDKHTLCDestination_FailedPayment_meth = (*env)->GetMethodID(env, LDKHTLCDestination_FailedPayment_class, "<init>", "([B)V");
2010         CHECK(LDKHTLCDestination_FailedPayment_meth != NULL);
2011 }
2012 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCDestination_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2013         LDKHTLCDestination *obj = (LDKHTLCDestination*)untag_ptr(ptr);
2014         switch(obj->tag) {
2015                 case LDKHTLCDestination_NextHopChannel: {
2016                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2017                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->next_hop_channel.node_id.compressed_form);
2018                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2019                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->next_hop_channel.channel_id.data);
2020                         return (*env)->NewObject(env, LDKHTLCDestination_NextHopChannel_class, LDKHTLCDestination_NextHopChannel_meth, node_id_arr, channel_id_arr);
2021                 }
2022                 case LDKHTLCDestination_UnknownNextHop: {
2023                         int64_t requested_forward_scid_conv = obj->unknown_next_hop.requested_forward_scid;
2024                         return (*env)->NewObject(env, LDKHTLCDestination_UnknownNextHop_class, LDKHTLCDestination_UnknownNextHop_meth, requested_forward_scid_conv);
2025                 }
2026                 case LDKHTLCDestination_FailedPayment: {
2027                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2028                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->failed_payment.payment_hash.data);
2029                         return (*env)->NewObject(env, LDKHTLCDestination_FailedPayment_class, LDKHTLCDestination_FailedPayment_meth, payment_hash_arr);
2030                 }
2031                 default: abort();
2032         }
2033 }
2034 static jclass LDKCOption_HTLCDestinationZ_Some_class = NULL;
2035 static jmethodID LDKCOption_HTLCDestinationZ_Some_meth = NULL;
2036 static jclass LDKCOption_HTLCDestinationZ_None_class = NULL;
2037 static jmethodID LDKCOption_HTLCDestinationZ_None_meth = NULL;
2038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1HTLCDestinationZ_init (JNIEnv *env, jclass clz) {
2039         LDKCOption_HTLCDestinationZ_Some_class =
2040                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCDestinationZ$Some"));
2041         CHECK(LDKCOption_HTLCDestinationZ_Some_class != NULL);
2042         LDKCOption_HTLCDestinationZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_HTLCDestinationZ_Some_class, "<init>", "(J)V");
2043         CHECK(LDKCOption_HTLCDestinationZ_Some_meth != NULL);
2044         LDKCOption_HTLCDestinationZ_None_class =
2045                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCDestinationZ$None"));
2046         CHECK(LDKCOption_HTLCDestinationZ_None_class != NULL);
2047         LDKCOption_HTLCDestinationZ_None_meth = (*env)->GetMethodID(env, LDKCOption_HTLCDestinationZ_None_class, "<init>", "()V");
2048         CHECK(LDKCOption_HTLCDestinationZ_None_meth != NULL);
2049 }
2050 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1HTLCDestinationZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2051         LDKCOption_HTLCDestinationZ *obj = (LDKCOption_HTLCDestinationZ*)untag_ptr(ptr);
2052         switch(obj->tag) {
2053                 case LDKCOption_HTLCDestinationZ_Some: {
2054                         int64_t some_ref = tag_ptr(&obj->some, false);
2055                         return (*env)->NewObject(env, LDKCOption_HTLCDestinationZ_Some_class, LDKCOption_HTLCDestinationZ_Some_meth, some_ref);
2056                 }
2057                 case LDKCOption_HTLCDestinationZ_None: {
2058                         return (*env)->NewObject(env, LDKCOption_HTLCDestinationZ_None_class, LDKCOption_HTLCDestinationZ_None_meth);
2059                 }
2060                 default: abort();
2061         }
2062 }
2063 static inline struct LDKCOption_HTLCDestinationZ CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
2064 CHECK(owner->result_ok);
2065         return COption_HTLCDestinationZ_clone(&*owner->contents.result);
2066 }
2067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2068         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(owner);
2069         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
2070         *ret_copy = CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(owner_conv);
2071         int64_t ret_ref = tag_ptr(ret_copy, true);
2072         return ret_ref;
2073 }
2074
2075 static inline struct LDKDecodeError CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
2076 CHECK(!owner->result_ok);
2077         return DecodeError_clone(&*owner->contents.err);
2078 }
2079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2080         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(owner);
2081         LDKDecodeError ret_var = CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(owner_conv);
2082         int64_t ret_ref = 0;
2083         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2084         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2085         return ret_ref;
2086 }
2087
2088 static jclass LDKNetworkUpdate_ChannelUpdateMessage_class = NULL;
2089 static jmethodID LDKNetworkUpdate_ChannelUpdateMessage_meth = NULL;
2090 static jclass LDKNetworkUpdate_ChannelFailure_class = NULL;
2091 static jmethodID LDKNetworkUpdate_ChannelFailure_meth = NULL;
2092 static jclass LDKNetworkUpdate_NodeFailure_class = NULL;
2093 static jmethodID LDKNetworkUpdate_NodeFailure_meth = NULL;
2094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetworkUpdate_init (JNIEnv *env, jclass clz) {
2095         LDKNetworkUpdate_ChannelUpdateMessage_class =
2096                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelUpdateMessage"));
2097         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_class != NULL);
2098         LDKNetworkUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
2099         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_meth != NULL);
2100         LDKNetworkUpdate_ChannelFailure_class =
2101                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelFailure"));
2102         CHECK(LDKNetworkUpdate_ChannelFailure_class != NULL);
2103         LDKNetworkUpdate_ChannelFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelFailure_class, "<init>", "(JZ)V");
2104         CHECK(LDKNetworkUpdate_ChannelFailure_meth != NULL);
2105         LDKNetworkUpdate_NodeFailure_class =
2106                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$NodeFailure"));
2107         CHECK(LDKNetworkUpdate_NodeFailure_class != NULL);
2108         LDKNetworkUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_NodeFailure_class, "<init>", "([BZ)V");
2109         CHECK(LDKNetworkUpdate_NodeFailure_meth != NULL);
2110 }
2111 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2112         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)untag_ptr(ptr);
2113         switch(obj->tag) {
2114                 case LDKNetworkUpdate_ChannelUpdateMessage: {
2115                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
2116                         int64_t msg_ref = 0;
2117                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2118                         msg_ref = tag_ptr(msg_var.inner, false);
2119                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelUpdateMessage_class, LDKNetworkUpdate_ChannelUpdateMessage_meth, msg_ref);
2120                 }
2121                 case LDKNetworkUpdate_ChannelFailure: {
2122                         int64_t short_channel_id_conv = obj->channel_failure.short_channel_id;
2123                         jboolean is_permanent_conv = obj->channel_failure.is_permanent;
2124                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelFailure_class, LDKNetworkUpdate_ChannelFailure_meth, short_channel_id_conv, is_permanent_conv);
2125                 }
2126                 case LDKNetworkUpdate_NodeFailure: {
2127                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2128                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
2129                         jboolean is_permanent_conv = obj->node_failure.is_permanent;
2130                         return (*env)->NewObject(env, LDKNetworkUpdate_NodeFailure_class, LDKNetworkUpdate_NodeFailure_meth, node_id_arr, is_permanent_conv);
2131                 }
2132                 default: abort();
2133         }
2134 }
2135 static jclass LDKCOption_NetworkUpdateZ_Some_class = NULL;
2136 static jmethodID LDKCOption_NetworkUpdateZ_Some_meth = NULL;
2137 static jclass LDKCOption_NetworkUpdateZ_None_class = NULL;
2138 static jmethodID LDKCOption_NetworkUpdateZ_None_meth = NULL;
2139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetworkUpdateZ_init (JNIEnv *env, jclass clz) {
2140         LDKCOption_NetworkUpdateZ_Some_class =
2141                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$Some"));
2142         CHECK(LDKCOption_NetworkUpdateZ_Some_class != NULL);
2143         LDKCOption_NetworkUpdateZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_Some_class, "<init>", "(J)V");
2144         CHECK(LDKCOption_NetworkUpdateZ_Some_meth != NULL);
2145         LDKCOption_NetworkUpdateZ_None_class =
2146                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$None"));
2147         CHECK(LDKCOption_NetworkUpdateZ_None_class != NULL);
2148         LDKCOption_NetworkUpdateZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_None_class, "<init>", "()V");
2149         CHECK(LDKCOption_NetworkUpdateZ_None_meth != NULL);
2150 }
2151 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetworkUpdateZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2152         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)untag_ptr(ptr);
2153         switch(obj->tag) {
2154                 case LDKCOption_NetworkUpdateZ_Some: {
2155                         int64_t some_ref = tag_ptr(&obj->some, false);
2156                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_Some_class, LDKCOption_NetworkUpdateZ_Some_meth, some_ref);
2157                 }
2158                 case LDKCOption_NetworkUpdateZ_None: {
2159                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_None_class, LDKCOption_NetworkUpdateZ_None_meth);
2160                 }
2161                 default: abort();
2162         }
2163 }
2164 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
2165 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
2166 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
2167 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
2168 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
2169 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
2170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
2171         LDKSpendableOutputDescriptor_StaticOutput_class =
2172                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput"));
2173         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
2174         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
2175         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
2176         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
2177                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput"));
2178         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
2179         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
2180         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
2181         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
2182                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput"));
2183         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
2184         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
2185         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
2186 }
2187 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2188         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)untag_ptr(ptr);
2189         switch(obj->tag) {
2190                 case LDKSpendableOutputDescriptor_StaticOutput: {
2191                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
2192                         int64_t outpoint_ref = 0;
2193                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
2194                         outpoint_ref = tag_ptr(outpoint_var.inner, false);
2195                         LDKTxOut* output_ref = &obj->static_output.output;
2196                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, tag_ptr(output_ref, false));
2197                 }
2198                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
2199                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
2200                         int64_t delayed_payment_output_ref = 0;
2201                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
2202                         delayed_payment_output_ref = tag_ptr(delayed_payment_output_var.inner, false);
2203                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
2204                 }
2205                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
2206                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
2207                         int64_t static_payment_output_ref = 0;
2208                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
2209                         static_payment_output_ref = tag_ptr(static_payment_output_var.inner, false);
2210                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
2211                 }
2212                 default: abort();
2213         }
2214 }
2215 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
2216         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
2217         for (size_t i = 0; i < ret.datalen; i++) {
2218                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
2219         }
2220         return ret;
2221 }
2222 static jclass LDKEvent_FundingGenerationReady_class = NULL;
2223 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
2224 static jclass LDKEvent_PaymentReceived_class = NULL;
2225 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
2226 static jclass LDKEvent_PaymentClaimed_class = NULL;
2227 static jmethodID LDKEvent_PaymentClaimed_meth = NULL;
2228 static jclass LDKEvent_PaymentSent_class = NULL;
2229 static jmethodID LDKEvent_PaymentSent_meth = NULL;
2230 static jclass LDKEvent_PaymentFailed_class = NULL;
2231 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
2232 static jclass LDKEvent_PaymentPathSuccessful_class = NULL;
2233 static jmethodID LDKEvent_PaymentPathSuccessful_meth = NULL;
2234 static jclass LDKEvent_PaymentPathFailed_class = NULL;
2235 static jmethodID LDKEvent_PaymentPathFailed_meth = NULL;
2236 static jclass LDKEvent_ProbeSuccessful_class = NULL;
2237 static jmethodID LDKEvent_ProbeSuccessful_meth = NULL;
2238 static jclass LDKEvent_ProbeFailed_class = NULL;
2239 static jmethodID LDKEvent_ProbeFailed_meth = NULL;
2240 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
2241 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
2242 static jclass LDKEvent_SpendableOutputs_class = NULL;
2243 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
2244 static jclass LDKEvent_PaymentForwarded_class = NULL;
2245 static jmethodID LDKEvent_PaymentForwarded_meth = NULL;
2246 static jclass LDKEvent_ChannelClosed_class = NULL;
2247 static jmethodID LDKEvent_ChannelClosed_meth = NULL;
2248 static jclass LDKEvent_DiscardFunding_class = NULL;
2249 static jmethodID LDKEvent_DiscardFunding_meth = NULL;
2250 static jclass LDKEvent_OpenChannelRequest_class = NULL;
2251 static jmethodID LDKEvent_OpenChannelRequest_meth = NULL;
2252 static jclass LDKEvent_HTLCHandlingFailed_class = NULL;
2253 static jmethodID LDKEvent_HTLCHandlingFailed_meth = NULL;
2254 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
2255         LDKEvent_FundingGenerationReady_class =
2256                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$FundingGenerationReady"));
2257         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
2258         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([B[BJ[BJ)V");
2259         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
2260         LDKEvent_PaymentReceived_class =
2261                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentReceived"));
2262         CHECK(LDKEvent_PaymentReceived_class != NULL);
2263         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([BJJ)V");
2264         CHECK(LDKEvent_PaymentReceived_meth != NULL);
2265         LDKEvent_PaymentClaimed_class =
2266                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentClaimed"));
2267         CHECK(LDKEvent_PaymentClaimed_class != NULL);
2268         LDKEvent_PaymentClaimed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentClaimed_class, "<init>", "([BJJ)V");
2269         CHECK(LDKEvent_PaymentClaimed_meth != NULL);
2270         LDKEvent_PaymentSent_class =
2271                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentSent"));
2272         CHECK(LDKEvent_PaymentSent_class != NULL);
2273         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B[BJ)V");
2274         CHECK(LDKEvent_PaymentSent_meth != NULL);
2275         LDKEvent_PaymentFailed_class =
2276                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentFailed"));
2277         CHECK(LDKEvent_PaymentFailed_class != NULL);
2278         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([B[B)V");
2279         CHECK(LDKEvent_PaymentFailed_meth != NULL);
2280         LDKEvent_PaymentPathSuccessful_class =
2281                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathSuccessful"));
2282         CHECK(LDKEvent_PaymentPathSuccessful_class != NULL);
2283         LDKEvent_PaymentPathSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathSuccessful_class, "<init>", "([B[B[J)V");
2284         CHECK(LDKEvent_PaymentPathSuccessful_meth != NULL);
2285         LDKEvent_PaymentPathFailed_class =
2286                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathFailed"));
2287         CHECK(LDKEvent_PaymentPathFailed_class != NULL);
2288         LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "<init>", "([B[BZJZ[JJJ)V");
2289         CHECK(LDKEvent_PaymentPathFailed_meth != NULL);
2290         LDKEvent_ProbeSuccessful_class =
2291                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ProbeSuccessful"));
2292         CHECK(LDKEvent_ProbeSuccessful_class != NULL);
2293         LDKEvent_ProbeSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_ProbeSuccessful_class, "<init>", "([B[B[J)V");
2294         CHECK(LDKEvent_ProbeSuccessful_meth != NULL);
2295         LDKEvent_ProbeFailed_class =
2296                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ProbeFailed"));
2297         CHECK(LDKEvent_ProbeFailed_class != NULL);
2298         LDKEvent_ProbeFailed_meth = (*env)->GetMethodID(env, LDKEvent_ProbeFailed_class, "<init>", "([B[B[JJ)V");
2299         CHECK(LDKEvent_ProbeFailed_meth != NULL);
2300         LDKEvent_PendingHTLCsForwardable_class =
2301                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable"));
2302         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
2303         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
2304         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
2305         LDKEvent_SpendableOutputs_class =
2306                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$SpendableOutputs"));
2307         CHECK(LDKEvent_SpendableOutputs_class != NULL);
2308         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
2309         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
2310         LDKEvent_PaymentForwarded_class =
2311                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentForwarded"));
2312         CHECK(LDKEvent_PaymentForwarded_class != NULL);
2313         LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "<init>", "([B[BJZ)V");
2314         CHECK(LDKEvent_PaymentForwarded_meth != NULL);
2315         LDKEvent_ChannelClosed_class =
2316                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ChannelClosed"));
2317         CHECK(LDKEvent_ChannelClosed_class != NULL);
2318         LDKEvent_ChannelClosed_meth = (*env)->GetMethodID(env, LDKEvent_ChannelClosed_class, "<init>", "([BJJ)V");
2319         CHECK(LDKEvent_ChannelClosed_meth != NULL);
2320         LDKEvent_DiscardFunding_class =
2321                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$DiscardFunding"));
2322         CHECK(LDKEvent_DiscardFunding_class != NULL);
2323         LDKEvent_DiscardFunding_meth = (*env)->GetMethodID(env, LDKEvent_DiscardFunding_class, "<init>", "([B[B)V");
2324         CHECK(LDKEvent_DiscardFunding_meth != NULL);
2325         LDKEvent_OpenChannelRequest_class =
2326                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$OpenChannelRequest"));
2327         CHECK(LDKEvent_OpenChannelRequest_class != NULL);
2328         LDKEvent_OpenChannelRequest_meth = (*env)->GetMethodID(env, LDKEvent_OpenChannelRequest_class, "<init>", "([B[BJJJ)V");
2329         CHECK(LDKEvent_OpenChannelRequest_meth != NULL);
2330         LDKEvent_HTLCHandlingFailed_class =
2331                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$HTLCHandlingFailed"));
2332         CHECK(LDKEvent_HTLCHandlingFailed_class != NULL);
2333         LDKEvent_HTLCHandlingFailed_meth = (*env)->GetMethodID(env, LDKEvent_HTLCHandlingFailed_class, "<init>", "([BJ)V");
2334         CHECK(LDKEvent_HTLCHandlingFailed_meth != NULL);
2335 }
2336 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2337         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
2338         switch(obj->tag) {
2339                 case LDKEvent_FundingGenerationReady: {
2340                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
2341                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
2342                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
2343                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->funding_generation_ready.counterparty_node_id.compressed_form);
2344                         int64_t channel_value_satoshis_conv = obj->funding_generation_ready.channel_value_satoshis;
2345                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
2346                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
2347                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
2348                         int64_t user_channel_id_conv = obj->funding_generation_ready.user_channel_id;
2349                         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);
2350                 }
2351                 case LDKEvent_PaymentReceived: {
2352                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2353                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
2354                         int64_t amount_msat_conv = obj->payment_received.amount_msat;
2355                         int64_t purpose_ref = tag_ptr(&obj->payment_received.purpose, false);
2356                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, amount_msat_conv, purpose_ref);
2357                 }
2358                 case LDKEvent_PaymentClaimed: {
2359                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2360                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_claimed.payment_hash.data);
2361                         int64_t amount_msat_conv = obj->payment_claimed.amount_msat;
2362                         int64_t purpose_ref = tag_ptr(&obj->payment_claimed.purpose, false);
2363                         return (*env)->NewObject(env, LDKEvent_PaymentClaimed_class, LDKEvent_PaymentClaimed_meth, payment_hash_arr, amount_msat_conv, purpose_ref);
2364                 }
2365                 case LDKEvent_PaymentSent: {
2366                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2367                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_sent.payment_id.data);
2368                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
2369                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
2370                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2371                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_sent.payment_hash.data);
2372                         int64_t fee_paid_msat_ref = tag_ptr(&obj->payment_sent.fee_paid_msat, false);
2373                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_id_arr, payment_preimage_arr, payment_hash_arr, fee_paid_msat_ref);
2374                 }
2375                 case LDKEvent_PaymentFailed: {
2376                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2377                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_failed.payment_id.data);
2378                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2379                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
2380                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_id_arr, payment_hash_arr);
2381                 }
2382                 case LDKEvent_PaymentPathSuccessful: {
2383                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2384                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_successful.payment_id.data);
2385                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2386                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_successful.payment_hash.data);
2387                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
2388                         int64_tArray path_arr = NULL;
2389                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2390                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2391                         for (size_t k = 0; k < path_var.datalen; k++) {
2392                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2393                                 int64_t path_conv_10_ref = 0;
2394                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2395                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
2396                                 path_arr_ptr[k] = path_conv_10_ref;
2397                         }
2398                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2399                         return (*env)->NewObject(env, LDKEvent_PaymentPathSuccessful_class, LDKEvent_PaymentPathSuccessful_meth, payment_id_arr, payment_hash_arr, path_arr);
2400                 }
2401                 case LDKEvent_PaymentPathFailed: {
2402                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2403                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_failed.payment_id.data);
2404                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2405                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_failed.payment_hash.data);
2406                         jboolean rejected_by_dest_conv = obj->payment_path_failed.rejected_by_dest;
2407                         int64_t network_update_ref = tag_ptr(&obj->payment_path_failed.network_update, false);
2408                         jboolean all_paths_failed_conv = obj->payment_path_failed.all_paths_failed;
2409                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
2410                         int64_tArray path_arr = NULL;
2411                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2412                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2413                         for (size_t k = 0; k < path_var.datalen; k++) {
2414                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2415                                 int64_t path_conv_10_ref = 0;
2416                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2417                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
2418                                 path_arr_ptr[k] = path_conv_10_ref;
2419                         }
2420                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2421                         int64_t short_channel_id_ref = tag_ptr(&obj->payment_path_failed.short_channel_id, false);
2422                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
2423                         int64_t retry_ref = 0;
2424                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
2425                         retry_ref = tag_ptr(retry_var.inner, false);
2426                         return (*env)->NewObject(env, LDKEvent_PaymentPathFailed_class, LDKEvent_PaymentPathFailed_meth, payment_id_arr, payment_hash_arr, rejected_by_dest_conv, network_update_ref, all_paths_failed_conv, path_arr, short_channel_id_ref, retry_ref);
2427                 }
2428                 case LDKEvent_ProbeSuccessful: {
2429                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2430                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->probe_successful.payment_id.data);
2431                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2432                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->probe_successful.payment_hash.data);
2433                         LDKCVec_RouteHopZ path_var = obj->probe_successful.path;
2434                         int64_tArray path_arr = NULL;
2435                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2436                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2437                         for (size_t k = 0; k < path_var.datalen; k++) {
2438                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2439                                 int64_t path_conv_10_ref = 0;
2440                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2441                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
2442                                 path_arr_ptr[k] = path_conv_10_ref;
2443                         }
2444                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2445                         return (*env)->NewObject(env, LDKEvent_ProbeSuccessful_class, LDKEvent_ProbeSuccessful_meth, payment_id_arr, payment_hash_arr, path_arr);
2446                 }
2447                 case LDKEvent_ProbeFailed: {
2448                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2449                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->probe_failed.payment_id.data);
2450                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2451                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->probe_failed.payment_hash.data);
2452                         LDKCVec_RouteHopZ path_var = obj->probe_failed.path;
2453                         int64_tArray path_arr = NULL;
2454                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2455                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2456                         for (size_t k = 0; k < path_var.datalen; k++) {
2457                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2458                                 int64_t path_conv_10_ref = 0;
2459                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2460                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
2461                                 path_arr_ptr[k] = path_conv_10_ref;
2462                         }
2463                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2464                         int64_t short_channel_id_ref = tag_ptr(&obj->probe_failed.short_channel_id, false);
2465                         return (*env)->NewObject(env, LDKEvent_ProbeFailed_class, LDKEvent_ProbeFailed_meth, payment_id_arr, payment_hash_arr, path_arr, short_channel_id_ref);
2466                 }
2467                 case LDKEvent_PendingHTLCsForwardable: {
2468                         int64_t time_forwardable_conv = obj->pending_htl_cs_forwardable.time_forwardable;
2469                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, time_forwardable_conv);
2470                 }
2471                 case LDKEvent_SpendableOutputs: {
2472                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
2473                         int64_tArray outputs_arr = NULL;
2474                         outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
2475                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
2476                         for (size_t b = 0; b < outputs_var.datalen; b++) {
2477                                 int64_t outputs_conv_27_ref = tag_ptr(&outputs_var.data[b], false);
2478                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
2479                         }
2480                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
2481                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
2482                 }
2483                 case LDKEvent_PaymentForwarded: {
2484                         int8_tArray prev_channel_id_arr = (*env)->NewByteArray(env, 32);
2485                         (*env)->SetByteArrayRegion(env, prev_channel_id_arr, 0, 32, obj->payment_forwarded.prev_channel_id.data);
2486                         int8_tArray next_channel_id_arr = (*env)->NewByteArray(env, 32);
2487                         (*env)->SetByteArrayRegion(env, next_channel_id_arr, 0, 32, obj->payment_forwarded.next_channel_id.data);
2488                         int64_t fee_earned_msat_ref = tag_ptr(&obj->payment_forwarded.fee_earned_msat, false);
2489                         jboolean claim_from_onchain_tx_conv = obj->payment_forwarded.claim_from_onchain_tx;
2490                         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);
2491                 }
2492                 case LDKEvent_ChannelClosed: {
2493                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2494                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_closed.channel_id.data);
2495                         int64_t user_channel_id_conv = obj->channel_closed.user_channel_id;
2496                         int64_t reason_ref = tag_ptr(&obj->channel_closed.reason, false);
2497                         return (*env)->NewObject(env, LDKEvent_ChannelClosed_class, LDKEvent_ChannelClosed_meth, channel_id_arr, user_channel_id_conv, reason_ref);
2498                 }
2499                 case LDKEvent_DiscardFunding: {
2500                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2501                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->discard_funding.channel_id.data);
2502                         LDKTransaction transaction_var = obj->discard_funding.transaction;
2503                         int8_tArray transaction_arr = (*env)->NewByteArray(env, transaction_var.datalen);
2504                         (*env)->SetByteArrayRegion(env, transaction_arr, 0, transaction_var.datalen, transaction_var.data);
2505                         return (*env)->NewObject(env, LDKEvent_DiscardFunding_class, LDKEvent_DiscardFunding_meth, channel_id_arr, transaction_arr);
2506                 }
2507                 case LDKEvent_OpenChannelRequest: {
2508                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
2509                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->open_channel_request.temporary_channel_id.data);
2510                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
2511                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->open_channel_request.counterparty_node_id.compressed_form);
2512                         int64_t funding_satoshis_conv = obj->open_channel_request.funding_satoshis;
2513                         int64_t push_msat_conv = obj->open_channel_request.push_msat;
2514                         LDKChannelTypeFeatures channel_type_var = obj->open_channel_request.channel_type;
2515                         int64_t channel_type_ref = 0;
2516                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
2517                         channel_type_ref = tag_ptr(channel_type_var.inner, false);
2518                         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);
2519                 }
2520                 case LDKEvent_HTLCHandlingFailed: {
2521                         int8_tArray prev_channel_id_arr = (*env)->NewByteArray(env, 32);
2522                         (*env)->SetByteArrayRegion(env, prev_channel_id_arr, 0, 32, obj->htlc_handling_failed.prev_channel_id.data);
2523                         int64_t failed_next_destination_ref = tag_ptr(&obj->htlc_handling_failed.failed_next_destination, false);
2524                         return (*env)->NewObject(env, LDKEvent_HTLCHandlingFailed_class, LDKEvent_HTLCHandlingFailed_meth, prev_channel_id_arr, failed_next_destination_ref);
2525                 }
2526                 default: abort();
2527         }
2528 }
2529 static jclass LDKCOption_EventZ_Some_class = NULL;
2530 static jmethodID LDKCOption_EventZ_Some_meth = NULL;
2531 static jclass LDKCOption_EventZ_None_class = NULL;
2532 static jmethodID LDKCOption_EventZ_None_meth = NULL;
2533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1EventZ_init (JNIEnv *env, jclass clz) {
2534         LDKCOption_EventZ_Some_class =
2535                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$Some"));
2536         CHECK(LDKCOption_EventZ_Some_class != NULL);
2537         LDKCOption_EventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_Some_class, "<init>", "(J)V");
2538         CHECK(LDKCOption_EventZ_Some_meth != NULL);
2539         LDKCOption_EventZ_None_class =
2540                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$None"));
2541         CHECK(LDKCOption_EventZ_None_class != NULL);
2542         LDKCOption_EventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_None_class, "<init>", "()V");
2543         CHECK(LDKCOption_EventZ_None_meth != NULL);
2544 }
2545 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1EventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2546         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)untag_ptr(ptr);
2547         switch(obj->tag) {
2548                 case LDKCOption_EventZ_Some: {
2549                         int64_t some_ref = tag_ptr(&obj->some, false);
2550                         return (*env)->NewObject(env, LDKCOption_EventZ_Some_class, LDKCOption_EventZ_Some_meth, some_ref);
2551                 }
2552                 case LDKCOption_EventZ_None: {
2553                         return (*env)->NewObject(env, LDKCOption_EventZ_None_class, LDKCOption_EventZ_None_meth);
2554                 }
2555                 default: abort();
2556         }
2557 }
2558 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2559 CHECK(owner->result_ok);
2560         return COption_EventZ_clone(&*owner->contents.result);
2561 }
2562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2563         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(owner);
2564         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
2565         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
2566         int64_t ret_ref = tag_ptr(ret_copy, true);
2567         return ret_ref;
2568 }
2569
2570 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2571 CHECK(!owner->result_ok);
2572         return DecodeError_clone(&*owner->contents.err);
2573 }
2574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2575         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(owner);
2576         LDKDecodeError ret_var = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
2577         int64_t ret_ref = 0;
2578         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2579         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2580         return ret_ref;
2581 }
2582
2583 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
2584 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
2585 static jclass LDKErrorAction_IgnoreError_class = NULL;
2586 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
2587 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
2588 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
2589 static jclass LDKErrorAction_IgnoreDuplicateGossip_class = NULL;
2590 static jmethodID LDKErrorAction_IgnoreDuplicateGossip_meth = NULL;
2591 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
2592 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
2593 static jclass LDKErrorAction_SendWarningMessage_class = NULL;
2594 static jmethodID LDKErrorAction_SendWarningMessage_meth = NULL;
2595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
2596         LDKErrorAction_DisconnectPeer_class =
2597                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$DisconnectPeer"));
2598         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
2599         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
2600         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
2601         LDKErrorAction_IgnoreError_class =
2602                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreError"));
2603         CHECK(LDKErrorAction_IgnoreError_class != NULL);
2604         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
2605         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
2606         LDKErrorAction_IgnoreAndLog_class =
2607                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog"));
2608         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
2609         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
2610         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
2611         LDKErrorAction_IgnoreDuplicateGossip_class =
2612                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreDuplicateGossip"));
2613         CHECK(LDKErrorAction_IgnoreDuplicateGossip_class != NULL);
2614         LDKErrorAction_IgnoreDuplicateGossip_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreDuplicateGossip_class, "<init>", "()V");
2615         CHECK(LDKErrorAction_IgnoreDuplicateGossip_meth != NULL);
2616         LDKErrorAction_SendErrorMessage_class =
2617                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendErrorMessage"));
2618         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
2619         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
2620         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
2621         LDKErrorAction_SendWarningMessage_class =
2622                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendWarningMessage"));
2623         CHECK(LDKErrorAction_SendWarningMessage_class != NULL);
2624         LDKErrorAction_SendWarningMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendWarningMessage_class, "<init>", "(JLorg/ldk/enums/Level;)V");
2625         CHECK(LDKErrorAction_SendWarningMessage_meth != NULL);
2626 }
2627 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2628         LDKErrorAction *obj = (LDKErrorAction*)untag_ptr(ptr);
2629         switch(obj->tag) {
2630                 case LDKErrorAction_DisconnectPeer: {
2631                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
2632                         int64_t msg_ref = 0;
2633                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2634                         msg_ref = tag_ptr(msg_var.inner, false);
2635                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
2636                 }
2637                 case LDKErrorAction_IgnoreError: {
2638                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
2639                 }
2640                 case LDKErrorAction_IgnoreAndLog: {
2641                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
2642                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
2643                 }
2644                 case LDKErrorAction_IgnoreDuplicateGossip: {
2645                         return (*env)->NewObject(env, LDKErrorAction_IgnoreDuplicateGossip_class, LDKErrorAction_IgnoreDuplicateGossip_meth);
2646                 }
2647                 case LDKErrorAction_SendErrorMessage: {
2648                         LDKErrorMessage msg_var = obj->send_error_message.msg;
2649                         int64_t msg_ref = 0;
2650                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2651                         msg_ref = tag_ptr(msg_var.inner, false);
2652                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
2653                 }
2654                 case LDKErrorAction_SendWarningMessage: {
2655                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
2656                         int64_t msg_ref = 0;
2657                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2658                         msg_ref = tag_ptr(msg_var.inner, false);
2659                         jclass log_level_conv = LDKLevel_to_java(env, obj->send_warning_message.log_level);
2660                         return (*env)->NewObject(env, LDKErrorAction_SendWarningMessage_class, LDKErrorAction_SendWarningMessage_meth, msg_ref, log_level_conv);
2661                 }
2662                 default: abort();
2663         }
2664 }
2665 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
2666 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
2667 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
2668 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
2669 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
2670 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
2671 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
2672 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
2673 static jclass LDKMessageSendEvent_SendChannelReady_class = NULL;
2674 static jmethodID LDKMessageSendEvent_SendChannelReady_meth = NULL;
2675 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
2676 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
2677 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
2678 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
2679 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
2680 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
2681 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
2682 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
2683 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
2684 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
2685 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
2686 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
2687 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
2688 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
2689 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
2690 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
2691 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
2692 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
2693 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
2694 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
2695 static jclass LDKMessageSendEvent_HandleError_class = NULL;
2696 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
2697 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
2698 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
2699 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
2700 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
2701 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
2702 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
2703 static jclass LDKMessageSendEvent_SendGossipTimestampFilter_class = NULL;
2704 static jmethodID LDKMessageSendEvent_SendGossipTimestampFilter_meth = NULL;
2705 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
2706         LDKMessageSendEvent_SendAcceptChannel_class =
2707                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel"));
2708         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
2709         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
2710         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
2711         LDKMessageSendEvent_SendOpenChannel_class =
2712                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel"));
2713         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
2714         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
2715         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
2716         LDKMessageSendEvent_SendFundingCreated_class =
2717                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated"));
2718         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
2719         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
2720         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
2721         LDKMessageSendEvent_SendFundingSigned_class =
2722                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned"));
2723         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
2724         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
2725         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
2726         LDKMessageSendEvent_SendChannelReady_class =
2727                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReady"));
2728         CHECK(LDKMessageSendEvent_SendChannelReady_class != NULL);
2729         LDKMessageSendEvent_SendChannelReady_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReady_class, "<init>", "([BJ)V");
2730         CHECK(LDKMessageSendEvent_SendChannelReady_meth != NULL);
2731         LDKMessageSendEvent_SendAnnouncementSignatures_class =
2732                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures"));
2733         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
2734         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
2735         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
2736         LDKMessageSendEvent_UpdateHTLCs_class =
2737                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs"));
2738         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
2739         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
2740         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
2741         LDKMessageSendEvent_SendRevokeAndACK_class =
2742                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK"));
2743         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
2744         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
2745         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
2746         LDKMessageSendEvent_SendClosingSigned_class =
2747                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned"));
2748         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
2749         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
2750         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
2751         LDKMessageSendEvent_SendShutdown_class =
2752                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown"));
2753         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
2754         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
2755         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
2756         LDKMessageSendEvent_SendChannelReestablish_class =
2757                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish"));
2758         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
2759         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
2760         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
2761         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
2762                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement"));
2763         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
2764         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
2765         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
2766         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
2767                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement"));
2768         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
2769         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
2770         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
2771         LDKMessageSendEvent_BroadcastChannelUpdate_class =
2772                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate"));
2773         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
2774         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
2775         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
2776         LDKMessageSendEvent_SendChannelUpdate_class =
2777                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate"));
2778         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
2779         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
2780         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
2781         LDKMessageSendEvent_HandleError_class =
2782                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$HandleError"));
2783         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
2784         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
2785         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
2786         LDKMessageSendEvent_SendChannelRangeQuery_class =
2787                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery"));
2788         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
2789         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
2790         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
2791         LDKMessageSendEvent_SendShortIdsQuery_class =
2792                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery"));
2793         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
2794         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
2795         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
2796         LDKMessageSendEvent_SendReplyChannelRange_class =
2797                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange"));
2798         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
2799         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
2800         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
2801         LDKMessageSendEvent_SendGossipTimestampFilter_class =
2802                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendGossipTimestampFilter"));
2803         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_class != NULL);
2804         LDKMessageSendEvent_SendGossipTimestampFilter_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, "<init>", "([BJ)V");
2805         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_meth != NULL);
2806 }
2807 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2808         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2809         switch(obj->tag) {
2810                 case LDKMessageSendEvent_SendAcceptChannel: {
2811                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2812                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
2813                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2814                         int64_t msg_ref = 0;
2815                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2816                         msg_ref = tag_ptr(msg_var.inner, false);
2817                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
2818                 }
2819                 case LDKMessageSendEvent_SendOpenChannel: {
2820                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2821                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
2822                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
2823                         int64_t msg_ref = 0;
2824                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2825                         msg_ref = tag_ptr(msg_var.inner, false);
2826                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
2827                 }
2828                 case LDKMessageSendEvent_SendFundingCreated: {
2829                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2830                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
2831                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
2832                         int64_t msg_ref = 0;
2833                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2834                         msg_ref = tag_ptr(msg_var.inner, false);
2835                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
2836                 }
2837                 case LDKMessageSendEvent_SendFundingSigned: {
2838                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2839                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
2840                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
2841                         int64_t msg_ref = 0;
2842                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2843                         msg_ref = tag_ptr(msg_var.inner, false);
2844                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
2845                 }
2846                 case LDKMessageSendEvent_SendChannelReady: {
2847                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2848                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_ready.node_id.compressed_form);
2849                         LDKChannelReady msg_var = obj->send_channel_ready.msg;
2850                         int64_t msg_ref = 0;
2851                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2852                         msg_ref = tag_ptr(msg_var.inner, false);
2853                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReady_class, LDKMessageSendEvent_SendChannelReady_meth, node_id_arr, msg_ref);
2854                 }
2855                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
2856                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2857                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
2858                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
2859                         int64_t msg_ref = 0;
2860                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2861                         msg_ref = tag_ptr(msg_var.inner, false);
2862                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
2863                 }
2864                 case LDKMessageSendEvent_UpdateHTLCs: {
2865                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2866                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
2867                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
2868                         int64_t updates_ref = 0;
2869                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
2870                         updates_ref = tag_ptr(updates_var.inner, false);
2871                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
2872                 }
2873                 case LDKMessageSendEvent_SendRevokeAndACK: {
2874                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2875                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
2876                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
2877                         int64_t msg_ref = 0;
2878                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2879                         msg_ref = tag_ptr(msg_var.inner, false);
2880                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
2881                 }
2882                 case LDKMessageSendEvent_SendClosingSigned: {
2883                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2884                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
2885                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
2886                         int64_t msg_ref = 0;
2887                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2888                         msg_ref = tag_ptr(msg_var.inner, false);
2889                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
2890                 }
2891                 case LDKMessageSendEvent_SendShutdown: {
2892                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2893                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
2894                         LDKShutdown msg_var = obj->send_shutdown.msg;
2895                         int64_t msg_ref = 0;
2896                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2897                         msg_ref = tag_ptr(msg_var.inner, false);
2898                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
2899                 }
2900                 case LDKMessageSendEvent_SendChannelReestablish: {
2901                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2902                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
2903                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
2904                         int64_t msg_ref = 0;
2905                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2906                         msg_ref = tag_ptr(msg_var.inner, false);
2907                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
2908                 }
2909                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
2910                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
2911                         int64_t msg_ref = 0;
2912                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2913                         msg_ref = tag_ptr(msg_var.inner, false);
2914                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
2915                         int64_t update_msg_ref = 0;
2916                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
2917                         update_msg_ref = tag_ptr(update_msg_var.inner, false);
2918                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
2919                 }
2920                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
2921                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
2922                         int64_t msg_ref = 0;
2923                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2924                         msg_ref = tag_ptr(msg_var.inner, false);
2925                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
2926                 }
2927                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
2928                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
2929                         int64_t msg_ref = 0;
2930                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2931                         msg_ref = tag_ptr(msg_var.inner, false);
2932                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
2933                 }
2934                 case LDKMessageSendEvent_SendChannelUpdate: {
2935                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2936                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
2937                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
2938                         int64_t msg_ref = 0;
2939                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2940                         msg_ref = tag_ptr(msg_var.inner, false);
2941                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
2942                 }
2943                 case LDKMessageSendEvent_HandleError: {
2944                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2945                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
2946                         int64_t action_ref = tag_ptr(&obj->handle_error.action, false);
2947                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
2948                 }
2949                 case LDKMessageSendEvent_SendChannelRangeQuery: {
2950                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2951                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
2952                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
2953                         int64_t msg_ref = 0;
2954                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2955                         msg_ref = tag_ptr(msg_var.inner, false);
2956                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
2957                 }
2958                 case LDKMessageSendEvent_SendShortIdsQuery: {
2959                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2960                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
2961                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
2962                         int64_t msg_ref = 0;
2963                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2964                         msg_ref = tag_ptr(msg_var.inner, false);
2965                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
2966                 }
2967                 case LDKMessageSendEvent_SendReplyChannelRange: {
2968                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2969                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
2970                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
2971                         int64_t msg_ref = 0;
2972                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2973                         msg_ref = tag_ptr(msg_var.inner, false);
2974                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
2975                 }
2976                 case LDKMessageSendEvent_SendGossipTimestampFilter: {
2977                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2978                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_gossip_timestamp_filter.node_id.compressed_form);
2979                         LDKGossipTimestampFilter msg_var = obj->send_gossip_timestamp_filter.msg;
2980                         int64_t msg_ref = 0;
2981                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2982                         msg_ref = tag_ptr(msg_var.inner, false);
2983                         return (*env)->NewObject(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, LDKMessageSendEvent_SendGossipTimestampFilter_meth, node_id_arr, msg_ref);
2984                 }
2985                 default: abort();
2986         }
2987 }
2988 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
2989         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
2990         for (size_t i = 0; i < ret.datalen; i++) {
2991                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
2992         }
2993         return ret;
2994 }
2995 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
2996 CHECK(owner->result_ok);
2997         return TxOut_clone(&*owner->contents.result);
2998 }
2999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3000         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(owner);
3001         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
3002         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
3003         return tag_ptr(ret_ref, true);
3004 }
3005
3006 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
3007 CHECK(!owner->result_ok);
3008         return AccessError_clone(&*owner->contents.err);
3009 }
3010 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3011         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(owner);
3012         jclass ret_conv = LDKAccessError_to_java(env, CResult_TxOutAccessErrorZ_get_err(owner_conv));
3013         return ret_conv;
3014 }
3015
3016 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
3017         return owner->a;
3018 }
3019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3020         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(owner);
3021         int64_t ret_conv = C2Tuple_usizeTransactionZ_get_a(owner_conv);
3022         return ret_conv;
3023 }
3024
3025 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
3026         return owner->b;
3027 }
3028 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3029         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(owner);
3030         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
3031         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
3032         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
3033         return ret_arr;
3034 }
3035
3036 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
3037         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
3038         for (size_t i = 0; i < ret.datalen; i++) {
3039                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
3040         }
3041         return ret;
3042 }
3043 static inline LDKCVec_TxidZ CVec_TxidZ_clone(const LDKCVec_TxidZ *orig) {
3044         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
3045         for (size_t i = 0; i < ret.datalen; i++) {
3046                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
3047         }
3048         return ret;
3049 }
3050 static inline void CResult_NoneChannelMonitorUpdateErrZ_get_ok(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
3051 CHECK(owner->result_ok);
3052         return *owner->contents.result;
3053 }
3054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3055         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)untag_ptr(owner);
3056         CResult_NoneChannelMonitorUpdateErrZ_get_ok(owner_conv);
3057 }
3058
3059 static inline enum LDKChannelMonitorUpdateErr CResult_NoneChannelMonitorUpdateErrZ_get_err(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
3060 CHECK(!owner->result_ok);
3061         return ChannelMonitorUpdateErr_clone(&*owner->contents.err);
3062 }
3063 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3064         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)untag_ptr(owner);
3065         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, CResult_NoneChannelMonitorUpdateErrZ_get_err(owner_conv));
3066         return ret_conv;
3067 }
3068
3069 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
3070 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
3071 static jclass LDKMonitorEvent_CommitmentTxConfirmed_class = NULL;
3072 static jmethodID LDKMonitorEvent_CommitmentTxConfirmed_meth = NULL;
3073 static jclass LDKMonitorEvent_UpdateCompleted_class = NULL;
3074 static jmethodID LDKMonitorEvent_UpdateCompleted_meth = NULL;
3075 static jclass LDKMonitorEvent_UpdateFailed_class = NULL;
3076 static jmethodID LDKMonitorEvent_UpdateFailed_meth = NULL;
3077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
3078         LDKMonitorEvent_HTLCEvent_class =
3079                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent"));
3080         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
3081         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
3082         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
3083         LDKMonitorEvent_CommitmentTxConfirmed_class =
3084                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxConfirmed"));
3085         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_class != NULL);
3086         LDKMonitorEvent_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxConfirmed_class, "<init>", "(J)V");
3087         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_meth != NULL);
3088         LDKMonitorEvent_UpdateCompleted_class =
3089                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateCompleted"));
3090         CHECK(LDKMonitorEvent_UpdateCompleted_class != NULL);
3091         LDKMonitorEvent_UpdateCompleted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateCompleted_class, "<init>", "(JJ)V");
3092         CHECK(LDKMonitorEvent_UpdateCompleted_meth != NULL);
3093         LDKMonitorEvent_UpdateFailed_class =
3094                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateFailed"));
3095         CHECK(LDKMonitorEvent_UpdateFailed_class != NULL);
3096         LDKMonitorEvent_UpdateFailed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateFailed_class, "<init>", "(J)V");
3097         CHECK(LDKMonitorEvent_UpdateFailed_meth != NULL);
3098 }
3099 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3100         LDKMonitorEvent *obj = (LDKMonitorEvent*)untag_ptr(ptr);
3101         switch(obj->tag) {
3102                 case LDKMonitorEvent_HTLCEvent: {
3103                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
3104                         int64_t htlc_event_ref = 0;
3105                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
3106                         htlc_event_ref = tag_ptr(htlc_event_var.inner, false);
3107                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
3108                 }
3109                 case LDKMonitorEvent_CommitmentTxConfirmed: {
3110                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
3111                         int64_t commitment_tx_confirmed_ref = 0;
3112                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
3113                         commitment_tx_confirmed_ref = tag_ptr(commitment_tx_confirmed_var.inner, false);
3114                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxConfirmed_class, LDKMonitorEvent_CommitmentTxConfirmed_meth, commitment_tx_confirmed_ref);
3115                 }
3116                 case LDKMonitorEvent_UpdateCompleted: {
3117                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
3118                         int64_t funding_txo_ref = 0;
3119                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
3120                         funding_txo_ref = tag_ptr(funding_txo_var.inner, false);
3121                         int64_t monitor_update_id_conv = obj->update_completed.monitor_update_id;
3122                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateCompleted_class, LDKMonitorEvent_UpdateCompleted_meth, funding_txo_ref, monitor_update_id_conv);
3123                 }
3124                 case LDKMonitorEvent_UpdateFailed: {
3125                         LDKOutPoint update_failed_var = obj->update_failed;
3126                         int64_t update_failed_ref = 0;
3127                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
3128                         update_failed_ref = tag_ptr(update_failed_var.inner, false);
3129                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateFailed_class, LDKMonitorEvent_UpdateFailed_meth, update_failed_ref);
3130                 }
3131                 default: abort();
3132         }
3133 }
3134 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
3135         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
3136         for (size_t i = 0; i < ret.datalen; i++) {
3137                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
3138         }
3139         return ret;
3140 }
3141 static inline struct LDKOutPoint C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
3142         return OutPoint_clone(&owner->a);
3143 }
3144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3145         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
3146         LDKOutPoint ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(owner_conv);
3147         int64_t ret_ref = 0;
3148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3149         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3150         return ret_ref;
3151 }
3152
3153 static inline struct LDKCVec_MonitorEventZ C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
3154         return CVec_MonitorEventZ_clone(&owner->b);
3155 }
3156 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3157         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
3158         LDKCVec_MonitorEventZ ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(owner_conv);
3159         int64_tArray ret_arr = NULL;
3160         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
3161         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
3162         for (size_t o = 0; o < ret_var.datalen; o++) {
3163                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3164                 *ret_conv_14_copy = ret_var.data[o];
3165                 int64_t ret_conv_14_ref = tag_ptr(ret_conv_14_copy, true);
3166                 ret_arr_ptr[o] = ret_conv_14_ref;
3167         }
3168         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
3169         FREE(ret_var.data);
3170         return ret_arr;
3171 }
3172
3173 static inline struct LDKPublicKey C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
3174         return owner->c;
3175 }
3176 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
3177         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
3178         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
3179         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(owner_conv).compressed_form);
3180         return ret_arr;
3181 }
3182
3183 static inline LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_clone(const LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ *orig) {
3184         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) * orig->datalen, "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ clone bytes"), .datalen = orig->datalen };
3185         for (size_t i = 0; i < ret.datalen; i++) {
3186                 ret.data[i] = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(&orig->data[i]);
3187         }
3188         return ret;
3189 }
3190 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
3191 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
3192 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
3193 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
3194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
3195         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
3196                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some"));
3197         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
3198         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
3199         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
3200         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
3201                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None"));
3202         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
3203         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
3204         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
3205 }
3206 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3207         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)untag_ptr(ptr);
3208         switch(obj->tag) {
3209                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
3210                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
3211                         *some_conv = obj->some;
3212                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
3213                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, tag_ptr(some_conv, true));
3214                 }
3215                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
3216                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
3217                 }
3218                 default: abort();
3219         }
3220 }
3221 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3222 CHECK(owner->result_ok);
3223         return FixedPenaltyScorer_clone(&*owner->contents.result);
3224 }
3225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3226         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(owner);
3227         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
3228         int64_t ret_ref = 0;
3229         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3230         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3231         return ret_ref;
3232 }
3233
3234 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3235 CHECK(!owner->result_ok);
3236         return DecodeError_clone(&*owner->contents.err);
3237 }
3238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3239         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(owner);
3240         LDKDecodeError ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
3241         int64_t ret_ref = 0;
3242         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3243         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3244         return ret_ref;
3245 }
3246
3247 static inline uint64_t C2Tuple_u64u64Z_get_a(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
3248         return owner->a;
3249 }
3250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3251         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(owner);
3252         int64_t ret_conv = C2Tuple_u64u64Z_get_a(owner_conv);
3253         return ret_conv;
3254 }
3255
3256 static inline uint64_t C2Tuple_u64u64Z_get_b(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
3257         return owner->b;
3258 }
3259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3260         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(owner);
3261         int64_t ret_conv = C2Tuple_u64u64Z_get_b(owner_conv);
3262         return ret_conv;
3263 }
3264
3265 static jclass LDKCOption_C2Tuple_u64u64ZZ_Some_class = NULL;
3266 static jmethodID LDKCOption_C2Tuple_u64u64ZZ_Some_meth = NULL;
3267 static jclass LDKCOption_C2Tuple_u64u64ZZ_None_class = NULL;
3268 static jmethodID LDKCOption_C2Tuple_u64u64ZZ_None_meth = NULL;
3269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1u64u64ZZ_init (JNIEnv *env, jclass clz) {
3270         LDKCOption_C2Tuple_u64u64ZZ_Some_class =
3271                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_u64u64ZZ$Some"));
3272         CHECK(LDKCOption_C2Tuple_u64u64ZZ_Some_class != NULL);
3273         LDKCOption_C2Tuple_u64u64ZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_u64u64ZZ_Some_class, "<init>", "(J)V");
3274         CHECK(LDKCOption_C2Tuple_u64u64ZZ_Some_meth != NULL);
3275         LDKCOption_C2Tuple_u64u64ZZ_None_class =
3276                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_u64u64ZZ$None"));
3277         CHECK(LDKCOption_C2Tuple_u64u64ZZ_None_class != NULL);
3278         LDKCOption_C2Tuple_u64u64ZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_u64u64ZZ_None_class, "<init>", "()V");
3279         CHECK(LDKCOption_C2Tuple_u64u64ZZ_None_meth != NULL);
3280 }
3281 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1u64u64ZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3282         LDKCOption_C2Tuple_u64u64ZZ *obj = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(ptr);
3283         switch(obj->tag) {
3284                 case LDKCOption_C2Tuple_u64u64ZZ_Some: {
3285                         LDKC2Tuple_u64u64Z* some_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
3286                         *some_conv = obj->some;
3287                         *some_conv = C2Tuple_u64u64Z_clone(some_conv);
3288                         return (*env)->NewObject(env, LDKCOption_C2Tuple_u64u64ZZ_Some_class, LDKCOption_C2Tuple_u64u64ZZ_Some_meth, tag_ptr(some_conv, true));
3289                 }
3290                 case LDKCOption_C2Tuple_u64u64ZZ_None: {
3291                         return (*env)->NewObject(env, LDKCOption_C2Tuple_u64u64ZZ_None_class, LDKCOption_C2Tuple_u64u64ZZ_None_meth);
3292                 }
3293                 default: abort();
3294         }
3295 }
3296 static inline LDKCVec_NodeIdZ CVec_NodeIdZ_clone(const LDKCVec_NodeIdZ *orig) {
3297         LDKCVec_NodeIdZ ret = { .data = MALLOC(sizeof(LDKNodeId) * orig->datalen, "LDKCVec_NodeIdZ clone bytes"), .datalen = orig->datalen };
3298         for (size_t i = 0; i < ret.datalen; i++) {
3299                 ret.data[i] = NodeId_clone(&orig->data[i]);
3300         }
3301         return ret;
3302 }
3303 typedef struct LDKLogger_JCalls {
3304         atomic_size_t refcnt;
3305         JavaVM *vm;
3306         jweak o;
3307         jmethodID log_meth;
3308 } LDKLogger_JCalls;
3309 static void LDKLogger_JCalls_free(void* this_arg) {
3310         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3311         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3312                 JNIEnv *env;
3313                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3314                 if (get_jenv_res == JNI_EDETACHED) {
3315                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3316                 } else {
3317                         DO_ASSERT(get_jenv_res == JNI_OK);
3318                 }
3319                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3320                 if (get_jenv_res == JNI_EDETACHED) {
3321                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3322                 }
3323                 FREE(j_calls);
3324         }
3325 }
3326 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
3327         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3328         JNIEnv *env;
3329         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3330         if (get_jenv_res == JNI_EDETACHED) {
3331                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3332         } else {
3333                 DO_ASSERT(get_jenv_res == JNI_OK);
3334         }
3335         LDKRecord record_var = *record;
3336         int64_t record_ref = 0;
3337         record_var = Record_clone(&record_var);
3338         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
3339         record_ref = tag_ptr(record_var.inner, record_var.is_owned);
3340         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3341         CHECK(obj != NULL);
3342         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_ref);
3343         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3344                 (*env)->ExceptionDescribe(env);
3345                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
3346         }
3347         if (get_jenv_res == JNI_EDETACHED) {
3348                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3349         }
3350 }
3351 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
3352         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
3353         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3354 }
3355 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
3356         jclass c = (*env)->GetObjectClass(env, o);
3357         CHECK(c != NULL);
3358         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
3359         atomic_init(&calls->refcnt, 1);
3360         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3361         calls->o = (*env)->NewWeakGlobalRef(env, o);
3362         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(J)V");
3363         CHECK(calls->log_meth != NULL);
3364
3365         LDKLogger ret = {
3366                 .this_arg = (void*) calls,
3367                 .log = log_LDKLogger_jcall,
3368                 .free = LDKLogger_JCalls_free,
3369         };
3370         return ret;
3371 }
3372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
3373         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
3374         *res_ptr = LDKLogger_init(env, clz, o);
3375         return tag_ptr(res_ptr, true);
3376 }
3377 static inline struct LDKProbabilisticScorer *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
3378 CHECK(owner->result_ok);
3379         return &*owner->contents.result;
3380 }
3381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3382         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(owner);
3383         LDKProbabilisticScorer ret_var = *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
3384         int64_t ret_ref = 0;
3385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3386         ret_ref = tag_ptr(ret_var.inner, false);
3387         return ret_ref;
3388 }
3389
3390 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
3391 CHECK(!owner->result_ok);
3392         return DecodeError_clone(&*owner->contents.err);
3393 }
3394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3395         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(owner);
3396         LDKDecodeError ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
3397         int64_t ret_ref = 0;
3398         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3399         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3400         return ret_ref;
3401 }
3402
3403 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3404 CHECK(owner->result_ok);
3405         return InitFeatures_clone(&*owner->contents.result);
3406 }
3407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3408         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(owner);
3409         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
3410         int64_t ret_ref = 0;
3411         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3412         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3413         return ret_ref;
3414 }
3415
3416 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3417 CHECK(!owner->result_ok);
3418         return DecodeError_clone(&*owner->contents.err);
3419 }
3420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3421         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(owner);
3422         LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
3423         int64_t ret_ref = 0;
3424         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3425         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3426         return ret_ref;
3427 }
3428
3429 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3430 CHECK(owner->result_ok);
3431         return ChannelFeatures_clone(&*owner->contents.result);
3432 }
3433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3434         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(owner);
3435         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
3436         int64_t ret_ref = 0;
3437         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3438         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3439         return ret_ref;
3440 }
3441
3442 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3443 CHECK(!owner->result_ok);
3444         return DecodeError_clone(&*owner->contents.err);
3445 }
3446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3447         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(owner);
3448         LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
3449         int64_t ret_ref = 0;
3450         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3451         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3452         return ret_ref;
3453 }
3454
3455 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3456 CHECK(owner->result_ok);
3457         return NodeFeatures_clone(&*owner->contents.result);
3458 }
3459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3460         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(owner);
3461         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
3462         int64_t ret_ref = 0;
3463         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3464         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3465         return ret_ref;
3466 }
3467
3468 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3469 CHECK(!owner->result_ok);
3470         return DecodeError_clone(&*owner->contents.err);
3471 }
3472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3473         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(owner);
3474         LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
3475         int64_t ret_ref = 0;
3476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3477         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3478         return ret_ref;
3479 }
3480
3481 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3482 CHECK(owner->result_ok);
3483         return InvoiceFeatures_clone(&*owner->contents.result);
3484 }
3485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3486         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(owner);
3487         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
3488         int64_t ret_ref = 0;
3489         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3490         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3491         return ret_ref;
3492 }
3493
3494 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3495 CHECK(!owner->result_ok);
3496         return DecodeError_clone(&*owner->contents.err);
3497 }
3498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3499         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(owner);
3500         LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
3501         int64_t ret_ref = 0;
3502         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3503         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3504         return ret_ref;
3505 }
3506
3507 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3508 CHECK(owner->result_ok);
3509         return ChannelTypeFeatures_clone(&*owner->contents.result);
3510 }
3511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3512         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(owner);
3513         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
3514         int64_t ret_ref = 0;
3515         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3516         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3517         return ret_ref;
3518 }
3519
3520 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3521 CHECK(!owner->result_ok);
3522         return DecodeError_clone(&*owner->contents.err);
3523 }
3524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3525         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(owner);
3526         LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
3527         int64_t ret_ref = 0;
3528         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3529         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3530         return ret_ref;
3531 }
3532
3533 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
3534 CHECK(owner->result_ok);
3535         return NodeId_clone(&*owner->contents.result);
3536 }
3537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3538         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(owner);
3539         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
3540         int64_t ret_ref = 0;
3541         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3542         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3543         return ret_ref;
3544 }
3545
3546 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
3547 CHECK(!owner->result_ok);
3548         return DecodeError_clone(&*owner->contents.err);
3549 }
3550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3551         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(owner);
3552         LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
3553         int64_t ret_ref = 0;
3554         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3555         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3556         return ret_ref;
3557 }
3558
3559 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
3560 CHECK(owner->result_ok);
3561         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
3562 }
3563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3564         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(owner);
3565         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
3566         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
3567         int64_t ret_ref = tag_ptr(ret_copy, true);
3568         return ret_ref;
3569 }
3570
3571 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
3572 CHECK(!owner->result_ok);
3573         return DecodeError_clone(&*owner->contents.err);
3574 }
3575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3576         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(owner);
3577         LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
3578         int64_t ret_ref = 0;
3579         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3580         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3581         return ret_ref;
3582 }
3583
3584 typedef struct LDKAccess_JCalls {
3585         atomic_size_t refcnt;
3586         JavaVM *vm;
3587         jweak o;
3588         jmethodID get_utxo_meth;
3589 } LDKAccess_JCalls;
3590 static void LDKAccess_JCalls_free(void* this_arg) {
3591         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3592         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3593                 JNIEnv *env;
3594                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3595                 if (get_jenv_res == JNI_EDETACHED) {
3596                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3597                 } else {
3598                         DO_ASSERT(get_jenv_res == JNI_OK);
3599                 }
3600                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3601                 if (get_jenv_res == JNI_EDETACHED) {
3602                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3603                 }
3604                 FREE(j_calls);
3605         }
3606 }
3607 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
3608         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3609         JNIEnv *env;
3610         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3611         if (get_jenv_res == JNI_EDETACHED) {
3612                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3613         } else {
3614                 DO_ASSERT(get_jenv_res == JNI_OK);
3615         }
3616         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
3617         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
3618         int64_t short_channel_id_conv = short_channel_id;
3619         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3620         CHECK(obj != NULL);
3621         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id_conv);
3622         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3623                 (*env)->ExceptionDescribe(env);
3624                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
3625         }
3626         void* ret_ptr = untag_ptr(ret);
3627         CHECK_ACCESS(ret_ptr);
3628         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
3629         FREE(untag_ptr(ret));
3630         if (get_jenv_res == JNI_EDETACHED) {
3631                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3632         }
3633         return ret_conv;
3634 }
3635 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
3636         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
3637         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3638 }
3639 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
3640         jclass c = (*env)->GetObjectClass(env, o);
3641         CHECK(c != NULL);
3642         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
3643         atomic_init(&calls->refcnt, 1);
3644         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3645         calls->o = (*env)->NewWeakGlobalRef(env, o);
3646         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
3647         CHECK(calls->get_utxo_meth != NULL);
3648
3649         LDKAccess ret = {
3650                 .this_arg = (void*) calls,
3651                 .get_utxo = get_utxo_LDKAccess_jcall,
3652                 .free = LDKAccess_JCalls_free,
3653         };
3654         return ret;
3655 }
3656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
3657         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
3658         *res_ptr = LDKAccess_init(env, clz, o);
3659         return tag_ptr(res_ptr, true);
3660 }
3661 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) {
3662         void* this_arg_ptr = untag_ptr(this_arg);
3663         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
3664         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
3665         unsigned char genesis_hash_arr[32];
3666         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
3667         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
3668         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
3669         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
3670         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
3671         return tag_ptr(ret_conv, true);
3672 }
3673
3674 static jclass LDKCOption_AccessZ_Some_class = NULL;
3675 static jmethodID LDKCOption_AccessZ_Some_meth = NULL;
3676 static jclass LDKCOption_AccessZ_None_class = NULL;
3677 static jmethodID LDKCOption_AccessZ_None_meth = NULL;
3678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1AccessZ_init (JNIEnv *env, jclass clz) {
3679         LDKCOption_AccessZ_Some_class =
3680                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$Some"));
3681         CHECK(LDKCOption_AccessZ_Some_class != NULL);
3682         LDKCOption_AccessZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_Some_class, "<init>", "(J)V");
3683         CHECK(LDKCOption_AccessZ_Some_meth != NULL);
3684         LDKCOption_AccessZ_None_class =
3685                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$None"));
3686         CHECK(LDKCOption_AccessZ_None_class != NULL);
3687         LDKCOption_AccessZ_None_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_None_class, "<init>", "()V");
3688         CHECK(LDKCOption_AccessZ_None_meth != NULL);
3689 }
3690 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1AccessZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3691         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)untag_ptr(ptr);
3692         switch(obj->tag) {
3693                 case LDKCOption_AccessZ_Some: {
3694                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
3695                         *some_ret = obj->some;
3696                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
3697                         if ((*some_ret).free == LDKAccess_JCalls_free) {
3698                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
3699                                 LDKAccess_JCalls_cloned(&(*some_ret));
3700                         }
3701                         return (*env)->NewObject(env, LDKCOption_AccessZ_Some_class, LDKCOption_AccessZ_Some_meth, tag_ptr(some_ret, true));
3702                 }
3703                 case LDKCOption_AccessZ_None: {
3704                         return (*env)->NewObject(env, LDKCOption_AccessZ_None_class, LDKCOption_AccessZ_None_meth);
3705                 }
3706                 default: abort();
3707         }
3708 }
3709 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
3710 CHECK(owner->result_ok);
3711         return *owner->contents.result;
3712 }
3713 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3714         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(owner);
3715         jboolean ret_conv = CResult_boolLightningErrorZ_get_ok(owner_conv);
3716         return ret_conv;
3717 }
3718
3719 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
3720 CHECK(!owner->result_ok);
3721         return LightningError_clone(&*owner->contents.err);
3722 }
3723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3724         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(owner);
3725         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
3726         int64_t ret_ref = 0;
3727         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3728         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3729         return ret_ref;
3730 }
3731
3732 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3733         return ChannelAnnouncement_clone(&owner->a);
3734 }
3735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3736         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
3737         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
3738         int64_t ret_ref = 0;
3739         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3740         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3741         return ret_ref;
3742 }
3743
3744 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3745         return ChannelUpdate_clone(&owner->b);
3746 }
3747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3748         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
3749         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
3750         int64_t ret_ref = 0;
3751         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3752         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3753         return ret_ref;
3754 }
3755
3756 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3757         return ChannelUpdate_clone(&owner->c);
3758 }
3759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
3760         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
3761         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
3762         int64_t ret_ref = 0;
3763         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3764         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3765         return ret_ref;
3766 }
3767
3768 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
3769         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
3770         for (size_t i = 0; i < ret.datalen; i++) {
3771                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
3772         }
3773         return ret;
3774 }
3775 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
3776         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
3777         for (size_t i = 0; i < ret.datalen; i++) {
3778                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
3779         }
3780         return ret;
3781 }
3782 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
3783 CHECK(owner->result_ok);
3784         return *owner->contents.result;
3785 }
3786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3787         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(owner);
3788         CResult_NoneLightningErrorZ_get_ok(owner_conv);
3789 }
3790
3791 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
3792 CHECK(!owner->result_ok);
3793         return LightningError_clone(&*owner->contents.err);
3794 }
3795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3796         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(owner);
3797         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
3798         int64_t ret_ref = 0;
3799         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3800         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3801         return ret_ref;
3802 }
3803
3804 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
3805 CHECK(owner->result_ok);
3806         return ChannelUpdateInfo_clone(&*owner->contents.result);
3807 }
3808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3809         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(owner);
3810         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
3811         int64_t ret_ref = 0;
3812         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3813         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3814         return ret_ref;
3815 }
3816
3817 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
3818 CHECK(!owner->result_ok);
3819         return DecodeError_clone(&*owner->contents.err);
3820 }
3821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3822         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(owner);
3823         LDKDecodeError ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
3824         int64_t ret_ref = 0;
3825         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3826         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3827         return ret_ref;
3828 }
3829
3830 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
3831 CHECK(owner->result_ok);
3832         return ChannelInfo_clone(&*owner->contents.result);
3833 }
3834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3835         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(owner);
3836         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
3837         int64_t ret_ref = 0;
3838         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3839         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3840         return ret_ref;
3841 }
3842
3843 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
3844 CHECK(!owner->result_ok);
3845         return DecodeError_clone(&*owner->contents.err);
3846 }
3847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3848         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(owner);
3849         LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
3850         int64_t ret_ref = 0;
3851         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3852         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3853         return ret_ref;
3854 }
3855
3856 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
3857 CHECK(owner->result_ok);
3858         return RoutingFees_clone(&*owner->contents.result);
3859 }
3860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3861         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(owner);
3862         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
3863         int64_t ret_ref = 0;
3864         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3865         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3866         return ret_ref;
3867 }
3868
3869 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
3870 CHECK(!owner->result_ok);
3871         return DecodeError_clone(&*owner->contents.err);
3872 }
3873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3874         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(owner);
3875         LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
3876         int64_t ret_ref = 0;
3877         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3878         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3879         return ret_ref;
3880 }
3881
3882 static jclass LDKNetAddress_IPv4_class = NULL;
3883 static jmethodID LDKNetAddress_IPv4_meth = NULL;
3884 static jclass LDKNetAddress_IPv6_class = NULL;
3885 static jmethodID LDKNetAddress_IPv6_meth = NULL;
3886 static jclass LDKNetAddress_OnionV2_class = NULL;
3887 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
3888 static jclass LDKNetAddress_OnionV3_class = NULL;
3889 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
3890 static jclass LDKNetAddress_Hostname_class = NULL;
3891 static jmethodID LDKNetAddress_Hostname_meth = NULL;
3892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
3893         LDKNetAddress_IPv4_class =
3894                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv4"));
3895         CHECK(LDKNetAddress_IPv4_class != NULL);
3896         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
3897         CHECK(LDKNetAddress_IPv4_meth != NULL);
3898         LDKNetAddress_IPv6_class =
3899                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv6"));
3900         CHECK(LDKNetAddress_IPv6_class != NULL);
3901         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
3902         CHECK(LDKNetAddress_IPv6_meth != NULL);
3903         LDKNetAddress_OnionV2_class =
3904                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV2"));
3905         CHECK(LDKNetAddress_OnionV2_class != NULL);
3906         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([B)V");
3907         CHECK(LDKNetAddress_OnionV2_meth != NULL);
3908         LDKNetAddress_OnionV3_class =
3909                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV3"));
3910         CHECK(LDKNetAddress_OnionV3_class != NULL);
3911         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
3912         CHECK(LDKNetAddress_OnionV3_meth != NULL);
3913         LDKNetAddress_Hostname_class =
3914                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$Hostname"));
3915         CHECK(LDKNetAddress_Hostname_class != NULL);
3916         LDKNetAddress_Hostname_meth = (*env)->GetMethodID(env, LDKNetAddress_Hostname_class, "<init>", "(JS)V");
3917         CHECK(LDKNetAddress_Hostname_meth != NULL);
3918 }
3919 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3920         LDKNetAddress *obj = (LDKNetAddress*)untag_ptr(ptr);
3921         switch(obj->tag) {
3922                 case LDKNetAddress_IPv4: {
3923                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
3924                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
3925                         int16_t port_conv = obj->i_pv4.port;
3926                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, port_conv);
3927                 }
3928                 case LDKNetAddress_IPv6: {
3929                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
3930                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
3931                         int16_t port_conv = obj->i_pv6.port;
3932                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, port_conv);
3933                 }
3934                 case LDKNetAddress_OnionV2: {
3935                         int8_tArray onion_v2_arr = (*env)->NewByteArray(env, 12);
3936                         (*env)->SetByteArrayRegion(env, onion_v2_arr, 0, 12, obj->onion_v2.data);
3937                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, onion_v2_arr);
3938                 }
3939                 case LDKNetAddress_OnionV3: {
3940                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
3941                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
3942                         int16_t checksum_conv = obj->onion_v3.checksum;
3943                         int8_t version_conv = obj->onion_v3.version;
3944                         int16_t port_conv = obj->onion_v3.port;
3945                         return (*env)->NewObject(env, LDKNetAddress_OnionV3_class, LDKNetAddress_OnionV3_meth, ed25519_pubkey_arr, checksum_conv, version_conv, port_conv);
3946                 }
3947                 case LDKNetAddress_Hostname: {
3948                         LDKHostname hostname_var = obj->hostname.hostname;
3949                         int64_t hostname_ref = 0;
3950                         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_var);
3951                         hostname_ref = tag_ptr(hostname_var.inner, false);
3952                         int16_t port_conv = obj->hostname.port;
3953                         return (*env)->NewObject(env, LDKNetAddress_Hostname_class, LDKNetAddress_Hostname_meth, hostname_ref, port_conv);
3954                 }
3955                 default: abort();
3956         }
3957 }
3958 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
3959         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
3960         for (size_t i = 0; i < ret.datalen; i++) {
3961                 ret.data[i] = NetAddress_clone(&orig->data[i]);
3962         }
3963         return ret;
3964 }
3965 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
3966 CHECK(owner->result_ok);
3967         return NodeAnnouncementInfo_clone(&*owner->contents.result);
3968 }
3969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3970         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(owner);
3971         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(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 struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
3979 CHECK(!owner->result_ok);
3980         return DecodeError_clone(&*owner->contents.err);
3981 }
3982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3983         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(owner);
3984         LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
3985         int64_t ret_ref = 0;
3986         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3987         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3988         return ret_ref;
3989 }
3990
3991 static inline struct LDKNodeAlias CResult_NodeAliasDecodeErrorZ_get_ok(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
3992 CHECK(owner->result_ok);
3993         return NodeAlias_clone(&*owner->contents.result);
3994 }
3995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3996         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(owner);
3997         LDKNodeAlias ret_var = CResult_NodeAliasDecodeErrorZ_get_ok(owner_conv);
3998         int64_t ret_ref = 0;
3999         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4000         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4001         return ret_ref;
4002 }
4003
4004 static inline struct LDKDecodeError CResult_NodeAliasDecodeErrorZ_get_err(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
4005 CHECK(!owner->result_ok);
4006         return DecodeError_clone(&*owner->contents.err);
4007 }
4008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4009         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(owner);
4010         LDKDecodeError ret_var = CResult_NodeAliasDecodeErrorZ_get_err(owner_conv);
4011         int64_t ret_ref = 0;
4012         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4013         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4014         return ret_ref;
4015 }
4016
4017 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
4018 CHECK(owner->result_ok);
4019         return NodeInfo_clone(&*owner->contents.result);
4020 }
4021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4022         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(owner);
4023         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
4024         int64_t ret_ref = 0;
4025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4026         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4027         return ret_ref;
4028 }
4029
4030 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
4031 CHECK(!owner->result_ok);
4032         return DecodeError_clone(&*owner->contents.err);
4033 }
4034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4035         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(owner);
4036         LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
4037         int64_t ret_ref = 0;
4038         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4039         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4040         return ret_ref;
4041 }
4042
4043 static inline struct LDKNetworkGraph *CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
4044 CHECK(owner->result_ok);
4045         return &*owner->contents.result;
4046 }
4047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4048         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(owner);
4049         LDKNetworkGraph ret_var = *CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
4050         int64_t ret_ref = 0;
4051         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4052         ret_ref = tag_ptr(ret_var.inner, false);
4053         return ret_ref;
4054 }
4055
4056 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
4057 CHECK(!owner->result_ok);
4058         return DecodeError_clone(&*owner->contents.err);
4059 }
4060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4061         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(owner);
4062         LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
4063         int64_t ret_ref = 0;
4064         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4065         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4066         return ret_ref;
4067 }
4068
4069 static jclass LDKCOption_CVec_NetAddressZZ_Some_class = NULL;
4070 static jmethodID LDKCOption_CVec_NetAddressZZ_Some_meth = NULL;
4071 static jclass LDKCOption_CVec_NetAddressZZ_None_class = NULL;
4072 static jmethodID LDKCOption_CVec_NetAddressZZ_None_meth = NULL;
4073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CVec_1NetAddressZZ_init (JNIEnv *env, jclass clz) {
4074         LDKCOption_CVec_NetAddressZZ_Some_class =
4075                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$Some"));
4076         CHECK(LDKCOption_CVec_NetAddressZZ_Some_class != NULL);
4077         LDKCOption_CVec_NetAddressZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_Some_class, "<init>", "([J)V");
4078         CHECK(LDKCOption_CVec_NetAddressZZ_Some_meth != NULL);
4079         LDKCOption_CVec_NetAddressZZ_None_class =
4080                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$None"));
4081         CHECK(LDKCOption_CVec_NetAddressZZ_None_class != NULL);
4082         LDKCOption_CVec_NetAddressZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_None_class, "<init>", "()V");
4083         CHECK(LDKCOption_CVec_NetAddressZZ_None_meth != NULL);
4084 }
4085 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddressZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4086         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)untag_ptr(ptr);
4087         switch(obj->tag) {
4088                 case LDKCOption_CVec_NetAddressZZ_Some: {
4089                         LDKCVec_NetAddressZ some_var = obj->some;
4090                         int64_tArray some_arr = NULL;
4091                         some_arr = (*env)->NewLongArray(env, some_var.datalen);
4092                         int64_t *some_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, some_arr, NULL);
4093                         for (size_t m = 0; m < some_var.datalen; m++) {
4094                                 int64_t some_conv_12_ref = tag_ptr(&some_var.data[m], false);
4095                                 some_arr_ptr[m] = some_conv_12_ref;
4096                         }
4097                         (*env)->ReleasePrimitiveArrayCritical(env, some_arr, some_arr_ptr, 0);
4098                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_Some_class, LDKCOption_CVec_NetAddressZZ_Some_meth, some_arr);
4099                 }
4100                 case LDKCOption_CVec_NetAddressZZ_None: {
4101                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_None_class, LDKCOption_CVec_NetAddressZZ_None_meth);
4102                 }
4103                 default: abort();
4104         }
4105 }
4106 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4107 CHECK(owner->result_ok);
4108         return DelayedPaymentOutputDescriptor_clone(&*owner->contents.result);
4109 }
4110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4111         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
4112         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
4113         int64_t ret_ref = 0;
4114         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4115         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4116         return ret_ref;
4117 }
4118
4119 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4120 CHECK(!owner->result_ok);
4121         return DecodeError_clone(&*owner->contents.err);
4122 }
4123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4124         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
4125         LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
4126         int64_t ret_ref = 0;
4127         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4128         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4129         return ret_ref;
4130 }
4131
4132 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4133 CHECK(owner->result_ok);
4134         return StaticPaymentOutputDescriptor_clone(&*owner->contents.result);
4135 }
4136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4137         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
4138         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
4139         int64_t ret_ref = 0;
4140         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4141         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4142         return ret_ref;
4143 }
4144
4145 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4146 CHECK(!owner->result_ok);
4147         return DecodeError_clone(&*owner->contents.err);
4148 }
4149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4150         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
4151         LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
4152         int64_t ret_ref = 0;
4153         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4154         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4155         return ret_ref;
4156 }
4157
4158 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4159 CHECK(owner->result_ok);
4160         return SpendableOutputDescriptor_clone(&*owner->contents.result);
4161 }
4162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4163         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
4164         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
4165         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
4166         int64_t ret_ref = tag_ptr(ret_copy, true);
4167         return ret_ref;
4168 }
4169
4170 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4171 CHECK(!owner->result_ok);
4172         return DecodeError_clone(&*owner->contents.err);
4173 }
4174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4175         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
4176         LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
4177         int64_t ret_ref = 0;
4178         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4179         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4180         return ret_ref;
4181 }
4182
4183 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
4184         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
4185         for (size_t i = 0; i < ret.datalen; i++) {
4186                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
4187         }
4188         return ret;
4189 }
4190 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
4191         return owner->a;
4192 }
4193 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4194         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(owner);
4195         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
4196         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form);
4197         return ret_arr;
4198 }
4199
4200 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
4201         return owner->b;
4202 }
4203 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4204         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(owner);
4205         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
4206         jobjectArray ret_arr = NULL;
4207         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
4208         ;
4209         for (size_t i = 0; i < ret_var.datalen; i++) {
4210                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
4211                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
4212                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
4213         }
4214         
4215         return ret_arr;
4216 }
4217
4218 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
4219 CHECK(owner->result_ok);
4220         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
4221 }
4222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4223         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(owner);
4224         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
4225         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
4226         return tag_ptr(ret_conv, true);
4227 }
4228
4229 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
4230 CHECK(!owner->result_ok);
4231         return *owner->contents.err;
4232 }
4233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4234         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(owner);
4235         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
4236 }
4237
4238 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
4239 CHECK(owner->result_ok);
4240         return *owner->contents.result;
4241 }
4242 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4243         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(owner);
4244         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
4245         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form);
4246         return ret_arr;
4247 }
4248
4249 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
4250 CHECK(!owner->result_ok);
4251         return *owner->contents.err;
4252 }
4253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4254         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(owner);
4255         CResult_SignatureNoneZ_get_err(owner_conv);
4256 }
4257
4258 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
4259         return owner->a;
4260 }
4261 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4262         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)untag_ptr(owner);
4263         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
4264         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form);
4265         return ret_arr;
4266 }
4267
4268 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
4269         return owner->b;
4270 }
4271 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4272         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)untag_ptr(owner);
4273         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
4274         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form);
4275         return ret_arr;
4276 }
4277
4278 static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
4279 CHECK(owner->result_ok);
4280         return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
4281 }
4282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4283         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(owner);
4284         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
4285         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
4286         return tag_ptr(ret_conv, true);
4287 }
4288
4289 static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
4290 CHECK(!owner->result_ok);
4291         return *owner->contents.err;
4292 }
4293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4294         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(owner);
4295         CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
4296 }
4297
4298 static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
4299 CHECK(owner->result_ok);
4300         return *owner->contents.result;
4301 }
4302 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4303         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(owner);
4304         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4305         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes);
4306         return ret_arr;
4307 }
4308
4309 static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
4310 CHECK(!owner->result_ok);
4311         return *owner->contents.err;
4312 }
4313 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4314         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(owner);
4315         CResult_SecretKeyNoneZ_get_err(owner_conv);
4316 }
4317
4318 typedef struct LDKBaseSign_JCalls {
4319         atomic_size_t refcnt;
4320         JavaVM *vm;
4321         jweak o;
4322         jmethodID get_per_commitment_point_meth;
4323         jmethodID release_commitment_secret_meth;
4324         jmethodID validate_holder_commitment_meth;
4325         jmethodID channel_keys_id_meth;
4326         jmethodID sign_counterparty_commitment_meth;
4327         jmethodID validate_counterparty_revocation_meth;
4328         jmethodID sign_holder_commitment_and_htlcs_meth;
4329         jmethodID sign_justice_revoked_output_meth;
4330         jmethodID sign_justice_revoked_htlc_meth;
4331         jmethodID sign_counterparty_htlc_transaction_meth;
4332         jmethodID sign_closing_transaction_meth;
4333         jmethodID sign_channel_announcement_meth;
4334         jmethodID ready_channel_meth;
4335 } LDKBaseSign_JCalls;
4336 static void LDKBaseSign_JCalls_free(void* this_arg) {
4337         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_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 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
4354         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_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         int64_t idx_conv = idx;
4363         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4364         CHECK(obj != NULL);
4365         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx_conv);
4366         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4367                 (*env)->ExceptionDescribe(env);
4368                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
4369         }
4370         LDKPublicKey ret_ref;
4371         CHECK((*env)->GetArrayLength(env, ret) == 33);
4372         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
4373         if (get_jenv_res == JNI_EDETACHED) {
4374                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4375         }
4376         return ret_ref;
4377 }
4378 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
4379         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4380         JNIEnv *env;
4381         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4382         if (get_jenv_res == JNI_EDETACHED) {
4383                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4384         } else {
4385                 DO_ASSERT(get_jenv_res == JNI_OK);
4386         }
4387         int64_t idx_conv = idx;
4388         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4389         CHECK(obj != NULL);
4390         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx_conv);
4391         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4392                 (*env)->ExceptionDescribe(env);
4393                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
4394         }
4395         LDKThirtyTwoBytes ret_ref;
4396         CHECK((*env)->GetArrayLength(env, ret) == 32);
4397         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
4398         if (get_jenv_res == JNI_EDETACHED) {
4399                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4400         }
4401         return ret_ref;
4402 }
4403 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
4404         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4405         JNIEnv *env;
4406         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4407         if (get_jenv_res == JNI_EDETACHED) {
4408                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4409         } else {
4410                 DO_ASSERT(get_jenv_res == JNI_OK);
4411         }
4412         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
4413         int64_t holder_tx_ref = 0;
4414         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
4415         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
4416         holder_tx_ref = tag_ptr(holder_tx_var.inner, holder_tx_var.is_owned);
4417         LDKCVec_PaymentPreimageZ preimages_var = preimages;
4418         jobjectArray preimages_arr = NULL;
4419         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
4420         ;
4421         for (size_t i = 0; i < preimages_var.datalen; i++) {
4422                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
4423                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
4424                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
4425         }
4426         
4427         FREE(preimages_var.data);
4428         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4429         CHECK(obj != NULL);
4430         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_holder_commitment_meth, holder_tx_ref, preimages_arr);
4431         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4432                 (*env)->ExceptionDescribe(env);
4433                 (*env)->FatalError(env, "A call to validate_holder_commitment in LDKBaseSign from rust threw an exception.");
4434         }
4435         void* ret_ptr = untag_ptr(ret);
4436         CHECK_ACCESS(ret_ptr);
4437         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
4438         FREE(untag_ptr(ret));
4439         if (get_jenv_res == JNI_EDETACHED) {
4440                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4441         }
4442         return ret_conv;
4443 }
4444 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
4445         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4446         JNIEnv *env;
4447         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4448         if (get_jenv_res == JNI_EDETACHED) {
4449                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4450         } else {
4451                 DO_ASSERT(get_jenv_res == JNI_OK);
4452         }
4453         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4454         CHECK(obj != NULL);
4455         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
4456         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4457                 (*env)->ExceptionDescribe(env);
4458                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
4459         }
4460         LDKThirtyTwoBytes ret_ref;
4461         CHECK((*env)->GetArrayLength(env, ret) == 32);
4462         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
4463         if (get_jenv_res == JNI_EDETACHED) {
4464                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4465         }
4466         return ret_ref;
4467 }
4468 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
4469         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4470         JNIEnv *env;
4471         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4472         if (get_jenv_res == JNI_EDETACHED) {
4473                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4474         } else {
4475                 DO_ASSERT(get_jenv_res == JNI_OK);
4476         }
4477         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
4478         int64_t commitment_tx_ref = 0;
4479         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
4480         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
4481         commitment_tx_ref = tag_ptr(commitment_tx_var.inner, commitment_tx_var.is_owned);
4482         LDKCVec_PaymentPreimageZ preimages_var = preimages;
4483         jobjectArray preimages_arr = NULL;
4484         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
4485         ;
4486         for (size_t i = 0; i < preimages_var.datalen; i++) {
4487                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
4488                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
4489                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
4490         }
4491         
4492         FREE(preimages_var.data);
4493         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4494         CHECK(obj != NULL);
4495         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref, preimages_arr);
4496         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4497                 (*env)->ExceptionDescribe(env);
4498                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
4499         }
4500         void* ret_ptr = untag_ptr(ret);
4501         CHECK_ACCESS(ret_ptr);
4502         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
4503         FREE(untag_ptr(ret));
4504         if (get_jenv_res == JNI_EDETACHED) {
4505                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4506         }
4507         return ret_conv;
4508 }
4509 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
4510         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4511         JNIEnv *env;
4512         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4513         if (get_jenv_res == JNI_EDETACHED) {
4514                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4515         } else {
4516                 DO_ASSERT(get_jenv_res == JNI_OK);
4517         }
4518         int64_t idx_conv = idx;
4519         int8_tArray secret_arr = (*env)->NewByteArray(env, 32);
4520         (*env)->SetByteArrayRegion(env, secret_arr, 0, 32, *secret);
4521         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4522         CHECK(obj != NULL);
4523         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_counterparty_revocation_meth, idx_conv, secret_arr);
4524         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4525                 (*env)->ExceptionDescribe(env);
4526                 (*env)->FatalError(env, "A call to validate_counterparty_revocation in LDKBaseSign from rust threw an exception.");
4527         }
4528         void* ret_ptr = untag_ptr(ret);
4529         CHECK_ACCESS(ret_ptr);
4530         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
4531         FREE(untag_ptr(ret));
4532         if (get_jenv_res == JNI_EDETACHED) {
4533                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4534         }
4535         return ret_conv;
4536 }
4537 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
4538         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4539         JNIEnv *env;
4540         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4541         if (get_jenv_res == JNI_EDETACHED) {
4542                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4543         } else {
4544                 DO_ASSERT(get_jenv_res == JNI_OK);
4545         }
4546         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
4547         int64_t commitment_tx_ref = 0;
4548         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
4549         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
4550         commitment_tx_ref = tag_ptr(commitment_tx_var.inner, commitment_tx_var.is_owned);
4551         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4552         CHECK(obj != NULL);
4553         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
4554         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4555                 (*env)->ExceptionDescribe(env);
4556                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
4557         }
4558         void* ret_ptr = untag_ptr(ret);
4559         CHECK_ACCESS(ret_ptr);
4560         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
4561         FREE(untag_ptr(ret));
4562         if (get_jenv_res == JNI_EDETACHED) {
4563                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4564         }
4565         return ret_conv;
4566 }
4567 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]) {
4568         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4569         JNIEnv *env;
4570         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4571         if (get_jenv_res == JNI_EDETACHED) {
4572                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4573         } else {
4574                 DO_ASSERT(get_jenv_res == JNI_OK);
4575         }
4576         LDKTransaction justice_tx_var = justice_tx;
4577         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
4578         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
4579         Transaction_free(justice_tx_var);
4580         int64_t input_conv = input;
4581         int64_t amount_conv = amount;
4582         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
4583         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
4584         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4585         CHECK(obj != NULL);
4586         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);
4587         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4588                 (*env)->ExceptionDescribe(env);
4589                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
4590         }
4591         void* ret_ptr = untag_ptr(ret);
4592         CHECK_ACCESS(ret_ptr);
4593         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4594         FREE(untag_ptr(ret));
4595         if (get_jenv_res == JNI_EDETACHED) {
4596                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4597         }
4598         return ret_conv;
4599 }
4600 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) {
4601         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4602         JNIEnv *env;
4603         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4604         if (get_jenv_res == JNI_EDETACHED) {
4605                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4606         } else {
4607                 DO_ASSERT(get_jenv_res == JNI_OK);
4608         }
4609         LDKTransaction justice_tx_var = justice_tx;
4610         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
4611         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
4612         Transaction_free(justice_tx_var);
4613         int64_t input_conv = input;
4614         int64_t amount_conv = amount;
4615         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
4616         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
4617         LDKHTLCOutputInCommitment htlc_var = *htlc;
4618         int64_t htlc_ref = 0;
4619         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
4620         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
4621         htlc_ref = tag_ptr(htlc_var.inner, htlc_var.is_owned);
4622         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4623         CHECK(obj != NULL);
4624         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);
4625         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4626                 (*env)->ExceptionDescribe(env);
4627                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
4628         }
4629         void* ret_ptr = untag_ptr(ret);
4630         CHECK_ACCESS(ret_ptr);
4631         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4632         FREE(untag_ptr(ret));
4633         if (get_jenv_res == JNI_EDETACHED) {
4634                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4635         }
4636         return ret_conv;
4637 }
4638 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) {
4639         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4640         JNIEnv *env;
4641         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4642         if (get_jenv_res == JNI_EDETACHED) {
4643                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4644         } else {
4645                 DO_ASSERT(get_jenv_res == JNI_OK);
4646         }
4647         LDKTransaction htlc_tx_var = htlc_tx;
4648         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
4649         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
4650         Transaction_free(htlc_tx_var);
4651         int64_t input_conv = input;
4652         int64_t amount_conv = amount;
4653         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
4654         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
4655         LDKHTLCOutputInCommitment htlc_var = *htlc;
4656         int64_t htlc_ref = 0;
4657         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
4658         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
4659         htlc_ref = tag_ptr(htlc_var.inner, htlc_var.is_owned);
4660         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4661         CHECK(obj != NULL);
4662         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);
4663         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4664                 (*env)->ExceptionDescribe(env);
4665                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
4666         }
4667         void* ret_ptr = untag_ptr(ret);
4668         CHECK_ACCESS(ret_ptr);
4669         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4670         FREE(untag_ptr(ret));
4671         if (get_jenv_res == JNI_EDETACHED) {
4672                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4673         }
4674         return ret_conv;
4675 }
4676 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
4677         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4678         JNIEnv *env;
4679         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4680         if (get_jenv_res == JNI_EDETACHED) {
4681                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4682         } else {
4683                 DO_ASSERT(get_jenv_res == JNI_OK);
4684         }
4685         LDKClosingTransaction closing_tx_var = *closing_tx;
4686         int64_t closing_tx_ref = 0;
4687         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
4688         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
4689         closing_tx_ref = tag_ptr(closing_tx_var.inner, closing_tx_var.is_owned);
4690         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4691         CHECK(obj != NULL);
4692         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
4693         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4694                 (*env)->ExceptionDescribe(env);
4695                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
4696         }
4697         void* ret_ptr = untag_ptr(ret);
4698         CHECK_ACCESS(ret_ptr);
4699         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4700         FREE(untag_ptr(ret));
4701         if (get_jenv_res == JNI_EDETACHED) {
4702                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4703         }
4704         return ret_conv;
4705 }
4706 LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
4707         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4708         JNIEnv *env;
4709         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4710         if (get_jenv_res == JNI_EDETACHED) {
4711                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4712         } else {
4713                 DO_ASSERT(get_jenv_res == JNI_OK);
4714         }
4715         LDKUnsignedChannelAnnouncement msg_var = *msg;
4716         int64_t msg_ref = 0;
4717         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
4718         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4719         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
4720         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4721         CHECK(obj != NULL);
4722         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
4723         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4724                 (*env)->ExceptionDescribe(env);
4725                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
4726         }
4727         void* ret_ptr = untag_ptr(ret);
4728         CHECK_ACCESS(ret_ptr);
4729         LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
4730         FREE(untag_ptr(ret));
4731         if (get_jenv_res == JNI_EDETACHED) {
4732                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4733         }
4734         return ret_conv;
4735 }
4736 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
4737         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4738         JNIEnv *env;
4739         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4740         if (get_jenv_res == JNI_EDETACHED) {
4741                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4742         } else {
4743                 DO_ASSERT(get_jenv_res == JNI_OK);
4744         }
4745         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
4746         int64_t channel_parameters_ref = 0;
4747         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
4748         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
4749         channel_parameters_ref = tag_ptr(channel_parameters_var.inner, channel_parameters_var.is_owned);
4750         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4751         CHECK(obj != NULL);
4752         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
4753         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4754                 (*env)->ExceptionDescribe(env);
4755                 (*env)->FatalError(env, "A call to ready_channel in LDKBaseSign from rust threw an exception.");
4756         }
4757         if (get_jenv_res == JNI_EDETACHED) {
4758                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4759         }
4760 }
4761 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
4762         jclass c = (*env)->GetObjectClass(env, o);
4763         CHECK(c != NULL);
4764         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
4765         atomic_init(&calls->refcnt, 1);
4766         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4767         calls->o = (*env)->NewWeakGlobalRef(env, o);
4768         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
4769         CHECK(calls->get_per_commitment_point_meth != NULL);
4770         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
4771         CHECK(calls->release_commitment_secret_meth != NULL);
4772         calls->validate_holder_commitment_meth = (*env)->GetMethodID(env, c, "validate_holder_commitment", "(J[[B)J");
4773         CHECK(calls->validate_holder_commitment_meth != NULL);
4774         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
4775         CHECK(calls->channel_keys_id_meth != NULL);
4776         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J[[B)J");
4777         CHECK(calls->sign_counterparty_commitment_meth != NULL);
4778         calls->validate_counterparty_revocation_meth = (*env)->GetMethodID(env, c, "validate_counterparty_revocation", "(J[B)J");
4779         CHECK(calls->validate_counterparty_revocation_meth != NULL);
4780         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
4781         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
4782         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
4783         CHECK(calls->sign_justice_revoked_output_meth != NULL);
4784         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
4785         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
4786         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
4787         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
4788         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
4789         CHECK(calls->sign_closing_transaction_meth != NULL);
4790         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
4791         CHECK(calls->sign_channel_announcement_meth != NULL);
4792         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
4793         CHECK(calls->ready_channel_meth != NULL);
4794
4795         LDKChannelPublicKeys pubkeys_conv;
4796         pubkeys_conv.inner = untag_ptr(pubkeys);
4797         pubkeys_conv.is_owned = ptr_is_owned(pubkeys);
4798         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
4799
4800         LDKBaseSign ret = {
4801                 .this_arg = (void*) calls,
4802                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
4803                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
4804                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
4805                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
4806                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
4807                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
4808                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
4809                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
4810                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
4811                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
4812                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
4813                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
4814                 .ready_channel = ready_channel_LDKBaseSign_jcall,
4815                 .free = LDKBaseSign_JCalls_free,
4816                 .pubkeys = pubkeys_conv,
4817                 .set_pubkeys = NULL,
4818         };
4819         return ret;
4820 }
4821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
4822         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
4823         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
4824         return tag_ptr(res_ptr, true);
4825 }
4826 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) {
4827         void* this_arg_ptr = untag_ptr(this_arg);
4828         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4829         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4830         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
4831         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
4832         return ret_arr;
4833 }
4834
4835 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
4836         void* this_arg_ptr = untag_ptr(this_arg);
4837         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4838         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4839         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4840         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
4841         return ret_arr;
4842 }
4843
4844 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) {
4845         void* this_arg_ptr = untag_ptr(this_arg);
4846         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4847         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4848         LDKHolderCommitmentTransaction holder_tx_conv;
4849         holder_tx_conv.inner = untag_ptr(holder_tx);
4850         holder_tx_conv.is_owned = ptr_is_owned(holder_tx);
4851         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
4852         holder_tx_conv.is_owned = false;
4853         LDKCVec_PaymentPreimageZ preimages_constr;
4854         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
4855         if (preimages_constr.datalen > 0)
4856                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
4857         else
4858                 preimages_constr.data = NULL;
4859         for (size_t i = 0; i < preimages_constr.datalen; i++) {
4860                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
4861                 LDKThirtyTwoBytes preimages_conv_8_ref;
4862                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
4863                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
4864                 preimages_constr.data[i] = preimages_conv_8_ref;
4865         }
4866         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
4867         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
4868         return tag_ptr(ret_conv, true);
4869 }
4870
4871 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
4872         void* this_arg_ptr = untag_ptr(this_arg);
4873         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4874         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4875         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4876         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
4877         return ret_arr;
4878 }
4879
4880 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) {
4881         void* this_arg_ptr = untag_ptr(this_arg);
4882         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4883         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4884         LDKCommitmentTransaction commitment_tx_conv;
4885         commitment_tx_conv.inner = untag_ptr(commitment_tx);
4886         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
4887         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
4888         commitment_tx_conv.is_owned = false;
4889         LDKCVec_PaymentPreimageZ preimages_constr;
4890         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
4891         if (preimages_constr.datalen > 0)
4892                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
4893         else
4894                 preimages_constr.data = NULL;
4895         for (size_t i = 0; i < preimages_constr.datalen; i++) {
4896                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
4897                 LDKThirtyTwoBytes preimages_conv_8_ref;
4898                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
4899                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
4900                 preimages_constr.data[i] = preimages_conv_8_ref;
4901         }
4902         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4903         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
4904         return tag_ptr(ret_conv, true);
4905 }
4906
4907 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) {
4908         void* this_arg_ptr = untag_ptr(this_arg);
4909         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4910         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4911         unsigned char secret_arr[32];
4912         CHECK((*env)->GetArrayLength(env, secret) == 32);
4913         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr);
4914         unsigned char (*secret_ref)[32] = &secret_arr;
4915         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
4916         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
4917         return tag_ptr(ret_conv, true);
4918 }
4919
4920 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) {
4921         void* this_arg_ptr = untag_ptr(this_arg);
4922         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4923         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4924         LDKHolderCommitmentTransaction commitment_tx_conv;
4925         commitment_tx_conv.inner = untag_ptr(commitment_tx);
4926         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
4927         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
4928         commitment_tx_conv.is_owned = false;
4929         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4930         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
4931         return tag_ptr(ret_conv, true);
4932 }
4933
4934 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) {
4935         void* this_arg_ptr = untag_ptr(this_arg);
4936         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4937         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4938         LDKTransaction justice_tx_ref;
4939         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
4940         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
4941         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
4942         justice_tx_ref.data_is_owned = true;
4943         unsigned char per_commitment_key_arr[32];
4944         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
4945         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
4946         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
4947         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4948         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
4949         return tag_ptr(ret_conv, true);
4950 }
4951
4952 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) {
4953         void* this_arg_ptr = untag_ptr(this_arg);
4954         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4955         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4956         LDKTransaction justice_tx_ref;
4957         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
4958         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
4959         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
4960         justice_tx_ref.data_is_owned = true;
4961         unsigned char per_commitment_key_arr[32];
4962         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
4963         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
4964         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
4965         LDKHTLCOutputInCommitment htlc_conv;
4966         htlc_conv.inner = untag_ptr(htlc);
4967         htlc_conv.is_owned = ptr_is_owned(htlc);
4968         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
4969         htlc_conv.is_owned = false;
4970         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4971         *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);
4972         return tag_ptr(ret_conv, true);
4973 }
4974
4975 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) {
4976         void* this_arg_ptr = untag_ptr(this_arg);
4977         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4978         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4979         LDKTransaction htlc_tx_ref;
4980         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
4981         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
4982         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
4983         htlc_tx_ref.data_is_owned = true;
4984         LDKPublicKey per_commitment_point_ref;
4985         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
4986         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
4987         LDKHTLCOutputInCommitment htlc_conv;
4988         htlc_conv.inner = untag_ptr(htlc);
4989         htlc_conv.is_owned = ptr_is_owned(htlc);
4990         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
4991         htlc_conv.is_owned = false;
4992         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4993         *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);
4994         return tag_ptr(ret_conv, true);
4995 }
4996
4997 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) {
4998         void* this_arg_ptr = untag_ptr(this_arg);
4999         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5000         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5001         LDKClosingTransaction closing_tx_conv;
5002         closing_tx_conv.inner = untag_ptr(closing_tx);
5003         closing_tx_conv.is_owned = ptr_is_owned(closing_tx);
5004         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
5005         closing_tx_conv.is_owned = false;
5006         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5007         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
5008         return tag_ptr(ret_conv, true);
5009 }
5010
5011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
5012         void* this_arg_ptr = untag_ptr(this_arg);
5013         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5014         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5015         LDKUnsignedChannelAnnouncement msg_conv;
5016         msg_conv.inner = untag_ptr(msg);
5017         msg_conv.is_owned = ptr_is_owned(msg);
5018         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
5019         msg_conv.is_owned = false;
5020         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
5021         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
5022         return tag_ptr(ret_conv, true);
5023 }
5024
5025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
5026         void* this_arg_ptr = untag_ptr(this_arg);
5027         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5028         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5029         LDKChannelTransactionParameters channel_parameters_conv;
5030         channel_parameters_conv.inner = untag_ptr(channel_parameters);
5031         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
5032         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
5033         channel_parameters_conv.is_owned = false;
5034         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
5035 }
5036
5037 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
5038         if (this_arg->set_pubkeys != NULL)
5039                 this_arg->set_pubkeys(this_arg);
5040         return this_arg->pubkeys;
5041 }
5042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
5043         void* this_arg_ptr = untag_ptr(this_arg);
5044         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5045         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5046         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
5047         int64_t ret_ref = 0;
5048         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5049         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5050         return ret_ref;
5051 }
5052
5053 typedef struct LDKSign_JCalls {
5054         atomic_size_t refcnt;
5055         JavaVM *vm;
5056         jweak o;
5057         LDKBaseSign_JCalls* BaseSign;
5058         jmethodID write_meth;
5059 } LDKSign_JCalls;
5060 static void LDKSign_JCalls_free(void* this_arg) {
5061         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
5062         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5063                 JNIEnv *env;
5064                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5065                 if (get_jenv_res == JNI_EDETACHED) {
5066                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5067                 } else {
5068                         DO_ASSERT(get_jenv_res == JNI_OK);
5069                 }
5070                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5071                 if (get_jenv_res == JNI_EDETACHED) {
5072                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5073                 }
5074                 FREE(j_calls);
5075         }
5076 }
5077 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
5078         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
5079         JNIEnv *env;
5080         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5081         if (get_jenv_res == JNI_EDETACHED) {
5082                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5083         } else {
5084                 DO_ASSERT(get_jenv_res == JNI_OK);
5085         }
5086         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5087         CHECK(obj != NULL);
5088         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
5089         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5090                 (*env)->ExceptionDescribe(env);
5091                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
5092         }
5093         LDKCVec_u8Z ret_ref;
5094         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
5095         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5096         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
5097         if (get_jenv_res == JNI_EDETACHED) {
5098                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5099         }
5100         return ret_ref;
5101 }
5102 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
5103         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
5104         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5105         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
5106 }
5107 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
5108         jclass c = (*env)->GetObjectClass(env, o);
5109         CHECK(c != NULL);
5110         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
5111         atomic_init(&calls->refcnt, 1);
5112         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5113         calls->o = (*env)->NewWeakGlobalRef(env, o);
5114         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
5115         CHECK(calls->write_meth != NULL);
5116
5117         LDKChannelPublicKeys pubkeys_conv;
5118         pubkeys_conv.inner = untag_ptr(pubkeys);
5119         pubkeys_conv.is_owned = ptr_is_owned(pubkeys);
5120         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
5121
5122         LDKSign ret = {
5123                 .this_arg = (void*) calls,
5124                 .write = write_LDKSign_jcall,
5125                 .cloned = LDKSign_JCalls_cloned,
5126                 .free = LDKSign_JCalls_free,
5127                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
5128         };
5129         calls->BaseSign = ret.BaseSign.this_arg;
5130         return ret;
5131 }
5132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
5133         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
5134         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
5135         return tag_ptr(res_ptr, true);
5136 }
5137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIEnv *env, jclass clz, int64_t arg) {
5138         LDKSign *inp = (LDKSign *)untag_ptr(arg);
5139         return tag_ptr(&inp->BaseSign, false);
5140 }
5141 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
5142         void* this_arg_ptr = untag_ptr(this_arg);
5143         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5144         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
5145         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
5146         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5147         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5148         CVec_u8Z_free(ret_var);
5149         return ret_arr;
5150 }
5151
5152 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
5153 CHECK(owner->result_ok);
5154         return Sign_clone(&*owner->contents.result);
5155 }
5156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5157         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(owner);
5158         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
5159         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
5160         return tag_ptr(ret_ret, true);
5161 }
5162
5163 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
5164 CHECK(!owner->result_ok);
5165         return DecodeError_clone(&*owner->contents.err);
5166 }
5167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5168         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(owner);
5169         LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
5170         int64_t ret_ref = 0;
5171         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5172         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5173         return ret_ref;
5174 }
5175
5176 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
5177 CHECK(owner->result_ok);
5178         return *owner->contents.result;
5179 }
5180 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5181         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(owner);
5182         int8_tArray ret_arr = (*env)->NewByteArray(env, 68);
5183         (*env)->SetByteArrayRegion(env, ret_arr, 0, 68, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form);
5184         return ret_arr;
5185 }
5186
5187 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
5188 CHECK(!owner->result_ok);
5189         return *owner->contents.err;
5190 }
5191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5192         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(owner);
5193         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
5194 }
5195
5196 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
5197         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
5198         for (size_t i = 0; i < ret.datalen; i++) {
5199                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
5200         }
5201         return ret;
5202 }
5203 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
5204 CHECK(owner->result_ok);
5205         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
5206 }
5207 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5208         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(owner);
5209         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
5210         jobjectArray ret_arr = NULL;
5211         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
5212         ;
5213         for (size_t i = 0; i < ret_var.datalen; i++) {
5214                 LDKCVec_u8Z ret_conv_8_var = ret_var.data[i];
5215                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
5216                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
5217                 CVec_u8Z_free(ret_conv_8_var);
5218                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
5219         }
5220         
5221         FREE(ret_var.data);
5222         return ret_arr;
5223 }
5224
5225 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
5226 CHECK(!owner->result_ok);
5227         return *owner->contents.err;
5228 }
5229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5230         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(owner);
5231         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
5232 }
5233
5234 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
5235 CHECK(owner->result_ok);
5236         return InMemorySigner_clone(&*owner->contents.result);
5237 }
5238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5239         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(owner);
5240         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
5241         int64_t ret_ref = 0;
5242         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5243         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5244         return ret_ref;
5245 }
5246
5247 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
5248 CHECK(!owner->result_ok);
5249         return DecodeError_clone(&*owner->contents.err);
5250 }
5251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5252         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(owner);
5253         LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
5254         int64_t ret_ref = 0;
5255         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5256         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5257         return ret_ref;
5258 }
5259
5260 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
5261         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
5262         for (size_t i = 0; i < ret.datalen; i++) {
5263                 ret.data[i] = TxOut_clone(&orig->data[i]);
5264         }
5265         return ret;
5266 }
5267 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
5268 CHECK(owner->result_ok);
5269         return *owner->contents.result;
5270 }
5271 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5272         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(owner);
5273         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
5274         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5275         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5276         return ret_arr;
5277 }
5278
5279 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
5280 CHECK(!owner->result_ok);
5281         return *owner->contents.err;
5282 }
5283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5284         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(owner);
5285         CResult_TransactionNoneZ_get_err(owner_conv);
5286 }
5287
5288 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
5289         return ThirtyTwoBytes_clone(&owner->a);
5290 }
5291 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5292         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(owner);
5293         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5294         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data);
5295         return ret_arr;
5296 }
5297
5298 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
5299         return ChannelMonitor_clone(&owner->b);
5300 }
5301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5302         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(owner);
5303         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
5304         int64_t ret_ref = 0;
5305         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5306         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5307         return ret_ref;
5308 }
5309
5310 static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
5311         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
5312         for (size_t i = 0; i < ret.datalen; i++) {
5313                 ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
5314         }
5315         return ret;
5316 }
5317 static inline struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
5318 CHECK(owner->result_ok);
5319         return CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(&*owner->contents.result);
5320 }
5321 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5322         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(owner);
5323         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret_var = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(owner_conv);
5324         int64_tArray ret_arr = NULL;
5325         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5326         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5327         for (size_t j = 0; j < ret_var.datalen; j++) {
5328                 LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
5329                 *ret_conv_35_conv = ret_var.data[j];
5330                 ret_arr_ptr[j] = tag_ptr(ret_conv_35_conv, true);
5331         }
5332         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5333         FREE(ret_var.data);
5334         return ret_arr;
5335 }
5336
5337 static inline enum LDKIOError CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
5338 CHECK(!owner->result_ok);
5339         return *owner->contents.err;
5340 }
5341 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5342         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(owner);
5343         jclass ret_conv = LDKIOError_to_java(env, CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(owner_conv));
5344         return ret_conv;
5345 }
5346
5347 static jclass LDKCOption_u16Z_Some_class = NULL;
5348 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
5349 static jclass LDKCOption_u16Z_None_class = NULL;
5350 static jmethodID LDKCOption_u16Z_None_meth = NULL;
5351 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
5352         LDKCOption_u16Z_Some_class =
5353                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$Some"));
5354         CHECK(LDKCOption_u16Z_Some_class != NULL);
5355         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
5356         CHECK(LDKCOption_u16Z_Some_meth != NULL);
5357         LDKCOption_u16Z_None_class =
5358                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$None"));
5359         CHECK(LDKCOption_u16Z_None_class != NULL);
5360         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
5361         CHECK(LDKCOption_u16Z_None_meth != NULL);
5362 }
5363 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5364         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)untag_ptr(ptr);
5365         switch(obj->tag) {
5366                 case LDKCOption_u16Z_Some: {
5367                         int16_t some_conv = obj->some;
5368                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, some_conv);
5369                 }
5370                 case LDKCOption_u16Z_None: {
5371                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
5372                 }
5373                 default: abort();
5374         }
5375 }
5376 static jclass LDKAPIError_APIMisuseError_class = NULL;
5377 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
5378 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
5379 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
5380 static jclass LDKAPIError_RouteError_class = NULL;
5381 static jmethodID LDKAPIError_RouteError_meth = NULL;
5382 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
5383 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
5384 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
5385 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
5386 static jclass LDKAPIError_IncompatibleShutdownScript_class = NULL;
5387 static jmethodID LDKAPIError_IncompatibleShutdownScript_meth = NULL;
5388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
5389         LDKAPIError_APIMisuseError_class =
5390                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$APIMisuseError"));
5391         CHECK(LDKAPIError_APIMisuseError_class != NULL);
5392         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
5393         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
5394         LDKAPIError_FeeRateTooHigh_class =
5395                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh"));
5396         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
5397         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
5398         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
5399         LDKAPIError_RouteError_class =
5400                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$RouteError"));
5401         CHECK(LDKAPIError_RouteError_class != NULL);
5402         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
5403         CHECK(LDKAPIError_RouteError_meth != NULL);
5404         LDKAPIError_ChannelUnavailable_class =
5405                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$ChannelUnavailable"));
5406         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
5407         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
5408         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
5409         LDKAPIError_MonitorUpdateFailed_class =
5410                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed"));
5411         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
5412         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
5413         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
5414         LDKAPIError_IncompatibleShutdownScript_class =
5415                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$IncompatibleShutdownScript"));
5416         CHECK(LDKAPIError_IncompatibleShutdownScript_class != NULL);
5417         LDKAPIError_IncompatibleShutdownScript_meth = (*env)->GetMethodID(env, LDKAPIError_IncompatibleShutdownScript_class, "<init>", "(J)V");
5418         CHECK(LDKAPIError_IncompatibleShutdownScript_meth != NULL);
5419 }
5420 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5421         LDKAPIError *obj = (LDKAPIError*)untag_ptr(ptr);
5422         switch(obj->tag) {
5423                 case LDKAPIError_APIMisuseError: {
5424                         LDKStr err_str = obj->api_misuse_error.err;
5425                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5426                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
5427                 }
5428                 case LDKAPIError_FeeRateTooHigh: {
5429                         LDKStr err_str = obj->fee_rate_too_high.err;
5430                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5431                         int32_t feerate_conv = obj->fee_rate_too_high.feerate;
5432                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, feerate_conv);
5433                 }
5434                 case LDKAPIError_RouteError: {
5435                         LDKStr err_str = obj->route_error.err;
5436                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5437                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
5438                 }
5439                 case LDKAPIError_ChannelUnavailable: {
5440                         LDKStr err_str = obj->channel_unavailable.err;
5441                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5442                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
5443                 }
5444                 case LDKAPIError_MonitorUpdateFailed: {
5445                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
5446                 }
5447                 case LDKAPIError_IncompatibleShutdownScript: {
5448                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
5449                         int64_t script_ref = 0;
5450                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
5451                         script_ref = tag_ptr(script_var.inner, false);
5452                         return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
5453                 }
5454                 default: abort();
5455         }
5456 }
5457 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
5458 CHECK(owner->result_ok);
5459         return *owner->contents.result;
5460 }
5461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5462         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(owner);
5463         CResult_NoneAPIErrorZ_get_ok(owner_conv);
5464 }
5465
5466 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
5467 CHECK(!owner->result_ok);
5468         return APIError_clone(&*owner->contents.err);
5469 }
5470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5471         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(owner);
5472         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5473         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
5474         int64_t ret_ref = tag_ptr(ret_copy, true);
5475         return ret_ref;
5476 }
5477
5478 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
5479         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
5480         for (size_t i = 0; i < ret.datalen; i++) {
5481                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
5482         }
5483         return ret;
5484 }
5485 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
5486         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
5487         for (size_t i = 0; i < ret.datalen; i++) {
5488                 ret.data[i] = APIError_clone(&orig->data[i]);
5489         }
5490         return ret;
5491 }
5492 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
5493 CHECK(owner->result_ok);
5494         return ThirtyTwoBytes_clone(&*owner->contents.result);
5495 }
5496 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5497         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(owner);
5498         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5499         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult__u832APIErrorZ_get_ok(owner_conv).data);
5500         return ret_arr;
5501 }
5502
5503 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
5504 CHECK(!owner->result_ok);
5505         return APIError_clone(&*owner->contents.err);
5506 }
5507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5508         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(owner);
5509         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5510         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
5511         int64_t ret_ref = tag_ptr(ret_copy, true);
5512         return ret_ref;
5513 }
5514
5515 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
5516 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
5517 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
5518 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
5519 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
5520 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
5521 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
5522 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
5523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
5524         LDKPaymentSendFailure_ParameterError_class =
5525                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError"));
5526         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
5527         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
5528         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
5529         LDKPaymentSendFailure_PathParameterError_class =
5530                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError"));
5531         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
5532         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
5533         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
5534         LDKPaymentSendFailure_AllFailedRetrySafe_class =
5535                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe"));
5536         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
5537         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
5538         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
5539         LDKPaymentSendFailure_PartialFailure_class =
5540                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure"));
5541         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
5542         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([JJ[B)V");
5543         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
5544 }
5545 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5546         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)untag_ptr(ptr);
5547         switch(obj->tag) {
5548                 case LDKPaymentSendFailure_ParameterError: {
5549                         int64_t parameter_error_ref = tag_ptr(&obj->parameter_error, false);
5550                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
5551                 }
5552                 case LDKPaymentSendFailure_PathParameterError: {
5553                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
5554                         int64_tArray path_parameter_error_arr = NULL;
5555                         path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
5556                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
5557                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
5558                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5559                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
5560                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
5561                                 path_parameter_error_arr_ptr[w] = tag_ptr(path_parameter_error_conv_22_conv, true);
5562                         }
5563                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
5564                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
5565                 }
5566                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
5567                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
5568                         int64_tArray all_failed_retry_safe_arr = NULL;
5569                         all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
5570                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
5571                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
5572                                 int64_t all_failed_retry_safe_conv_10_ref = tag_ptr(&all_failed_retry_safe_var.data[k], false);
5573                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
5574                         }
5575                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
5576                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
5577                 }
5578                 case LDKPaymentSendFailure_PartialFailure: {
5579                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
5580                         int64_tArray results_arr = NULL;
5581                         results_arr = (*env)->NewLongArray(env, results_var.datalen);
5582                         int64_t *results_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, results_arr, NULL);
5583                         for (size_t w = 0; w < results_var.datalen; w++) {
5584                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5585                                 *results_conv_22_conv = results_var.data[w];
5586                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
5587                                 results_arr_ptr[w] = tag_ptr(results_conv_22_conv, true);
5588                         }
5589                         (*env)->ReleasePrimitiveArrayCritical(env, results_arr, results_arr_ptr, 0);
5590                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
5591                         int64_t failed_paths_retry_ref = 0;
5592                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
5593                         failed_paths_retry_ref = tag_ptr(failed_paths_retry_var.inner, false);
5594                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
5595                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->partial_failure.payment_id.data);
5596                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, results_arr, failed_paths_retry_ref, payment_id_arr);
5597                 }
5598                 default: abort();
5599         }
5600 }
5601 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
5602 CHECK(owner->result_ok);
5603         return ThirtyTwoBytes_clone(&*owner->contents.result);
5604 }
5605 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5606         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)untag_ptr(owner);
5607         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5608         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data);
5609         return ret_arr;
5610 }
5611
5612 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
5613 CHECK(!owner->result_ok);
5614         return PaymentSendFailure_clone(&*owner->contents.err);
5615 }
5616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5617         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)untag_ptr(owner);
5618         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
5619         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
5620         int64_t ret_ref = tag_ptr(ret_copy, true);
5621         return ret_ref;
5622 }
5623
5624 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
5625 CHECK(owner->result_ok);
5626         return *owner->contents.result;
5627 }
5628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5629         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(owner);
5630         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
5631 }
5632
5633 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
5634 CHECK(!owner->result_ok);
5635         return PaymentSendFailure_clone(&*owner->contents.err);
5636 }
5637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5638         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(owner);
5639         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
5640         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
5641         int64_t ret_ref = tag_ptr(ret_copy, true);
5642         return ret_ref;
5643 }
5644
5645 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
5646         return ThirtyTwoBytes_clone(&owner->a);
5647 }
5648 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5649         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(owner);
5650         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5651         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data);
5652         return ret_arr;
5653 }
5654
5655 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
5656         return ThirtyTwoBytes_clone(&owner->b);
5657 }
5658 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5659         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(owner);
5660         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5661         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data);
5662         return ret_arr;
5663 }
5664
5665 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
5666 CHECK(owner->result_ok);
5667         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
5668 }
5669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5670         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(owner);
5671         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
5672         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
5673         return tag_ptr(ret_conv, true);
5674 }
5675
5676 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
5677 CHECK(!owner->result_ok);
5678         return PaymentSendFailure_clone(&*owner->contents.err);
5679 }
5680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5681         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(owner);
5682         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
5683         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
5684         int64_t ret_ref = tag_ptr(ret_copy, true);
5685         return ret_ref;
5686 }
5687
5688 static inline LDKCVec_ThirtyTwoBytesZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_ThirtyTwoBytesZ *orig) {
5689         LDKCVec_ThirtyTwoBytesZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_ThirtyTwoBytesZ clone bytes"), .datalen = orig->datalen };
5690         for (size_t i = 0; i < ret.datalen; i++) {
5691                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
5692         }
5693         return ret;
5694 }
5695 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
5696         return ThirtyTwoBytes_clone(&owner->a);
5697 }
5698 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5699         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(owner);
5700         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5701         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data);
5702         return ret_arr;
5703 }
5704
5705 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
5706         return ThirtyTwoBytes_clone(&owner->b);
5707 }
5708 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5709         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(owner);
5710         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5711         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data);
5712         return ret_arr;
5713 }
5714
5715 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
5716 CHECK(owner->result_ok);
5717         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
5718 }
5719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5720         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(owner);
5721         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
5722         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
5723         return tag_ptr(ret_conv, true);
5724 }
5725
5726 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
5727 CHECK(!owner->result_ok);
5728         return *owner->contents.err;
5729 }
5730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5731         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(owner);
5732         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
5733 }
5734
5735 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
5736 CHECK(owner->result_ok);
5737         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
5738 }
5739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5740         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(owner);
5741         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
5742         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
5743         return tag_ptr(ret_conv, true);
5744 }
5745
5746 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
5747 CHECK(!owner->result_ok);
5748         return APIError_clone(&*owner->contents.err);
5749 }
5750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5751         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(owner);
5752         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5753         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
5754         int64_t ret_ref = tag_ptr(ret_copy, true);
5755         return ret_ref;
5756 }
5757
5758 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
5759 CHECK(owner->result_ok);
5760         return ThirtyTwoBytes_clone(&*owner->contents.result);
5761 }
5762 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5763         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(owner);
5764         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5765         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data);
5766         return ret_arr;
5767 }
5768
5769 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
5770 CHECK(!owner->result_ok);
5771         return *owner->contents.err;
5772 }
5773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5774         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(owner);
5775         CResult_PaymentSecretNoneZ_get_err(owner_conv);
5776 }
5777
5778 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
5779 CHECK(owner->result_ok);
5780         return ThirtyTwoBytes_clone(&*owner->contents.result);
5781 }
5782 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5783         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(owner);
5784         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5785         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data);
5786         return ret_arr;
5787 }
5788
5789 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
5790 CHECK(!owner->result_ok);
5791         return APIError_clone(&*owner->contents.err);
5792 }
5793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5794         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(owner);
5795         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5796         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
5797         int64_t ret_ref = tag_ptr(ret_copy, true);
5798         return ret_ref;
5799 }
5800
5801 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
5802 CHECK(owner->result_ok);
5803         return ThirtyTwoBytes_clone(&*owner->contents.result);
5804 }
5805 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5806         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(owner);
5807         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5808         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data);
5809         return ret_arr;
5810 }
5811
5812 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
5813 CHECK(!owner->result_ok);
5814         return APIError_clone(&*owner->contents.err);
5815 }
5816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5817         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(owner);
5818         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5819         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
5820         int64_t ret_ref = tag_ptr(ret_copy, true);
5821         return ret_ref;
5822 }
5823
5824 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
5825 CHECK(owner->result_ok);
5826         return CounterpartyForwardingInfo_clone(&*owner->contents.result);
5827 }
5828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5829         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(owner);
5830         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
5831         int64_t ret_ref = 0;
5832         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5833         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5834         return ret_ref;
5835 }
5836
5837 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
5838 CHECK(!owner->result_ok);
5839         return DecodeError_clone(&*owner->contents.err);
5840 }
5841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5842         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(owner);
5843         LDKDecodeError ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
5844         int64_t ret_ref = 0;
5845         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5846         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5847         return ret_ref;
5848 }
5849
5850 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
5851 CHECK(owner->result_ok);
5852         return ChannelCounterparty_clone(&*owner->contents.result);
5853 }
5854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5855         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(owner);
5856         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
5857         int64_t ret_ref = 0;
5858         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5859         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5860         return ret_ref;
5861 }
5862
5863 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
5864 CHECK(!owner->result_ok);
5865         return DecodeError_clone(&*owner->contents.err);
5866 }
5867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5868         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(owner);
5869         LDKDecodeError ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
5870         int64_t ret_ref = 0;
5871         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5872         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5873         return ret_ref;
5874 }
5875
5876 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
5877 CHECK(owner->result_ok);
5878         return ChannelDetails_clone(&*owner->contents.result);
5879 }
5880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5881         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(owner);
5882         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
5883         int64_t ret_ref = 0;
5884         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5885         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5886         return ret_ref;
5887 }
5888
5889 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
5890 CHECK(!owner->result_ok);
5891         return DecodeError_clone(&*owner->contents.err);
5892 }
5893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5894         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(owner);
5895         LDKDecodeError ret_var = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
5896         int64_t ret_ref = 0;
5897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5898         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5899         return ret_ref;
5900 }
5901
5902 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
5903 CHECK(owner->result_ok);
5904         return PhantomRouteHints_clone(&*owner->contents.result);
5905 }
5906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5907         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(owner);
5908         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
5909         int64_t ret_ref = 0;
5910         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5911         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5912         return ret_ref;
5913 }
5914
5915 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
5916 CHECK(!owner->result_ok);
5917         return DecodeError_clone(&*owner->contents.err);
5918 }
5919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5920         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(owner);
5921         LDKDecodeError ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
5922         int64_t ret_ref = 0;
5923         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5924         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5925         return ret_ref;
5926 }
5927
5928 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
5929         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
5930         for (size_t i = 0; i < ret.datalen; i++) {
5931                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
5932         }
5933         return ret;
5934 }
5935 typedef struct LDKWatch_JCalls {
5936         atomic_size_t refcnt;
5937         JavaVM *vm;
5938         jweak o;
5939         jmethodID watch_channel_meth;
5940         jmethodID update_channel_meth;
5941         jmethodID release_pending_monitor_events_meth;
5942 } LDKWatch_JCalls;
5943 static void LDKWatch_JCalls_free(void* this_arg) {
5944         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5945         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5946                 JNIEnv *env;
5947                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5948                 if (get_jenv_res == JNI_EDETACHED) {
5949                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5950                 } else {
5951                         DO_ASSERT(get_jenv_res == JNI_OK);
5952                 }
5953                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5954                 if (get_jenv_res == JNI_EDETACHED) {
5955                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5956                 }
5957                 FREE(j_calls);
5958         }
5959 }
5960 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
5961         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5962         JNIEnv *env;
5963         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5964         if (get_jenv_res == JNI_EDETACHED) {
5965                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5966         } else {
5967                 DO_ASSERT(get_jenv_res == JNI_OK);
5968         }
5969         LDKOutPoint funding_txo_var = funding_txo;
5970         int64_t funding_txo_ref = 0;
5971         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
5972         funding_txo_ref = tag_ptr(funding_txo_var.inner, funding_txo_var.is_owned);
5973         LDKChannelMonitor monitor_var = monitor;
5974         int64_t monitor_ref = 0;
5975         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
5976         monitor_ref = tag_ptr(monitor_var.inner, monitor_var.is_owned);
5977         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5978         CHECK(obj != NULL);
5979         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
5980         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5981                 (*env)->ExceptionDescribe(env);
5982                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
5983         }
5984         void* ret_ptr = untag_ptr(ret);
5985         CHECK_ACCESS(ret_ptr);
5986         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
5987         FREE(untag_ptr(ret));
5988         if (get_jenv_res == JNI_EDETACHED) {
5989                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5990         }
5991         return ret_conv;
5992 }
5993 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
5994         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5995         JNIEnv *env;
5996         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5997         if (get_jenv_res == JNI_EDETACHED) {
5998                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5999         } else {
6000                 DO_ASSERT(get_jenv_res == JNI_OK);
6001         }
6002         LDKOutPoint funding_txo_var = funding_txo;
6003         int64_t funding_txo_ref = 0;
6004         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
6005         funding_txo_ref = tag_ptr(funding_txo_var.inner, funding_txo_var.is_owned);
6006         LDKChannelMonitorUpdate update_var = update;
6007         int64_t update_ref = 0;
6008         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
6009         update_ref = tag_ptr(update_var.inner, update_var.is_owned);
6010         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6011         CHECK(obj != NULL);
6012         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
6013         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6014                 (*env)->ExceptionDescribe(env);
6015                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
6016         }
6017         void* ret_ptr = untag_ptr(ret);
6018         CHECK_ACCESS(ret_ptr);
6019         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
6020         FREE(untag_ptr(ret));
6021         if (get_jenv_res == JNI_EDETACHED) {
6022                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6023         }
6024         return ret_conv;
6025 }
6026 LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
6027         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6028         JNIEnv *env;
6029         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6030         if (get_jenv_res == JNI_EDETACHED) {
6031                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6032         } else {
6033                 DO_ASSERT(get_jenv_res == JNI_OK);
6034         }
6035         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6036         CHECK(obj != NULL);
6037         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
6038         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6039                 (*env)->ExceptionDescribe(env);
6040                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
6041         }
6042         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_constr;
6043         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6044         if (ret_constr.datalen > 0)
6045                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
6046         else
6047                 ret_constr.data = NULL;
6048         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
6049         for (size_t x = 0; x < ret_constr.datalen; x++) {
6050                 int64_t ret_conv_49 = ret_vals[x];
6051                 void* ret_conv_49_ptr = untag_ptr(ret_conv_49);
6052                 CHECK_ACCESS(ret_conv_49_ptr);
6053                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ ret_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(ret_conv_49_ptr);
6054                 FREE(untag_ptr(ret_conv_49));
6055                 ret_constr.data[x] = ret_conv_49_conv;
6056         }
6057         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
6058         if (get_jenv_res == JNI_EDETACHED) {
6059                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6060         }
6061         return ret_constr;
6062 }
6063 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
6064         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
6065         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6066 }
6067 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
6068         jclass c = (*env)->GetObjectClass(env, o);
6069         CHECK(c != NULL);
6070         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
6071         atomic_init(&calls->refcnt, 1);
6072         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6073         calls->o = (*env)->NewWeakGlobalRef(env, o);
6074         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
6075         CHECK(calls->watch_channel_meth != NULL);
6076         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
6077         CHECK(calls->update_channel_meth != NULL);
6078         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
6079         CHECK(calls->release_pending_monitor_events_meth != NULL);
6080
6081         LDKWatch ret = {
6082                 .this_arg = (void*) calls,
6083                 .watch_channel = watch_channel_LDKWatch_jcall,
6084                 .update_channel = update_channel_LDKWatch_jcall,
6085                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
6086                 .free = LDKWatch_JCalls_free,
6087         };
6088         return ret;
6089 }
6090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
6091         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
6092         *res_ptr = LDKWatch_init(env, clz, o);
6093         return tag_ptr(res_ptr, true);
6094 }
6095 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) {
6096         void* this_arg_ptr = untag_ptr(this_arg);
6097         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6098         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6099         LDKOutPoint funding_txo_conv;
6100         funding_txo_conv.inner = untag_ptr(funding_txo);
6101         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
6102         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
6103         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
6104         LDKChannelMonitor monitor_conv;
6105         monitor_conv.inner = untag_ptr(monitor);
6106         monitor_conv.is_owned = ptr_is_owned(monitor);
6107         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
6108         monitor_conv = ChannelMonitor_clone(&monitor_conv);
6109         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6110         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
6111         return tag_ptr(ret_conv, true);
6112 }
6113
6114 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) {
6115         void* this_arg_ptr = untag_ptr(this_arg);
6116         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6117         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6118         LDKOutPoint funding_txo_conv;
6119         funding_txo_conv.inner = untag_ptr(funding_txo);
6120         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
6121         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
6122         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
6123         LDKChannelMonitorUpdate update_conv;
6124         update_conv.inner = untag_ptr(update);
6125         update_conv.is_owned = ptr_is_owned(update);
6126         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
6127         update_conv = ChannelMonitorUpdate_clone(&update_conv);
6128         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6129         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
6130         return tag_ptr(ret_conv, true);
6131 }
6132
6133 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
6134         void* this_arg_ptr = untag_ptr(this_arg);
6135         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6136         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6137         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
6138         int64_tArray ret_arr = NULL;
6139         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6140         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6141         for (size_t x = 0; x < ret_var.datalen; x++) {
6142                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv_49_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
6143                 *ret_conv_49_conv = ret_var.data[x];
6144                 ret_arr_ptr[x] = tag_ptr(ret_conv_49_conv, true);
6145         }
6146         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6147         FREE(ret_var.data);
6148         return ret_arr;
6149 }
6150
6151 typedef struct LDKBroadcasterInterface_JCalls {
6152         atomic_size_t refcnt;
6153         JavaVM *vm;
6154         jweak o;
6155         jmethodID broadcast_transaction_meth;
6156 } LDKBroadcasterInterface_JCalls;
6157 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
6158         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
6159         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6160                 JNIEnv *env;
6161                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6162                 if (get_jenv_res == JNI_EDETACHED) {
6163                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6164                 } else {
6165                         DO_ASSERT(get_jenv_res == JNI_OK);
6166                 }
6167                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6168                 if (get_jenv_res == JNI_EDETACHED) {
6169                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6170                 }
6171                 FREE(j_calls);
6172         }
6173 }
6174 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
6175         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
6176         JNIEnv *env;
6177         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6178         if (get_jenv_res == JNI_EDETACHED) {
6179                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6180         } else {
6181                 DO_ASSERT(get_jenv_res == JNI_OK);
6182         }
6183         LDKTransaction tx_var = tx;
6184         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
6185         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
6186         Transaction_free(tx_var);
6187         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6188         CHECK(obj != NULL);
6189         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
6190         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6191                 (*env)->ExceptionDescribe(env);
6192                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
6193         }
6194         if (get_jenv_res == JNI_EDETACHED) {
6195                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6196         }
6197 }
6198 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
6199         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
6200         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6201 }
6202 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
6203         jclass c = (*env)->GetObjectClass(env, o);
6204         CHECK(c != NULL);
6205         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
6206         atomic_init(&calls->refcnt, 1);
6207         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6208         calls->o = (*env)->NewWeakGlobalRef(env, o);
6209         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
6210         CHECK(calls->broadcast_transaction_meth != NULL);
6211
6212         LDKBroadcasterInterface ret = {
6213                 .this_arg = (void*) calls,
6214                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
6215                 .free = LDKBroadcasterInterface_JCalls_free,
6216         };
6217         return ret;
6218 }
6219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
6220         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
6221         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
6222         return tag_ptr(res_ptr, true);
6223 }
6224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
6225         void* this_arg_ptr = untag_ptr(this_arg);
6226         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6227         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
6228         LDKTransaction tx_ref;
6229         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
6230         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
6231         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
6232         tx_ref.data_is_owned = true;
6233         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
6234 }
6235
6236 typedef struct LDKKeysInterface_JCalls {
6237         atomic_size_t refcnt;
6238         JavaVM *vm;
6239         jweak o;
6240         jmethodID get_node_secret_meth;
6241         jmethodID get_destination_script_meth;
6242         jmethodID get_shutdown_scriptpubkey_meth;
6243         jmethodID get_channel_signer_meth;
6244         jmethodID get_secure_random_bytes_meth;
6245         jmethodID read_chan_signer_meth;
6246         jmethodID sign_invoice_meth;
6247         jmethodID get_inbound_payment_key_material_meth;
6248 } LDKKeysInterface_JCalls;
6249 static void LDKKeysInterface_JCalls_free(void* this_arg) {
6250         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6251         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6252                 JNIEnv *env;
6253                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6254                 if (get_jenv_res == JNI_EDETACHED) {
6255                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6256                 } else {
6257                         DO_ASSERT(get_jenv_res == JNI_OK);
6258                 }
6259                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6260                 if (get_jenv_res == JNI_EDETACHED) {
6261                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6262                 }
6263                 FREE(j_calls);
6264         }
6265 }
6266 LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
6267         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6268         JNIEnv *env;
6269         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6270         if (get_jenv_res == JNI_EDETACHED) {
6271                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6272         } else {
6273                 DO_ASSERT(get_jenv_res == JNI_OK);
6274         }
6275         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
6276         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6277         CHECK(obj != NULL);
6278         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_node_secret_meth, recipient_conv);
6279         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6280                 (*env)->ExceptionDescribe(env);
6281                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
6282         }
6283         void* ret_ptr = untag_ptr(ret);
6284         CHECK_ACCESS(ret_ptr);
6285         LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
6286         FREE(untag_ptr(ret));
6287         if (get_jenv_res == JNI_EDETACHED) {
6288                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6289         }
6290         return ret_conv;
6291 }
6292 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
6293         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6294         JNIEnv *env;
6295         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6296         if (get_jenv_res == JNI_EDETACHED) {
6297                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6298         } else {
6299                 DO_ASSERT(get_jenv_res == JNI_OK);
6300         }
6301         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6302         CHECK(obj != NULL);
6303         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
6304         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6305                 (*env)->ExceptionDescribe(env);
6306                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
6307         }
6308         LDKCVec_u8Z ret_ref;
6309         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
6310         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
6311         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
6312         if (get_jenv_res == JNI_EDETACHED) {
6313                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6314         }
6315         return ret_ref;
6316 }
6317 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
6318         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6319         JNIEnv *env;
6320         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6321         if (get_jenv_res == JNI_EDETACHED) {
6322                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6323         } else {
6324                 DO_ASSERT(get_jenv_res == JNI_OK);
6325         }
6326         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6327         CHECK(obj != NULL);
6328         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_shutdown_scriptpubkey_meth);
6329         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6330                 (*env)->ExceptionDescribe(env);
6331                 (*env)->FatalError(env, "A call to get_shutdown_scriptpubkey in LDKKeysInterface from rust threw an exception.");
6332         }
6333         LDKShutdownScript ret_conv;
6334         ret_conv.inner = untag_ptr(ret);
6335         ret_conv.is_owned = ptr_is_owned(ret);
6336         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
6337         if (get_jenv_res == JNI_EDETACHED) {
6338                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6339         }
6340         return ret_conv;
6341 }
6342 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
6343         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6344         JNIEnv *env;
6345         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6346         if (get_jenv_res == JNI_EDETACHED) {
6347                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6348         } else {
6349                 DO_ASSERT(get_jenv_res == JNI_OK);
6350         }
6351         jboolean inbound_conv = inbound;
6352         int64_t channel_value_satoshis_conv = channel_value_satoshis;
6353         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6354         CHECK(obj != NULL);
6355         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound_conv, channel_value_satoshis_conv);
6356         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6357                 (*env)->ExceptionDescribe(env);
6358                 (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
6359         }
6360         void* ret_ptr = untag_ptr(ret);
6361         CHECK_ACCESS(ret_ptr);
6362         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
6363         FREE(untag_ptr(ret));
6364         if (get_jenv_res == JNI_EDETACHED) {
6365                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6366         }
6367         return ret_conv;
6368 }
6369 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
6370         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6371         JNIEnv *env;
6372         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6373         if (get_jenv_res == JNI_EDETACHED) {
6374                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6375         } else {
6376                 DO_ASSERT(get_jenv_res == JNI_OK);
6377         }
6378         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6379         CHECK(obj != NULL);
6380         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
6381         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6382                 (*env)->ExceptionDescribe(env);
6383                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
6384         }
6385         LDKThirtyTwoBytes ret_ref;
6386         CHECK((*env)->GetArrayLength(env, ret) == 32);
6387         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
6388         if (get_jenv_res == JNI_EDETACHED) {
6389                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6390         }
6391         return ret_ref;
6392 }
6393 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
6394         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6395         JNIEnv *env;
6396         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6397         if (get_jenv_res == JNI_EDETACHED) {
6398                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6399         } else {
6400                 DO_ASSERT(get_jenv_res == JNI_OK);
6401         }
6402         LDKu8slice reader_var = reader;
6403         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
6404         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
6405         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6406         CHECK(obj != NULL);
6407         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
6408         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6409                 (*env)->ExceptionDescribe(env);
6410                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
6411         }
6412         void* ret_ptr = untag_ptr(ret);
6413         CHECK_ACCESS(ret_ptr);
6414         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
6415         FREE(untag_ptr(ret));
6416         if (get_jenv_res == JNI_EDETACHED) {
6417                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6418         }
6419         return ret_conv;
6420 }
6421 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_u5Z invoice_data, LDKRecipient receipient) {
6422         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6423         JNIEnv *env;
6424         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6425         if (get_jenv_res == JNI_EDETACHED) {
6426                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6427         } else {
6428                 DO_ASSERT(get_jenv_res == JNI_OK);
6429         }
6430         LDKu8slice hrp_bytes_var = hrp_bytes;
6431         int8_tArray hrp_bytes_arr = (*env)->NewByteArray(env, hrp_bytes_var.datalen);
6432         (*env)->SetByteArrayRegion(env, hrp_bytes_arr, 0, hrp_bytes_var.datalen, hrp_bytes_var.data);
6433         LDKCVec_u5Z invoice_data_var = invoice_data;
6434         jobjectArray invoice_data_arr = NULL;
6435         invoice_data_arr = (*env)->NewByteArray(env, invoice_data_var.datalen);
6436         int8_t *invoice_data_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, invoice_data_arr, NULL);
6437         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
6438                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
6439                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
6440         }
6441         (*env)->ReleasePrimitiveArrayCritical(env, invoice_data_arr, invoice_data_arr_ptr, 0);
6442         FREE(invoice_data_var.data);
6443         jclass receipient_conv = LDKRecipient_to_java(env, receipient);
6444         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6445         CHECK(obj != NULL);
6446         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, hrp_bytes_arr, invoice_data_arr, receipient_conv);
6447         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6448                 (*env)->ExceptionDescribe(env);
6449                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
6450         }
6451         void* ret_ptr = untag_ptr(ret);
6452         CHECK_ACCESS(ret_ptr);
6453         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
6454         FREE(untag_ptr(ret));
6455         if (get_jenv_res == JNI_EDETACHED) {
6456                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6457         }
6458         return ret_conv;
6459 }
6460 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
6461         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6462         JNIEnv *env;
6463         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6464         if (get_jenv_res == JNI_EDETACHED) {
6465                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6466         } else {
6467                 DO_ASSERT(get_jenv_res == JNI_OK);
6468         }
6469         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6470         CHECK(obj != NULL);
6471         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_inbound_payment_key_material_meth);
6472         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6473                 (*env)->ExceptionDescribe(env);
6474                 (*env)->FatalError(env, "A call to get_inbound_payment_key_material in LDKKeysInterface from rust threw an exception.");
6475         }
6476         LDKThirtyTwoBytes ret_ref;
6477         CHECK((*env)->GetArrayLength(env, ret) == 32);
6478         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
6479         if (get_jenv_res == JNI_EDETACHED) {
6480                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6481         }
6482         return ret_ref;
6483 }
6484 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
6485         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
6486         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6487 }
6488 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
6489         jclass c = (*env)->GetObjectClass(env, o);
6490         CHECK(c != NULL);
6491         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
6492         atomic_init(&calls->refcnt, 1);
6493         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6494         calls->o = (*env)->NewWeakGlobalRef(env, o);
6495         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "(Lorg/ldk/enums/Recipient;)J");
6496         CHECK(calls->get_node_secret_meth != NULL);
6497         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
6498         CHECK(calls->get_destination_script_meth != NULL);
6499         calls->get_shutdown_scriptpubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_scriptpubkey", "()J");
6500         CHECK(calls->get_shutdown_scriptpubkey_meth != NULL);
6501         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
6502         CHECK(calls->get_channel_signer_meth != NULL);
6503         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
6504         CHECK(calls->get_secure_random_bytes_meth != NULL);
6505         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
6506         CHECK(calls->read_chan_signer_meth != NULL);
6507         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B[BLorg/ldk/enums/Recipient;)J");
6508         CHECK(calls->sign_invoice_meth != NULL);
6509         calls->get_inbound_payment_key_material_meth = (*env)->GetMethodID(env, c, "get_inbound_payment_key_material", "()[B");
6510         CHECK(calls->get_inbound_payment_key_material_meth != NULL);
6511
6512         LDKKeysInterface ret = {
6513                 .this_arg = (void*) calls,
6514                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
6515                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
6516                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
6517                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
6518                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
6519                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
6520                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
6521                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
6522                 .free = LDKKeysInterface_JCalls_free,
6523         };
6524         return ret;
6525 }
6526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
6527         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
6528         *res_ptr = LDKKeysInterface_init(env, clz, o);
6529         return tag_ptr(res_ptr, true);
6530 }
6531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg, jclass recipient) {
6532         void* this_arg_ptr = untag_ptr(this_arg);
6533         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6534         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6535         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
6536         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
6537         *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
6538         return tag_ptr(ret_conv, true);
6539 }
6540
6541 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
6542         void* this_arg_ptr = untag_ptr(this_arg);
6543         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6544         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6545         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
6546         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6547         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6548         CVec_u8Z_free(ret_var);
6549         return ret_arr;
6550 }
6551
6552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
6553         void* this_arg_ptr = untag_ptr(this_arg);
6554         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6555         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6556         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
6557         int64_t ret_ref = 0;
6558         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6559         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6560         return ret_ref;
6561 }
6562
6563 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) {
6564         void* this_arg_ptr = untag_ptr(this_arg);
6565         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6566         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6567         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
6568         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
6569         return tag_ptr(ret_ret, true);
6570 }
6571
6572 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
6573         void* this_arg_ptr = untag_ptr(this_arg);
6574         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6575         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6576         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6577         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
6578         return ret_arr;
6579 }
6580
6581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
6582         void* this_arg_ptr = untag_ptr(this_arg);
6583         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6584         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6585         LDKu8slice reader_ref;
6586         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
6587         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
6588         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
6589         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
6590         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
6591         return tag_ptr(ret_conv, true);
6592 }
6593
6594 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) {
6595         void* this_arg_ptr = untag_ptr(this_arg);
6596         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6597         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6598         LDKu8slice hrp_bytes_ref;
6599         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
6600         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
6601         LDKCVec_u5Z invoice_data_constr;
6602         invoice_data_constr.datalen = (*env)->GetArrayLength(env, invoice_data);
6603         if (invoice_data_constr.datalen > 0)
6604                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
6605         else
6606                 invoice_data_constr.data = NULL;
6607         int8_t* invoice_data_vals = (*env)->GetByteArrayElements (env, invoice_data, NULL);
6608         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
6609                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
6610                 
6611                 invoice_data_constr.data[h] = (LDKu5){ ._0 = invoice_data_conv_7 };
6612         }
6613         (*env)->ReleaseByteArrayElements(env, invoice_data, invoice_data_vals, 0);
6614         LDKRecipient receipient_conv = LDKRecipient_from_java(env, receipient);
6615         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
6616         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
6617         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
6618         return tag_ptr(ret_conv, true);
6619 }
6620
6621 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1inbound_1payment_1key_1material(JNIEnv *env, jclass clz, int64_t this_arg) {
6622         void* this_arg_ptr = untag_ptr(this_arg);
6623         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6624         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6625         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6626         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data);
6627         return ret_arr;
6628 }
6629
6630 typedef struct LDKFeeEstimator_JCalls {
6631         atomic_size_t refcnt;
6632         JavaVM *vm;
6633         jweak o;
6634         jmethodID get_est_sat_per_1000_weight_meth;
6635 } LDKFeeEstimator_JCalls;
6636 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
6637         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
6638         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6639                 JNIEnv *env;
6640                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6641                 if (get_jenv_res == JNI_EDETACHED) {
6642                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6643                 } else {
6644                         DO_ASSERT(get_jenv_res == JNI_OK);
6645                 }
6646                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6647                 if (get_jenv_res == JNI_EDETACHED) {
6648                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6649                 }
6650                 FREE(j_calls);
6651         }
6652 }
6653 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
6654         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
6655         JNIEnv *env;
6656         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6657         if (get_jenv_res == JNI_EDETACHED) {
6658                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6659         } else {
6660                 DO_ASSERT(get_jenv_res == JNI_OK);
6661         }
6662         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
6663         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6664         CHECK(obj != NULL);
6665         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
6666         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6667                 (*env)->ExceptionDescribe(env);
6668                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
6669         }
6670         if (get_jenv_res == JNI_EDETACHED) {
6671                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6672         }
6673         return ret;
6674 }
6675 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
6676         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
6677         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6678 }
6679 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
6680         jclass c = (*env)->GetObjectClass(env, o);
6681         CHECK(c != NULL);
6682         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
6683         atomic_init(&calls->refcnt, 1);
6684         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6685         calls->o = (*env)->NewWeakGlobalRef(env, o);
6686         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
6687         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
6688
6689         LDKFeeEstimator ret = {
6690                 .this_arg = (void*) calls,
6691                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
6692                 .free = LDKFeeEstimator_JCalls_free,
6693         };
6694         return ret;
6695 }
6696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
6697         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
6698         *res_ptr = LDKFeeEstimator_init(env, clz, o);
6699         return tag_ptr(res_ptr, true);
6700 }
6701 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) {
6702         void* this_arg_ptr = untag_ptr(this_arg);
6703         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6704         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
6705         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
6706         int32_t ret_conv = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
6707         return ret_conv;
6708 }
6709
6710 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
6711         return ThirtyTwoBytes_clone(&owner->a);
6712 }
6713 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6714         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)untag_ptr(owner);
6715         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6716         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data);
6717         return ret_arr;
6718 }
6719
6720 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
6721         return &owner->b;
6722 }
6723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6724         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)untag_ptr(owner);
6725         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
6726         int64_t ret_ref = 0;
6727         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6728         ret_ref = tag_ptr(ret_var.inner, false);
6729         return ret_ref;
6730 }
6731
6732 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
6733 CHECK(owner->result_ok);
6734         return &*owner->contents.result;
6735 }
6736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6737         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(owner);
6738         int64_t ret_ret = tag_ptr(CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv), false);
6739         return ret_ret;
6740 }
6741
6742 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
6743 CHECK(!owner->result_ok);
6744         return DecodeError_clone(&*owner->contents.err);
6745 }
6746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6747         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(owner);
6748         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
6749         int64_t ret_ref = 0;
6750         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6751         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6752         return ret_ref;
6753 }
6754
6755 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
6756 CHECK(owner->result_ok);
6757         return ChannelConfig_clone(&*owner->contents.result);
6758 }
6759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6760         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(owner);
6761         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
6762         int64_t ret_ref = 0;
6763         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6764         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6765         return ret_ref;
6766 }
6767
6768 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
6769 CHECK(!owner->result_ok);
6770         return DecodeError_clone(&*owner->contents.err);
6771 }
6772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6773         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(owner);
6774         LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
6775         int64_t ret_ref = 0;
6776         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6777         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6778         return ret_ref;
6779 }
6780
6781 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
6782 CHECK(owner->result_ok);
6783         return OutPoint_clone(&*owner->contents.result);
6784 }
6785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6786         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(owner);
6787         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
6788         int64_t ret_ref = 0;
6789         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6790         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6791         return ret_ref;
6792 }
6793
6794 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
6795 CHECK(!owner->result_ok);
6796         return DecodeError_clone(&*owner->contents.err);
6797 }
6798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6799         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(owner);
6800         LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
6801         int64_t ret_ref = 0;
6802         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6803         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6804         return ret_ref;
6805 }
6806
6807 typedef struct LDKType_JCalls {
6808         atomic_size_t refcnt;
6809         JavaVM *vm;
6810         jweak o;
6811         jmethodID type_id_meth;
6812         jmethodID debug_str_meth;
6813         jmethodID write_meth;
6814 } LDKType_JCalls;
6815 static void LDKType_JCalls_free(void* this_arg) {
6816         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
6817         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6818                 JNIEnv *env;
6819                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6820                 if (get_jenv_res == JNI_EDETACHED) {
6821                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6822                 } else {
6823                         DO_ASSERT(get_jenv_res == JNI_OK);
6824                 }
6825                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6826                 if (get_jenv_res == JNI_EDETACHED) {
6827                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6828                 }
6829                 FREE(j_calls);
6830         }
6831 }
6832 uint16_t type_id_LDKType_jcall(const void* this_arg) {
6833         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
6834         JNIEnv *env;
6835         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6836         if (get_jenv_res == JNI_EDETACHED) {
6837                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6838         } else {
6839                 DO_ASSERT(get_jenv_res == JNI_OK);
6840         }
6841         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6842         CHECK(obj != NULL);
6843         int16_t ret = (*env)->CallShortMethod(env, obj, j_calls->type_id_meth);
6844         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6845                 (*env)->ExceptionDescribe(env);
6846                 (*env)->FatalError(env, "A call to type_id in LDKType from rust threw an exception.");
6847         }
6848         if (get_jenv_res == JNI_EDETACHED) {
6849                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6850         }
6851         return ret;
6852 }
6853 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
6854         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
6855         JNIEnv *env;
6856         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6857         if (get_jenv_res == JNI_EDETACHED) {
6858                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6859         } else {
6860                 DO_ASSERT(get_jenv_res == JNI_OK);
6861         }
6862         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6863         CHECK(obj != NULL);
6864         jstring ret = (*env)->CallObjectMethod(env, obj, j_calls->debug_str_meth);
6865         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6866                 (*env)->ExceptionDescribe(env);
6867                 (*env)->FatalError(env, "A call to debug_str in LDKType from rust threw an exception.");
6868         }
6869         LDKStr ret_conv = java_to_owned_str(env, ret);
6870         if (get_jenv_res == JNI_EDETACHED) {
6871                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6872         }
6873         return ret_conv;
6874 }
6875 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
6876         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
6877         JNIEnv *env;
6878         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6879         if (get_jenv_res == JNI_EDETACHED) {
6880                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6881         } else {
6882                 DO_ASSERT(get_jenv_res == JNI_OK);
6883         }
6884         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6885         CHECK(obj != NULL);
6886         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
6887         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6888                 (*env)->ExceptionDescribe(env);
6889                 (*env)->FatalError(env, "A call to write in LDKType from rust threw an exception.");
6890         }
6891         LDKCVec_u8Z ret_ref;
6892         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
6893         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
6894         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
6895         if (get_jenv_res == JNI_EDETACHED) {
6896                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6897         }
6898         return ret_ref;
6899 }
6900 static void LDKType_JCalls_cloned(LDKType* new_obj) {
6901         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
6902         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6903 }
6904 static inline LDKType LDKType_init (JNIEnv *env, jclass clz, jobject o) {
6905         jclass c = (*env)->GetObjectClass(env, o);
6906         CHECK(c != NULL);
6907         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
6908         atomic_init(&calls->refcnt, 1);
6909         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6910         calls->o = (*env)->NewWeakGlobalRef(env, o);
6911         calls->type_id_meth = (*env)->GetMethodID(env, c, "type_id", "()S");
6912         CHECK(calls->type_id_meth != NULL);
6913         calls->debug_str_meth = (*env)->GetMethodID(env, c, "debug_str", "()Ljava/lang/String;");
6914         CHECK(calls->debug_str_meth != NULL);
6915         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
6916         CHECK(calls->write_meth != NULL);
6917
6918         LDKType ret = {
6919                 .this_arg = (void*) calls,
6920                 .type_id = type_id_LDKType_jcall,
6921                 .debug_str = debug_str_LDKType_jcall,
6922                 .write = write_LDKType_jcall,
6923                 .cloned = LDKType_JCalls_cloned,
6924                 .free = LDKType_JCalls_free,
6925         };
6926         return ret;
6927 }
6928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, jclass clz, jobject o) {
6929         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
6930         *res_ptr = LDKType_init(env, clz, o);
6931         return tag_ptr(res_ptr, true);
6932 }
6933 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Type_1type_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
6934         void* this_arg_ptr = untag_ptr(this_arg);
6935         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6936         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
6937         int16_t ret_conv = (this_arg_conv->type_id)(this_arg_conv->this_arg);
6938         return ret_conv;
6939 }
6940
6941 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *env, jclass clz, int64_t this_arg) {
6942         void* this_arg_ptr = untag_ptr(this_arg);
6943         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6944         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
6945         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
6946         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
6947         Str_free(ret_str);
6948         return ret_conv;
6949 }
6950
6951 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Type_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
6952         void* this_arg_ptr = untag_ptr(this_arg);
6953         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6954         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
6955         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
6956         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6957         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6958         CVec_u8Z_free(ret_var);
6959         return ret_arr;
6960 }
6961
6962 static jclass LDKCOption_TypeZ_Some_class = NULL;
6963 static jmethodID LDKCOption_TypeZ_Some_meth = NULL;
6964 static jclass LDKCOption_TypeZ_None_class = NULL;
6965 static jmethodID LDKCOption_TypeZ_None_meth = NULL;
6966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init (JNIEnv *env, jclass clz) {
6967         LDKCOption_TypeZ_Some_class =
6968                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$Some"));
6969         CHECK(LDKCOption_TypeZ_Some_class != NULL);
6970         LDKCOption_TypeZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_Some_class, "<init>", "(J)V");
6971         CHECK(LDKCOption_TypeZ_Some_meth != NULL);
6972         LDKCOption_TypeZ_None_class =
6973                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$None"));
6974         CHECK(LDKCOption_TypeZ_None_class != NULL);
6975         LDKCOption_TypeZ_None_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_None_class, "<init>", "()V");
6976         CHECK(LDKCOption_TypeZ_None_meth != NULL);
6977 }
6978 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6979         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)untag_ptr(ptr);
6980         switch(obj->tag) {
6981                 case LDKCOption_TypeZ_Some: {
6982                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
6983                         *some_ret = Type_clone(&obj->some);
6984                         return (*env)->NewObject(env, LDKCOption_TypeZ_Some_class, LDKCOption_TypeZ_Some_meth, tag_ptr(some_ret, true));
6985                 }
6986                 case LDKCOption_TypeZ_None: {
6987                         return (*env)->NewObject(env, LDKCOption_TypeZ_None_class, LDKCOption_TypeZ_None_meth);
6988                 }
6989                 default: abort();
6990         }
6991 }
6992 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
6993 CHECK(owner->result_ok);
6994         return COption_TypeZ_clone(&*owner->contents.result);
6995 }
6996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6997         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(owner);
6998         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
6999         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
7000         int64_t ret_ref = tag_ptr(ret_copy, true);
7001         return ret_ref;
7002 }
7003
7004 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
7005 CHECK(!owner->result_ok);
7006         return DecodeError_clone(&*owner->contents.err);
7007 }
7008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7009         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(owner);
7010         LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
7011         int64_t ret_ref = 0;
7012         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7013         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7014         return ret_ref;
7015 }
7016
7017 static jclass LDKPaymentError_Invoice_class = NULL;
7018 static jmethodID LDKPaymentError_Invoice_meth = NULL;
7019 static jclass LDKPaymentError_Routing_class = NULL;
7020 static jmethodID LDKPaymentError_Routing_meth = NULL;
7021 static jclass LDKPaymentError_Sending_class = NULL;
7022 static jmethodID LDKPaymentError_Sending_meth = NULL;
7023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentError_init (JNIEnv *env, jclass clz) {
7024         LDKPaymentError_Invoice_class =
7025                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Invoice"));
7026         CHECK(LDKPaymentError_Invoice_class != NULL);
7027         LDKPaymentError_Invoice_meth = (*env)->GetMethodID(env, LDKPaymentError_Invoice_class, "<init>", "(Ljava/lang/String;)V");
7028         CHECK(LDKPaymentError_Invoice_meth != NULL);
7029         LDKPaymentError_Routing_class =
7030                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Routing"));
7031         CHECK(LDKPaymentError_Routing_class != NULL);
7032         LDKPaymentError_Routing_meth = (*env)->GetMethodID(env, LDKPaymentError_Routing_class, "<init>", "(J)V");
7033         CHECK(LDKPaymentError_Routing_meth != NULL);
7034         LDKPaymentError_Sending_class =
7035                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Sending"));
7036         CHECK(LDKPaymentError_Sending_class != NULL);
7037         LDKPaymentError_Sending_meth = (*env)->GetMethodID(env, LDKPaymentError_Sending_class, "<init>", "(J)V");
7038         CHECK(LDKPaymentError_Sending_meth != NULL);
7039 }
7040 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7041         LDKPaymentError *obj = (LDKPaymentError*)untag_ptr(ptr);
7042         switch(obj->tag) {
7043                 case LDKPaymentError_Invoice: {
7044                         LDKStr invoice_str = obj->invoice;
7045                         jstring invoice_conv = str_ref_to_java(env, invoice_str.chars, invoice_str.len);
7046                         return (*env)->NewObject(env, LDKPaymentError_Invoice_class, LDKPaymentError_Invoice_meth, invoice_conv);
7047                 }
7048                 case LDKPaymentError_Routing: {
7049                         LDKLightningError routing_var = obj->routing;
7050                         int64_t routing_ref = 0;
7051                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
7052                         routing_ref = tag_ptr(routing_var.inner, false);
7053                         return (*env)->NewObject(env, LDKPaymentError_Routing_class, LDKPaymentError_Routing_meth, routing_ref);
7054                 }
7055                 case LDKPaymentError_Sending: {
7056                         int64_t sending_ref = tag_ptr(&obj->sending, false);
7057                         return (*env)->NewObject(env, LDKPaymentError_Sending_class, LDKPaymentError_Sending_meth, sending_ref);
7058                 }
7059                 default: abort();
7060         }
7061 }
7062 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
7063 CHECK(owner->result_ok);
7064         return ThirtyTwoBytes_clone(&*owner->contents.result);
7065 }
7066 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7067         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(owner);
7068         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7069         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data);
7070         return ret_arr;
7071 }
7072
7073 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
7074 CHECK(!owner->result_ok);
7075         return PaymentError_clone(&*owner->contents.err);
7076 }
7077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7078         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(owner);
7079         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
7080         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
7081         int64_t ret_ref = tag_ptr(ret_copy, true);
7082         return ret_ref;
7083 }
7084
7085 static jclass LDKParseError_Bech32Error_class = NULL;
7086 static jmethodID LDKParseError_Bech32Error_meth = NULL;
7087 static jclass LDKParseError_ParseAmountError_class = NULL;
7088 static jmethodID LDKParseError_ParseAmountError_meth = NULL;
7089 static jclass LDKParseError_MalformedSignature_class = NULL;
7090 static jmethodID LDKParseError_MalformedSignature_meth = NULL;
7091 static jclass LDKParseError_BadPrefix_class = NULL;
7092 static jmethodID LDKParseError_BadPrefix_meth = NULL;
7093 static jclass LDKParseError_UnknownCurrency_class = NULL;
7094 static jmethodID LDKParseError_UnknownCurrency_meth = NULL;
7095 static jclass LDKParseError_UnknownSiPrefix_class = NULL;
7096 static jmethodID LDKParseError_UnknownSiPrefix_meth = NULL;
7097 static jclass LDKParseError_MalformedHRP_class = NULL;
7098 static jmethodID LDKParseError_MalformedHRP_meth = NULL;
7099 static jclass LDKParseError_TooShortDataPart_class = NULL;
7100 static jmethodID LDKParseError_TooShortDataPart_meth = NULL;
7101 static jclass LDKParseError_UnexpectedEndOfTaggedFields_class = NULL;
7102 static jmethodID LDKParseError_UnexpectedEndOfTaggedFields_meth = NULL;
7103 static jclass LDKParseError_DescriptionDecodeError_class = NULL;
7104 static jmethodID LDKParseError_DescriptionDecodeError_meth = NULL;
7105 static jclass LDKParseError_PaddingError_class = NULL;
7106 static jmethodID LDKParseError_PaddingError_meth = NULL;
7107 static jclass LDKParseError_IntegerOverflowError_class = NULL;
7108 static jmethodID LDKParseError_IntegerOverflowError_meth = NULL;
7109 static jclass LDKParseError_InvalidSegWitProgramLength_class = NULL;
7110 static jmethodID LDKParseError_InvalidSegWitProgramLength_meth = NULL;
7111 static jclass LDKParseError_InvalidPubKeyHashLength_class = NULL;
7112 static jmethodID LDKParseError_InvalidPubKeyHashLength_meth = NULL;
7113 static jclass LDKParseError_InvalidScriptHashLength_class = NULL;
7114 static jmethodID LDKParseError_InvalidScriptHashLength_meth = NULL;
7115 static jclass LDKParseError_InvalidRecoveryId_class = NULL;
7116 static jmethodID LDKParseError_InvalidRecoveryId_meth = NULL;
7117 static jclass LDKParseError_InvalidSliceLength_class = NULL;
7118 static jmethodID LDKParseError_InvalidSliceLength_meth = NULL;
7119 static jclass LDKParseError_Skip_class = NULL;
7120 static jmethodID LDKParseError_Skip_meth = NULL;
7121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseError_init (JNIEnv *env, jclass clz) {
7122         LDKParseError_Bech32Error_class =
7123                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Bech32Error"));
7124         CHECK(LDKParseError_Bech32Error_class != NULL);
7125         LDKParseError_Bech32Error_meth = (*env)->GetMethodID(env, LDKParseError_Bech32Error_class, "<init>", "(J)V");
7126         CHECK(LDKParseError_Bech32Error_meth != NULL);
7127         LDKParseError_ParseAmountError_class =
7128                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$ParseAmountError"));
7129         CHECK(LDKParseError_ParseAmountError_class != NULL);
7130         LDKParseError_ParseAmountError_meth = (*env)->GetMethodID(env, LDKParseError_ParseAmountError_class, "<init>", "(I)V");
7131         CHECK(LDKParseError_ParseAmountError_meth != NULL);
7132         LDKParseError_MalformedSignature_class =
7133                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedSignature"));
7134         CHECK(LDKParseError_MalformedSignature_class != NULL);
7135         LDKParseError_MalformedSignature_meth = (*env)->GetMethodID(env, LDKParseError_MalformedSignature_class, "<init>", "(Lorg/ldk/enums/Secp256k1Error;)V");
7136         CHECK(LDKParseError_MalformedSignature_meth != NULL);
7137         LDKParseError_BadPrefix_class =
7138                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$BadPrefix"));
7139         CHECK(LDKParseError_BadPrefix_class != NULL);
7140         LDKParseError_BadPrefix_meth = (*env)->GetMethodID(env, LDKParseError_BadPrefix_class, "<init>", "()V");
7141         CHECK(LDKParseError_BadPrefix_meth != NULL);
7142         LDKParseError_UnknownCurrency_class =
7143                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownCurrency"));
7144         CHECK(LDKParseError_UnknownCurrency_class != NULL);
7145         LDKParseError_UnknownCurrency_meth = (*env)->GetMethodID(env, LDKParseError_UnknownCurrency_class, "<init>", "()V");
7146         CHECK(LDKParseError_UnknownCurrency_meth != NULL);
7147         LDKParseError_UnknownSiPrefix_class =
7148                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownSiPrefix"));
7149         CHECK(LDKParseError_UnknownSiPrefix_class != NULL);
7150         LDKParseError_UnknownSiPrefix_meth = (*env)->GetMethodID(env, LDKParseError_UnknownSiPrefix_class, "<init>", "()V");
7151         CHECK(LDKParseError_UnknownSiPrefix_meth != NULL);
7152         LDKParseError_MalformedHRP_class =
7153                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedHRP"));
7154         CHECK(LDKParseError_MalformedHRP_class != NULL);
7155         LDKParseError_MalformedHRP_meth = (*env)->GetMethodID(env, LDKParseError_MalformedHRP_class, "<init>", "()V");
7156         CHECK(LDKParseError_MalformedHRP_meth != NULL);
7157         LDKParseError_TooShortDataPart_class =
7158                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$TooShortDataPart"));
7159         CHECK(LDKParseError_TooShortDataPart_class != NULL);
7160         LDKParseError_TooShortDataPart_meth = (*env)->GetMethodID(env, LDKParseError_TooShortDataPart_class, "<init>", "()V");
7161         CHECK(LDKParseError_TooShortDataPart_meth != NULL);
7162         LDKParseError_UnexpectedEndOfTaggedFields_class =
7163                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnexpectedEndOfTaggedFields"));
7164         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_class != NULL);
7165         LDKParseError_UnexpectedEndOfTaggedFields_meth = (*env)->GetMethodID(env, LDKParseError_UnexpectedEndOfTaggedFields_class, "<init>", "()V");
7166         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_meth != NULL);
7167         LDKParseError_DescriptionDecodeError_class =
7168                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$DescriptionDecodeError"));
7169         CHECK(LDKParseError_DescriptionDecodeError_class != NULL);
7170         LDKParseError_DescriptionDecodeError_meth = (*env)->GetMethodID(env, LDKParseError_DescriptionDecodeError_class, "<init>", "(I)V");
7171         CHECK(LDKParseError_DescriptionDecodeError_meth != NULL);
7172         LDKParseError_PaddingError_class =
7173                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$PaddingError"));
7174         CHECK(LDKParseError_PaddingError_class != NULL);
7175         LDKParseError_PaddingError_meth = (*env)->GetMethodID(env, LDKParseError_PaddingError_class, "<init>", "()V");
7176         CHECK(LDKParseError_PaddingError_meth != NULL);
7177         LDKParseError_IntegerOverflowError_class =
7178                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$IntegerOverflowError"));
7179         CHECK(LDKParseError_IntegerOverflowError_class != NULL);
7180         LDKParseError_IntegerOverflowError_meth = (*env)->GetMethodID(env, LDKParseError_IntegerOverflowError_class, "<init>", "()V");
7181         CHECK(LDKParseError_IntegerOverflowError_meth != NULL);
7182         LDKParseError_InvalidSegWitProgramLength_class =
7183                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSegWitProgramLength"));
7184         CHECK(LDKParseError_InvalidSegWitProgramLength_class != NULL);
7185         LDKParseError_InvalidSegWitProgramLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSegWitProgramLength_class, "<init>", "()V");
7186         CHECK(LDKParseError_InvalidSegWitProgramLength_meth != NULL);
7187         LDKParseError_InvalidPubKeyHashLength_class =
7188                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidPubKeyHashLength"));
7189         CHECK(LDKParseError_InvalidPubKeyHashLength_class != NULL);
7190         LDKParseError_InvalidPubKeyHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidPubKeyHashLength_class, "<init>", "()V");
7191         CHECK(LDKParseError_InvalidPubKeyHashLength_meth != NULL);
7192         LDKParseError_InvalidScriptHashLength_class =
7193                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidScriptHashLength"));
7194         CHECK(LDKParseError_InvalidScriptHashLength_class != NULL);
7195         LDKParseError_InvalidScriptHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidScriptHashLength_class, "<init>", "()V");
7196         CHECK(LDKParseError_InvalidScriptHashLength_meth != NULL);
7197         LDKParseError_InvalidRecoveryId_class =
7198                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidRecoveryId"));
7199         CHECK(LDKParseError_InvalidRecoveryId_class != NULL);
7200         LDKParseError_InvalidRecoveryId_meth = (*env)->GetMethodID(env, LDKParseError_InvalidRecoveryId_class, "<init>", "()V");
7201         CHECK(LDKParseError_InvalidRecoveryId_meth != NULL);
7202         LDKParseError_InvalidSliceLength_class =
7203                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSliceLength"));
7204         CHECK(LDKParseError_InvalidSliceLength_class != NULL);
7205         LDKParseError_InvalidSliceLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSliceLength_class, "<init>", "(Ljava/lang/String;)V");
7206         CHECK(LDKParseError_InvalidSliceLength_meth != NULL);
7207         LDKParseError_Skip_class =
7208                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Skip"));
7209         CHECK(LDKParseError_Skip_class != NULL);
7210         LDKParseError_Skip_meth = (*env)->GetMethodID(env, LDKParseError_Skip_class, "<init>", "()V");
7211         CHECK(LDKParseError_Skip_meth != NULL);
7212 }
7213 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7214         LDKParseError *obj = (LDKParseError*)untag_ptr(ptr);
7215         switch(obj->tag) {
7216                 case LDKParseError_Bech32Error: {
7217                         int64_t bech32_error_ref = tag_ptr(&obj->bech32_error, false);
7218                         return (*env)->NewObject(env, LDKParseError_Bech32Error_class, LDKParseError_Bech32Error_meth, bech32_error_ref);
7219                 }
7220                 case LDKParseError_ParseAmountError: {
7221                         /*obj->parse_amount_error*/
7222                         return (*env)->NewObject(env, LDKParseError_ParseAmountError_class, LDKParseError_ParseAmountError_meth, 0);
7223                 }
7224                 case LDKParseError_MalformedSignature: {
7225                         jclass malformed_signature_conv = LDKSecp256k1Error_to_java(env, obj->malformed_signature);
7226                         return (*env)->NewObject(env, LDKParseError_MalformedSignature_class, LDKParseError_MalformedSignature_meth, malformed_signature_conv);
7227                 }
7228                 case LDKParseError_BadPrefix: {
7229                         return (*env)->NewObject(env, LDKParseError_BadPrefix_class, LDKParseError_BadPrefix_meth);
7230                 }
7231                 case LDKParseError_UnknownCurrency: {
7232                         return (*env)->NewObject(env, LDKParseError_UnknownCurrency_class, LDKParseError_UnknownCurrency_meth);
7233                 }
7234                 case LDKParseError_UnknownSiPrefix: {
7235                         return (*env)->NewObject(env, LDKParseError_UnknownSiPrefix_class, LDKParseError_UnknownSiPrefix_meth);
7236                 }
7237                 case LDKParseError_MalformedHRP: {
7238                         return (*env)->NewObject(env, LDKParseError_MalformedHRP_class, LDKParseError_MalformedHRP_meth);
7239                 }
7240                 case LDKParseError_TooShortDataPart: {
7241                         return (*env)->NewObject(env, LDKParseError_TooShortDataPart_class, LDKParseError_TooShortDataPart_meth);
7242                 }
7243                 case LDKParseError_UnexpectedEndOfTaggedFields: {
7244                         return (*env)->NewObject(env, LDKParseError_UnexpectedEndOfTaggedFields_class, LDKParseError_UnexpectedEndOfTaggedFields_meth);
7245                 }
7246                 case LDKParseError_DescriptionDecodeError: {
7247                         /*obj->description_decode_error*/
7248                         return (*env)->NewObject(env, LDKParseError_DescriptionDecodeError_class, LDKParseError_DescriptionDecodeError_meth, 0);
7249                 }
7250                 case LDKParseError_PaddingError: {
7251                         return (*env)->NewObject(env, LDKParseError_PaddingError_class, LDKParseError_PaddingError_meth);
7252                 }
7253                 case LDKParseError_IntegerOverflowError: {
7254                         return (*env)->NewObject(env, LDKParseError_IntegerOverflowError_class, LDKParseError_IntegerOverflowError_meth);
7255                 }
7256                 case LDKParseError_InvalidSegWitProgramLength: {
7257                         return (*env)->NewObject(env, LDKParseError_InvalidSegWitProgramLength_class, LDKParseError_InvalidSegWitProgramLength_meth);
7258                 }
7259                 case LDKParseError_InvalidPubKeyHashLength: {
7260                         return (*env)->NewObject(env, LDKParseError_InvalidPubKeyHashLength_class, LDKParseError_InvalidPubKeyHashLength_meth);
7261                 }
7262                 case LDKParseError_InvalidScriptHashLength: {
7263                         return (*env)->NewObject(env, LDKParseError_InvalidScriptHashLength_class, LDKParseError_InvalidScriptHashLength_meth);
7264                 }
7265                 case LDKParseError_InvalidRecoveryId: {
7266                         return (*env)->NewObject(env, LDKParseError_InvalidRecoveryId_class, LDKParseError_InvalidRecoveryId_meth);
7267                 }
7268                 case LDKParseError_InvalidSliceLength: {
7269                         LDKStr invalid_slice_length_str = obj->invalid_slice_length;
7270                         jstring invalid_slice_length_conv = str_ref_to_java(env, invalid_slice_length_str.chars, invalid_slice_length_str.len);
7271                         return (*env)->NewObject(env, LDKParseError_InvalidSliceLength_class, LDKParseError_InvalidSliceLength_meth, invalid_slice_length_conv);
7272                 }
7273                 case LDKParseError_Skip: {
7274                         return (*env)->NewObject(env, LDKParseError_Skip_class, LDKParseError_Skip_meth);
7275                 }
7276                 default: abort();
7277         }
7278 }
7279 static inline enum LDKSiPrefix CResult_SiPrefixParseErrorZ_get_ok(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
7280 CHECK(owner->result_ok);
7281         return SiPrefix_clone(&*owner->contents.result);
7282 }
7283 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7284         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(owner);
7285         jclass ret_conv = LDKSiPrefix_to_java(env, CResult_SiPrefixParseErrorZ_get_ok(owner_conv));
7286         return ret_conv;
7287 }
7288
7289 static inline struct LDKParseError CResult_SiPrefixParseErrorZ_get_err(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
7290 CHECK(!owner->result_ok);
7291         return ParseError_clone(&*owner->contents.err);
7292 }
7293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7294         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(owner);
7295         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
7296         *ret_copy = CResult_SiPrefixParseErrorZ_get_err(owner_conv);
7297         int64_t ret_ref = tag_ptr(ret_copy, true);
7298         return ret_ref;
7299 }
7300
7301 static jclass LDKParseOrSemanticError_ParseError_class = NULL;
7302 static jmethodID LDKParseOrSemanticError_ParseError_meth = NULL;
7303 static jclass LDKParseOrSemanticError_SemanticError_class = NULL;
7304 static jmethodID LDKParseOrSemanticError_SemanticError_meth = NULL;
7305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseOrSemanticError_init (JNIEnv *env, jclass clz) {
7306         LDKParseOrSemanticError_ParseError_class =
7307                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$ParseError"));
7308         CHECK(LDKParseOrSemanticError_ParseError_class != NULL);
7309         LDKParseOrSemanticError_ParseError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_ParseError_class, "<init>", "(J)V");
7310         CHECK(LDKParseOrSemanticError_ParseError_meth != NULL);
7311         LDKParseOrSemanticError_SemanticError_class =
7312                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$SemanticError"));
7313         CHECK(LDKParseOrSemanticError_SemanticError_class != NULL);
7314         LDKParseOrSemanticError_SemanticError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_SemanticError_class, "<init>", "(Lorg/ldk/enums/SemanticError;)V");
7315         CHECK(LDKParseOrSemanticError_SemanticError_meth != NULL);
7316 }
7317 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseOrSemanticError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7318         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)untag_ptr(ptr);
7319         switch(obj->tag) {
7320                 case LDKParseOrSemanticError_ParseError: {
7321                         int64_t parse_error_ref = tag_ptr(&obj->parse_error, false);
7322                         return (*env)->NewObject(env, LDKParseOrSemanticError_ParseError_class, LDKParseOrSemanticError_ParseError_meth, parse_error_ref);
7323                 }
7324                 case LDKParseOrSemanticError_SemanticError: {
7325                         jclass semantic_error_conv = LDKSemanticError_to_java(env, obj->semantic_error);
7326                         return (*env)->NewObject(env, LDKParseOrSemanticError_SemanticError_class, LDKParseOrSemanticError_SemanticError_meth, semantic_error_conv);
7327                 }
7328                 default: abort();
7329         }
7330 }
7331 static inline struct LDKInvoice CResult_InvoiceParseOrSemanticErrorZ_get_ok(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
7332 CHECK(owner->result_ok);
7333         return Invoice_clone(&*owner->contents.result);
7334 }
7335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7336         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(owner);
7337         LDKInvoice ret_var = CResult_InvoiceParseOrSemanticErrorZ_get_ok(owner_conv);
7338         int64_t ret_ref = 0;
7339         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7340         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7341         return ret_ref;
7342 }
7343
7344 static inline struct LDKParseOrSemanticError CResult_InvoiceParseOrSemanticErrorZ_get_err(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
7345 CHECK(!owner->result_ok);
7346         return ParseOrSemanticError_clone(&*owner->contents.err);
7347 }
7348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7349         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(owner);
7350         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
7351         *ret_copy = CResult_InvoiceParseOrSemanticErrorZ_get_err(owner_conv);
7352         int64_t ret_ref = tag_ptr(ret_copy, true);
7353         return ret_ref;
7354 }
7355
7356 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceParseErrorZ_get_ok(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
7357 CHECK(owner->result_ok);
7358         return SignedRawInvoice_clone(&*owner->contents.result);
7359 }
7360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7361         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(owner);
7362         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceParseErrorZ_get_ok(owner_conv);
7363         int64_t ret_ref = 0;
7364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7365         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7366         return ret_ref;
7367 }
7368
7369 static inline struct LDKParseError CResult_SignedRawInvoiceParseErrorZ_get_err(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
7370 CHECK(!owner->result_ok);
7371         return ParseError_clone(&*owner->contents.err);
7372 }
7373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7374         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(owner);
7375         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
7376         *ret_copy = CResult_SignedRawInvoiceParseErrorZ_get_err(owner_conv);
7377         int64_t ret_ref = tag_ptr(ret_copy, true);
7378         return ret_ref;
7379 }
7380
7381 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
7382         return RawInvoice_clone(&owner->a);
7383 }
7384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7385         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(owner);
7386         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
7387         int64_t ret_ref = 0;
7388         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7389         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7390         return ret_ref;
7391 }
7392
7393 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
7394         return ThirtyTwoBytes_clone(&owner->b);
7395 }
7396 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7397         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(owner);
7398         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7399         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data);
7400         return ret_arr;
7401 }
7402
7403 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
7404         return InvoiceSignature_clone(&owner->c);
7405 }
7406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
7407         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(owner);
7408         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
7409         int64_t ret_ref = 0;
7410         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7411         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7412         return ret_ref;
7413 }
7414
7415 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
7416 CHECK(owner->result_ok);
7417         return PayeePubKey_clone(&*owner->contents.result);
7418 }
7419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7420         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(owner);
7421         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
7422         int64_t ret_ref = 0;
7423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7424         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7425         return ret_ref;
7426 }
7427
7428 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
7429 CHECK(!owner->result_ok);
7430         return *owner->contents.err;
7431 }
7432 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7433         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(owner);
7434         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PayeePubKeyErrorZ_get_err(owner_conv));
7435         return ret_conv;
7436 }
7437
7438 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
7439         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
7440         for (size_t i = 0; i < ret.datalen; i++) {
7441                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
7442         }
7443         return ret;
7444 }
7445 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
7446 CHECK(owner->result_ok);
7447         return PositiveTimestamp_clone(&*owner->contents.result);
7448 }
7449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7450         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(owner);
7451         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
7452         int64_t ret_ref = 0;
7453         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7454         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7455         return ret_ref;
7456 }
7457
7458 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
7459 CHECK(!owner->result_ok);
7460         return CreationError_clone(&*owner->contents.err);
7461 }
7462 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7463         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(owner);
7464         jclass ret_conv = LDKCreationError_to_java(env, CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
7465         return ret_conv;
7466 }
7467
7468 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
7469 CHECK(owner->result_ok);
7470         return *owner->contents.result;
7471 }
7472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7473         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(owner);
7474         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
7475 }
7476
7477 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
7478 CHECK(!owner->result_ok);
7479         return SemanticError_clone(&*owner->contents.err);
7480 }
7481 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7482         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(owner);
7483         jclass ret_conv = LDKSemanticError_to_java(env, CResult_NoneSemanticErrorZ_get_err(owner_conv));
7484         return ret_conv;
7485 }
7486
7487 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
7488 CHECK(owner->result_ok);
7489         return Invoice_clone(&*owner->contents.result);
7490 }
7491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7492         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(owner);
7493         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
7494         int64_t ret_ref = 0;
7495         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7496         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7497         return ret_ref;
7498 }
7499
7500 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
7501 CHECK(!owner->result_ok);
7502         return SemanticError_clone(&*owner->contents.err);
7503 }
7504 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7505         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(owner);
7506         jclass ret_conv = LDKSemanticError_to_java(env, CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
7507         return ret_conv;
7508 }
7509
7510 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
7511 CHECK(owner->result_ok);
7512         return Description_clone(&*owner->contents.result);
7513 }
7514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7515         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(owner);
7516         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
7517         int64_t ret_ref = 0;
7518         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7519         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7520         return ret_ref;
7521 }
7522
7523 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
7524 CHECK(!owner->result_ok);
7525         return CreationError_clone(&*owner->contents.err);
7526 }
7527 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7528         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(owner);
7529         jclass ret_conv = LDKCreationError_to_java(env, CResult_DescriptionCreationErrorZ_get_err(owner_conv));
7530         return ret_conv;
7531 }
7532
7533 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
7534 CHECK(owner->result_ok);
7535         return PrivateRoute_clone(&*owner->contents.result);
7536 }
7537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7538         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(owner);
7539         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
7540         int64_t ret_ref = 0;
7541         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7542         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7543         return ret_ref;
7544 }
7545
7546 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
7547 CHECK(!owner->result_ok);
7548         return CreationError_clone(&*owner->contents.err);
7549 }
7550 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7551         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(owner);
7552         jclass ret_conv = LDKCreationError_to_java(env, CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
7553         return ret_conv;
7554 }
7555
7556 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
7557 CHECK(owner->result_ok);
7558         return *owner->contents.result;
7559 }
7560 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7561         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)untag_ptr(owner);
7562         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
7563         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
7564         return ret_conv;
7565 }
7566
7567 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
7568 CHECK(!owner->result_ok);
7569         return *owner->contents.err;
7570 }
7571 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7572         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)untag_ptr(owner);
7573         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_StringErrorZ_get_err(owner_conv));
7574         return ret_conv;
7575 }
7576
7577 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
7578 CHECK(owner->result_ok);
7579         return ChannelMonitorUpdate_clone(&*owner->contents.result);
7580 }
7581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7582         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(owner);
7583         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
7584         int64_t ret_ref = 0;
7585         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7586         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7587         return ret_ref;
7588 }
7589
7590 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
7591 CHECK(!owner->result_ok);
7592         return DecodeError_clone(&*owner->contents.err);
7593 }
7594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7595         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(owner);
7596         LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
7597         int64_t ret_ref = 0;
7598         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7599         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7600         return ret_ref;
7601 }
7602
7603 static jclass LDKCOption_MonitorEventZ_Some_class = NULL;
7604 static jmethodID LDKCOption_MonitorEventZ_Some_meth = NULL;
7605 static jclass LDKCOption_MonitorEventZ_None_class = NULL;
7606 static jmethodID LDKCOption_MonitorEventZ_None_meth = NULL;
7607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1MonitorEventZ_init (JNIEnv *env, jclass clz) {
7608         LDKCOption_MonitorEventZ_Some_class =
7609                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$Some"));
7610         CHECK(LDKCOption_MonitorEventZ_Some_class != NULL);
7611         LDKCOption_MonitorEventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_Some_class, "<init>", "(J)V");
7612         CHECK(LDKCOption_MonitorEventZ_Some_meth != NULL);
7613         LDKCOption_MonitorEventZ_None_class =
7614                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$None"));
7615         CHECK(LDKCOption_MonitorEventZ_None_class != NULL);
7616         LDKCOption_MonitorEventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_None_class, "<init>", "()V");
7617         CHECK(LDKCOption_MonitorEventZ_None_meth != NULL);
7618 }
7619 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1MonitorEventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7620         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)untag_ptr(ptr);
7621         switch(obj->tag) {
7622                 case LDKCOption_MonitorEventZ_Some: {
7623                         int64_t some_ref = tag_ptr(&obj->some, false);
7624                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_Some_class, LDKCOption_MonitorEventZ_Some_meth, some_ref);
7625                 }
7626                 case LDKCOption_MonitorEventZ_None: {
7627                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_None_class, LDKCOption_MonitorEventZ_None_meth);
7628                 }
7629                 default: abort();
7630         }
7631 }
7632 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
7633 CHECK(owner->result_ok);
7634         return COption_MonitorEventZ_clone(&*owner->contents.result);
7635 }
7636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7637         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(owner);
7638         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
7639         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
7640         int64_t ret_ref = tag_ptr(ret_copy, true);
7641         return ret_ref;
7642 }
7643
7644 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
7645 CHECK(!owner->result_ok);
7646         return DecodeError_clone(&*owner->contents.err);
7647 }
7648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7649         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(owner);
7650         LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
7651         int64_t ret_ref = 0;
7652         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7653         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7654         return ret_ref;
7655 }
7656
7657 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
7658 CHECK(owner->result_ok);
7659         return HTLCUpdate_clone(&*owner->contents.result);
7660 }
7661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7662         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(owner);
7663         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
7664         int64_t ret_ref = 0;
7665         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7666         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7667         return ret_ref;
7668 }
7669
7670 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
7671 CHECK(!owner->result_ok);
7672         return DecodeError_clone(&*owner->contents.err);
7673 }
7674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7675         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(owner);
7676         LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
7677         int64_t ret_ref = 0;
7678         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7679         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7680         return ret_ref;
7681 }
7682
7683 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
7684         return OutPoint_clone(&owner->a);
7685 }
7686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7687         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(owner);
7688         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
7689         int64_t ret_ref = 0;
7690         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7691         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7692         return ret_ref;
7693 }
7694
7695 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
7696         return CVec_u8Z_clone(&owner->b);
7697 }
7698 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7699         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(owner);
7700         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
7701         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7702         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7703         CVec_u8Z_free(ret_var);
7704         return ret_arr;
7705 }
7706
7707 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
7708         return owner->a;
7709 }
7710 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7711         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(owner);
7712         int32_t ret_conv = C2Tuple_u32ScriptZ_get_a(owner_conv);
7713         return ret_conv;
7714 }
7715
7716 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
7717         return CVec_u8Z_clone(&owner->b);
7718 }
7719 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7720         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(owner);
7721         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
7722         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7723         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7724         CVec_u8Z_free(ret_var);
7725         return ret_arr;
7726 }
7727
7728 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
7729         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
7730         for (size_t i = 0; i < ret.datalen; i++) {
7731                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
7732         }
7733         return ret;
7734 }
7735 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
7736         return ThirtyTwoBytes_clone(&owner->a);
7737 }
7738 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7739         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(owner);
7740         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7741         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data);
7742         return ret_arr;
7743 }
7744
7745 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
7746         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
7747 }
7748 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7749         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(owner);
7750         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
7751         int64_tArray ret_arr = NULL;
7752         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
7753         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
7754         for (size_t v = 0; v < ret_var.datalen; v++) {
7755                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
7756                 *ret_conv_21_conv = ret_var.data[v];
7757                 ret_arr_ptr[v] = tag_ptr(ret_conv_21_conv, true);
7758         }
7759         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
7760         FREE(ret_var.data);
7761         return ret_arr;
7762 }
7763
7764 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
7765         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 };
7766         for (size_t i = 0; i < ret.datalen; i++) {
7767                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
7768         }
7769         return ret;
7770 }
7771 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
7772         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
7773         for (size_t i = 0; i < ret.datalen; i++) {
7774                 ret.data[i] = Event_clone(&orig->data[i]);
7775         }
7776         return ret;
7777 }
7778 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
7779         return owner->a;
7780 }
7781 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7782         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(owner);
7783         int32_t ret_conv = C2Tuple_u32TxOutZ_get_a(owner_conv);
7784         return ret_conv;
7785 }
7786
7787 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
7788         return TxOut_clone(&owner->b);
7789 }
7790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7791         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(owner);
7792         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
7793         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
7794         return tag_ptr(ret_ref, true);
7795 }
7796
7797 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
7798         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
7799         for (size_t i = 0; i < ret.datalen; i++) {
7800                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
7801         }
7802         return ret;
7803 }
7804 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
7805         return ThirtyTwoBytes_clone(&owner->a);
7806 }
7807 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7808         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(owner);
7809         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7810         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data);
7811         return ret_arr;
7812 }
7813
7814 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
7815         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
7816 }
7817 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7818         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(owner);
7819         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
7820         int64_tArray ret_arr = NULL;
7821         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
7822         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
7823         for (size_t u = 0; u < ret_var.datalen; u++) {
7824                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
7825                 *ret_conv_20_conv = ret_var.data[u];
7826                 ret_arr_ptr[u] = tag_ptr(ret_conv_20_conv, true);
7827         }
7828         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
7829         FREE(ret_var.data);
7830         return ret_arr;
7831 }
7832
7833 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
7834         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 };
7835         for (size_t i = 0; i < ret.datalen; i++) {
7836                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
7837         }
7838         return ret;
7839 }
7840 static jclass LDKBalance_ClaimableOnChannelClose_class = NULL;
7841 static jmethodID LDKBalance_ClaimableOnChannelClose_meth = NULL;
7842 static jclass LDKBalance_ClaimableAwaitingConfirmations_class = NULL;
7843 static jmethodID LDKBalance_ClaimableAwaitingConfirmations_meth = NULL;
7844 static jclass LDKBalance_ContentiousClaimable_class = NULL;
7845 static jmethodID LDKBalance_ContentiousClaimable_meth = NULL;
7846 static jclass LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class = NULL;
7847 static jmethodID LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = NULL;
7848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init (JNIEnv *env, jclass clz) {
7849         LDKBalance_ClaimableOnChannelClose_class =
7850                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableOnChannelClose"));
7851         CHECK(LDKBalance_ClaimableOnChannelClose_class != NULL);
7852         LDKBalance_ClaimableOnChannelClose_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableOnChannelClose_class, "<init>", "(J)V");
7853         CHECK(LDKBalance_ClaimableOnChannelClose_meth != NULL);
7854         LDKBalance_ClaimableAwaitingConfirmations_class =
7855                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableAwaitingConfirmations"));
7856         CHECK(LDKBalance_ClaimableAwaitingConfirmations_class != NULL);
7857         LDKBalance_ClaimableAwaitingConfirmations_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableAwaitingConfirmations_class, "<init>", "(JI)V");
7858         CHECK(LDKBalance_ClaimableAwaitingConfirmations_meth != NULL);
7859         LDKBalance_ContentiousClaimable_class =
7860                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ContentiousClaimable"));
7861         CHECK(LDKBalance_ContentiousClaimable_class != NULL);
7862         LDKBalance_ContentiousClaimable_meth = (*env)->GetMethodID(env, LDKBalance_ContentiousClaimable_class, "<init>", "(JI)V");
7863         CHECK(LDKBalance_ContentiousClaimable_meth != NULL);
7864         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class =
7865                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$MaybeClaimableHTLCAwaitingTimeout"));
7866         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class != NULL);
7867         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = (*env)->GetMethodID(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, "<init>", "(JI)V");
7868         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth != NULL);
7869 }
7870 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7871         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
7872         switch(obj->tag) {
7873                 case LDKBalance_ClaimableOnChannelClose: {
7874                         int64_t claimable_amount_satoshis_conv = obj->claimable_on_channel_close.claimable_amount_satoshis;
7875                         return (*env)->NewObject(env, LDKBalance_ClaimableOnChannelClose_class, LDKBalance_ClaimableOnChannelClose_meth, claimable_amount_satoshis_conv);
7876                 }
7877                 case LDKBalance_ClaimableAwaitingConfirmations: {
7878                         int64_t claimable_amount_satoshis_conv = obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
7879                         int32_t confirmation_height_conv = obj->claimable_awaiting_confirmations.confirmation_height;
7880                         return (*env)->NewObject(env, LDKBalance_ClaimableAwaitingConfirmations_class, LDKBalance_ClaimableAwaitingConfirmations_meth, claimable_amount_satoshis_conv, confirmation_height_conv);
7881                 }
7882                 case LDKBalance_ContentiousClaimable: {
7883                         int64_t claimable_amount_satoshis_conv = obj->contentious_claimable.claimable_amount_satoshis;
7884                         int32_t timeout_height_conv = obj->contentious_claimable.timeout_height;
7885                         return (*env)->NewObject(env, LDKBalance_ContentiousClaimable_class, LDKBalance_ContentiousClaimable_meth, claimable_amount_satoshis_conv, timeout_height_conv);
7886                 }
7887                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: {
7888                         int64_t claimable_amount_satoshis_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis;
7889                         int32_t claimable_height_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
7890                         return (*env)->NewObject(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth, claimable_amount_satoshis_conv, claimable_height_conv);
7891                 }
7892                 default: abort();
7893         }
7894 }
7895 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
7896         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
7897         for (size_t i = 0; i < ret.datalen; i++) {
7898                 ret.data[i] = Balance_clone(&orig->data[i]);
7899         }
7900         return ret;
7901 }
7902 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
7903 CHECK(owner->result_ok);
7904         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
7905 }
7906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7907         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(owner);
7908         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
7909         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
7910         return tag_ptr(ret_conv, true);
7911 }
7912
7913 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
7914 CHECK(!owner->result_ok);
7915         return DecodeError_clone(&*owner->contents.err);
7916 }
7917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7918         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(owner);
7919         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
7920         int64_t ret_ref = 0;
7921         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7922         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7923         return ret_ref;
7924 }
7925
7926 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
7927         return owner->a;
7928 }
7929 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7930         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(owner);
7931         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
7932         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form);
7933         return ret_arr;
7934 }
7935
7936 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
7937         return Type_clone(&owner->b);
7938 }
7939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7940         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(owner);
7941         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
7942         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
7943         return tag_ptr(ret_ret, true);
7944 }
7945
7946 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
7947         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
7948         for (size_t i = 0; i < ret.datalen; i++) {
7949                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
7950         }
7951         return ret;
7952 }
7953 static jclass LDKCOption_NetAddressZ_Some_class = NULL;
7954 static jmethodID LDKCOption_NetAddressZ_Some_meth = NULL;
7955 static jclass LDKCOption_NetAddressZ_None_class = NULL;
7956 static jmethodID LDKCOption_NetAddressZ_None_meth = NULL;
7957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetAddressZ_init (JNIEnv *env, jclass clz) {
7958         LDKCOption_NetAddressZ_Some_class =
7959                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$Some"));
7960         CHECK(LDKCOption_NetAddressZ_Some_class != NULL);
7961         LDKCOption_NetAddressZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_Some_class, "<init>", "(J)V");
7962         CHECK(LDKCOption_NetAddressZ_Some_meth != NULL);
7963         LDKCOption_NetAddressZ_None_class =
7964                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$None"));
7965         CHECK(LDKCOption_NetAddressZ_None_class != NULL);
7966         LDKCOption_NetAddressZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_None_class, "<init>", "()V");
7967         CHECK(LDKCOption_NetAddressZ_None_meth != NULL);
7968 }
7969 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetAddressZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7970         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)untag_ptr(ptr);
7971         switch(obj->tag) {
7972                 case LDKCOption_NetAddressZ_Some: {
7973                         int64_t some_ref = tag_ptr(&obj->some, false);
7974                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_Some_class, LDKCOption_NetAddressZ_Some_meth, some_ref);
7975                 }
7976                 case LDKCOption_NetAddressZ_None: {
7977                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_None_class, LDKCOption_NetAddressZ_None_meth);
7978                 }
7979                 default: abort();
7980         }
7981 }
7982 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
7983 CHECK(owner->result_ok);
7984         return CVec_u8Z_clone(&*owner->contents.result);
7985 }
7986 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7987         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(owner);
7988         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
7989         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7990         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7991         CVec_u8Z_free(ret_var);
7992         return ret_arr;
7993 }
7994
7995 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
7996 CHECK(!owner->result_ok);
7997         return PeerHandleError_clone(&*owner->contents.err);
7998 }
7999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8000         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(owner);
8001         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
8002         int64_t ret_ref = 0;
8003         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8004         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8005         return ret_ref;
8006 }
8007
8008 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
8009 CHECK(owner->result_ok);
8010         return *owner->contents.result;
8011 }
8012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8013         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(owner);
8014         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
8015 }
8016
8017 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
8018 CHECK(!owner->result_ok);
8019         return PeerHandleError_clone(&*owner->contents.err);
8020 }
8021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8022         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(owner);
8023         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
8024         int64_t ret_ref = 0;
8025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8026         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8027         return ret_ref;
8028 }
8029
8030 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
8031 CHECK(owner->result_ok);
8032         return *owner->contents.result;
8033 }
8034 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8035         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(owner);
8036         jboolean ret_conv = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
8037         return ret_conv;
8038 }
8039
8040 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
8041 CHECK(!owner->result_ok);
8042         return PeerHandleError_clone(&*owner->contents.err);
8043 }
8044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8045         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(owner);
8046         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
8047         int64_t ret_ref = 0;
8048         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8049         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8050         return ret_ref;
8051 }
8052
8053 static jclass LDKGraphSyncError_DecodeError_class = NULL;
8054 static jmethodID LDKGraphSyncError_DecodeError_meth = NULL;
8055 static jclass LDKGraphSyncError_LightningError_class = NULL;
8056 static jmethodID LDKGraphSyncError_LightningError_meth = NULL;
8057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKGraphSyncError_init (JNIEnv *env, jclass clz) {
8058         LDKGraphSyncError_DecodeError_class =
8059                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGraphSyncError$DecodeError"));
8060         CHECK(LDKGraphSyncError_DecodeError_class != NULL);
8061         LDKGraphSyncError_DecodeError_meth = (*env)->GetMethodID(env, LDKGraphSyncError_DecodeError_class, "<init>", "(J)V");
8062         CHECK(LDKGraphSyncError_DecodeError_meth != NULL);
8063         LDKGraphSyncError_LightningError_class =
8064                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGraphSyncError$LightningError"));
8065         CHECK(LDKGraphSyncError_LightningError_class != NULL);
8066         LDKGraphSyncError_LightningError_meth = (*env)->GetMethodID(env, LDKGraphSyncError_LightningError_class, "<init>", "(J)V");
8067         CHECK(LDKGraphSyncError_LightningError_meth != NULL);
8068 }
8069 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKGraphSyncError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8070         LDKGraphSyncError *obj = (LDKGraphSyncError*)untag_ptr(ptr);
8071         switch(obj->tag) {
8072                 case LDKGraphSyncError_DecodeError: {
8073                         LDKDecodeError decode_error_var = obj->decode_error;
8074                         int64_t decode_error_ref = 0;
8075                         CHECK_INNER_FIELD_ACCESS_OR_NULL(decode_error_var);
8076                         decode_error_ref = tag_ptr(decode_error_var.inner, false);
8077                         return (*env)->NewObject(env, LDKGraphSyncError_DecodeError_class, LDKGraphSyncError_DecodeError_meth, decode_error_ref);
8078                 }
8079                 case LDKGraphSyncError_LightningError: {
8080                         LDKLightningError lightning_error_var = obj->lightning_error;
8081                         int64_t lightning_error_ref = 0;
8082                         CHECK_INNER_FIELD_ACCESS_OR_NULL(lightning_error_var);
8083                         lightning_error_ref = tag_ptr(lightning_error_var.inner, false);
8084                         return (*env)->NewObject(env, LDKGraphSyncError_LightningError_class, LDKGraphSyncError_LightningError_meth, lightning_error_ref);
8085                 }
8086                 default: abort();
8087         }
8088 }
8089 static inline uint32_t CResult_u32GraphSyncErrorZ_get_ok(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
8090 CHECK(owner->result_ok);
8091         return *owner->contents.result;
8092 }
8093 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8094         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(owner);
8095         int32_t ret_conv = CResult_u32GraphSyncErrorZ_get_ok(owner_conv);
8096         return ret_conv;
8097 }
8098
8099 static inline struct LDKGraphSyncError CResult_u32GraphSyncErrorZ_get_err(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
8100 CHECK(!owner->result_ok);
8101         return GraphSyncError_clone(&*owner->contents.err);
8102 }
8103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8104         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(owner);
8105         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
8106         *ret_copy = CResult_u32GraphSyncErrorZ_get_err(owner_conv);
8107         int64_t ret_ref = tag_ptr(ret_copy, true);
8108         return ret_ref;
8109 }
8110
8111 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
8112 CHECK(owner->result_ok);
8113         return NetAddress_clone(&*owner->contents.result);
8114 }
8115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8116         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(owner);
8117         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
8118         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
8119         int64_t ret_ref = tag_ptr(ret_copy, true);
8120         return ret_ref;
8121 }
8122
8123 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
8124 CHECK(!owner->result_ok);
8125         return DecodeError_clone(&*owner->contents.err);
8126 }
8127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8128         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(owner);
8129         LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
8130         int64_t ret_ref = 0;
8131         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8132         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8133         return ret_ref;
8134 }
8135
8136 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
8137         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
8138         for (size_t i = 0; i < ret.datalen; i++) {
8139                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
8140         }
8141         return ret;
8142 }
8143 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
8144         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
8145         for (size_t i = 0; i < ret.datalen; i++) {
8146                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
8147         }
8148         return ret;
8149 }
8150 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
8151         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
8152         for (size_t i = 0; i < ret.datalen; i++) {
8153                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
8154         }
8155         return ret;
8156 }
8157 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
8158         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
8159         for (size_t i = 0; i < ret.datalen; i++) {
8160                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
8161         }
8162         return ret;
8163 }
8164 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
8165 CHECK(owner->result_ok);
8166         return AcceptChannel_clone(&*owner->contents.result);
8167 }
8168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8169         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(owner);
8170         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
8171         int64_t ret_ref = 0;
8172         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8173         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8174         return ret_ref;
8175 }
8176
8177 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
8178 CHECK(!owner->result_ok);
8179         return DecodeError_clone(&*owner->contents.err);
8180 }
8181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8182         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(owner);
8183         LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
8184         int64_t ret_ref = 0;
8185         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8186         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8187         return ret_ref;
8188 }
8189
8190 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
8191 CHECK(owner->result_ok);
8192         return AnnouncementSignatures_clone(&*owner->contents.result);
8193 }
8194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8195         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(owner);
8196         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
8197         int64_t ret_ref = 0;
8198         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8199         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8200         return ret_ref;
8201 }
8202
8203 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
8204 CHECK(!owner->result_ok);
8205         return DecodeError_clone(&*owner->contents.err);
8206 }
8207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8208         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(owner);
8209         LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
8210         int64_t ret_ref = 0;
8211         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8212         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8213         return ret_ref;
8214 }
8215
8216 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
8217 CHECK(owner->result_ok);
8218         return ChannelReestablish_clone(&*owner->contents.result);
8219 }
8220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8221         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(owner);
8222         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
8223         int64_t ret_ref = 0;
8224         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8225         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8226         return ret_ref;
8227 }
8228
8229 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
8230 CHECK(!owner->result_ok);
8231         return DecodeError_clone(&*owner->contents.err);
8232 }
8233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8234         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(owner);
8235         LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
8236         int64_t ret_ref = 0;
8237         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8238         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8239         return ret_ref;
8240 }
8241
8242 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
8243 CHECK(owner->result_ok);
8244         return ClosingSigned_clone(&*owner->contents.result);
8245 }
8246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8247         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(owner);
8248         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
8249         int64_t ret_ref = 0;
8250         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8251         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8252         return ret_ref;
8253 }
8254
8255 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
8256 CHECK(!owner->result_ok);
8257         return DecodeError_clone(&*owner->contents.err);
8258 }
8259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8260         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(owner);
8261         LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
8262         int64_t ret_ref = 0;
8263         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8264         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8265         return ret_ref;
8266 }
8267
8268 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
8269 CHECK(owner->result_ok);
8270         return ClosingSignedFeeRange_clone(&*owner->contents.result);
8271 }
8272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8273         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(owner);
8274         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
8275         int64_t ret_ref = 0;
8276         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8277         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8278         return ret_ref;
8279 }
8280
8281 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
8282 CHECK(!owner->result_ok);
8283         return DecodeError_clone(&*owner->contents.err);
8284 }
8285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8286         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(owner);
8287         LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
8288         int64_t ret_ref = 0;
8289         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8290         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8291         return ret_ref;
8292 }
8293
8294 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
8295 CHECK(owner->result_ok);
8296         return CommitmentSigned_clone(&*owner->contents.result);
8297 }
8298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8299         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(owner);
8300         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
8301         int64_t ret_ref = 0;
8302         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8303         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8304         return ret_ref;
8305 }
8306
8307 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
8308 CHECK(!owner->result_ok);
8309         return DecodeError_clone(&*owner->contents.err);
8310 }
8311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8312         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(owner);
8313         LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
8314         int64_t ret_ref = 0;
8315         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8316         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8317         return ret_ref;
8318 }
8319
8320 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
8321 CHECK(owner->result_ok);
8322         return FundingCreated_clone(&*owner->contents.result);
8323 }
8324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8325         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(owner);
8326         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
8327         int64_t ret_ref = 0;
8328         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8329         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8330         return ret_ref;
8331 }
8332
8333 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
8334 CHECK(!owner->result_ok);
8335         return DecodeError_clone(&*owner->contents.err);
8336 }
8337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8338         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(owner);
8339         LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
8340         int64_t ret_ref = 0;
8341         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8342         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8343         return ret_ref;
8344 }
8345
8346 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
8347 CHECK(owner->result_ok);
8348         return FundingSigned_clone(&*owner->contents.result);
8349 }
8350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8351         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(owner);
8352         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
8353         int64_t ret_ref = 0;
8354         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8355         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8356         return ret_ref;
8357 }
8358
8359 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
8360 CHECK(!owner->result_ok);
8361         return DecodeError_clone(&*owner->contents.err);
8362 }
8363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8364         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(owner);
8365         LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
8366         int64_t ret_ref = 0;
8367         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8368         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8369         return ret_ref;
8370 }
8371
8372 static inline struct LDKChannelReady CResult_ChannelReadyDecodeErrorZ_get_ok(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
8373 CHECK(owner->result_ok);
8374         return ChannelReady_clone(&*owner->contents.result);
8375 }
8376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8377         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(owner);
8378         LDKChannelReady ret_var = CResult_ChannelReadyDecodeErrorZ_get_ok(owner_conv);
8379         int64_t ret_ref = 0;
8380         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8381         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8382         return ret_ref;
8383 }
8384
8385 static inline struct LDKDecodeError CResult_ChannelReadyDecodeErrorZ_get_err(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
8386 CHECK(!owner->result_ok);
8387         return DecodeError_clone(&*owner->contents.err);
8388 }
8389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8390         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(owner);
8391         LDKDecodeError ret_var = CResult_ChannelReadyDecodeErrorZ_get_err(owner_conv);
8392         int64_t ret_ref = 0;
8393         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8394         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8395         return ret_ref;
8396 }
8397
8398 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
8399 CHECK(owner->result_ok);
8400         return Init_clone(&*owner->contents.result);
8401 }
8402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8403         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(owner);
8404         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
8405         int64_t ret_ref = 0;
8406         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8407         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8408         return ret_ref;
8409 }
8410
8411 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
8412 CHECK(!owner->result_ok);
8413         return DecodeError_clone(&*owner->contents.err);
8414 }
8415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8416         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(owner);
8417         LDKDecodeError ret_var = CResult_InitDecodeErrorZ_get_err(owner_conv);
8418         int64_t ret_ref = 0;
8419         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8420         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8421         return ret_ref;
8422 }
8423
8424 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
8425 CHECK(owner->result_ok);
8426         return OpenChannel_clone(&*owner->contents.result);
8427 }
8428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8429         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(owner);
8430         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
8431         int64_t ret_ref = 0;
8432         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8433         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8434         return ret_ref;
8435 }
8436
8437 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
8438 CHECK(!owner->result_ok);
8439         return DecodeError_clone(&*owner->contents.err);
8440 }
8441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8442         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(owner);
8443         LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
8444         int64_t ret_ref = 0;
8445         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8446         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8447         return ret_ref;
8448 }
8449
8450 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
8451 CHECK(owner->result_ok);
8452         return RevokeAndACK_clone(&*owner->contents.result);
8453 }
8454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8455         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(owner);
8456         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
8457         int64_t ret_ref = 0;
8458         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8459         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8460         return ret_ref;
8461 }
8462
8463 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
8464 CHECK(!owner->result_ok);
8465         return DecodeError_clone(&*owner->contents.err);
8466 }
8467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8468         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(owner);
8469         LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
8470         int64_t ret_ref = 0;
8471         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8472         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8473         return ret_ref;
8474 }
8475
8476 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
8477 CHECK(owner->result_ok);
8478         return Shutdown_clone(&*owner->contents.result);
8479 }
8480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8481         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(owner);
8482         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
8483         int64_t ret_ref = 0;
8484         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8485         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8486         return ret_ref;
8487 }
8488
8489 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
8490 CHECK(!owner->result_ok);
8491         return DecodeError_clone(&*owner->contents.err);
8492 }
8493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8494         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(owner);
8495         LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
8496         int64_t ret_ref = 0;
8497         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8498         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8499         return ret_ref;
8500 }
8501
8502 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
8503 CHECK(owner->result_ok);
8504         return UpdateFailHTLC_clone(&*owner->contents.result);
8505 }
8506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8507         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(owner);
8508         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
8509         int64_t ret_ref = 0;
8510         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8511         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8512         return ret_ref;
8513 }
8514
8515 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
8516 CHECK(!owner->result_ok);
8517         return DecodeError_clone(&*owner->contents.err);
8518 }
8519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8520         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(owner);
8521         LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
8522         int64_t ret_ref = 0;
8523         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8524         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8525         return ret_ref;
8526 }
8527
8528 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
8529 CHECK(owner->result_ok);
8530         return UpdateFailMalformedHTLC_clone(&*owner->contents.result);
8531 }
8532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8533         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(owner);
8534         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
8535         int64_t ret_ref = 0;
8536         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8537         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8538         return ret_ref;
8539 }
8540
8541 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
8542 CHECK(!owner->result_ok);
8543         return DecodeError_clone(&*owner->contents.err);
8544 }
8545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8546         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(owner);
8547         LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
8548         int64_t ret_ref = 0;
8549         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8550         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8551         return ret_ref;
8552 }
8553
8554 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
8555 CHECK(owner->result_ok);
8556         return UpdateFee_clone(&*owner->contents.result);
8557 }
8558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8559         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(owner);
8560         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
8561         int64_t ret_ref = 0;
8562         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8563         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8564         return ret_ref;
8565 }
8566
8567 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
8568 CHECK(!owner->result_ok);
8569         return DecodeError_clone(&*owner->contents.err);
8570 }
8571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8572         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(owner);
8573         LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
8574         int64_t ret_ref = 0;
8575         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8576         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8577         return ret_ref;
8578 }
8579
8580 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
8581 CHECK(owner->result_ok);
8582         return UpdateFulfillHTLC_clone(&*owner->contents.result);
8583 }
8584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8585         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(owner);
8586         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
8587         int64_t ret_ref = 0;
8588         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8589         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8590         return ret_ref;
8591 }
8592
8593 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
8594 CHECK(!owner->result_ok);
8595         return DecodeError_clone(&*owner->contents.err);
8596 }
8597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8598         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(owner);
8599         LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
8600         int64_t ret_ref = 0;
8601         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8602         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8603         return ret_ref;
8604 }
8605
8606 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
8607 CHECK(owner->result_ok);
8608         return UpdateAddHTLC_clone(&*owner->contents.result);
8609 }
8610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8611         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(owner);
8612         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
8613         int64_t ret_ref = 0;
8614         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8615         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8616         return ret_ref;
8617 }
8618
8619 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
8620 CHECK(!owner->result_ok);
8621         return DecodeError_clone(&*owner->contents.err);
8622 }
8623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8624         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(owner);
8625         LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
8626         int64_t ret_ref = 0;
8627         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8628         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8629         return ret_ref;
8630 }
8631
8632 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
8633 CHECK(owner->result_ok);
8634         return Ping_clone(&*owner->contents.result);
8635 }
8636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8637         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(owner);
8638         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
8639         int64_t ret_ref = 0;
8640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8641         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8642         return ret_ref;
8643 }
8644
8645 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
8646 CHECK(!owner->result_ok);
8647         return DecodeError_clone(&*owner->contents.err);
8648 }
8649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8650         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(owner);
8651         LDKDecodeError ret_var = CResult_PingDecodeErrorZ_get_err(owner_conv);
8652         int64_t ret_ref = 0;
8653         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8654         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8655         return ret_ref;
8656 }
8657
8658 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
8659 CHECK(owner->result_ok);
8660         return Pong_clone(&*owner->contents.result);
8661 }
8662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8663         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(owner);
8664         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
8665         int64_t ret_ref = 0;
8666         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8667         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8668         return ret_ref;
8669 }
8670
8671 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
8672 CHECK(!owner->result_ok);
8673         return DecodeError_clone(&*owner->contents.err);
8674 }
8675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8676         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(owner);
8677         LDKDecodeError ret_var = CResult_PongDecodeErrorZ_get_err(owner_conv);
8678         int64_t ret_ref = 0;
8679         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8680         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8681         return ret_ref;
8682 }
8683
8684 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8685 CHECK(owner->result_ok);
8686         return UnsignedChannelAnnouncement_clone(&*owner->contents.result);
8687 }
8688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8689         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
8690         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
8691         int64_t ret_ref = 0;
8692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8693         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8694         return ret_ref;
8695 }
8696
8697 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8698 CHECK(!owner->result_ok);
8699         return DecodeError_clone(&*owner->contents.err);
8700 }
8701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8702         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
8703         LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
8704         int64_t ret_ref = 0;
8705         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8706         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8707         return ret_ref;
8708 }
8709
8710 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8711 CHECK(owner->result_ok);
8712         return ChannelAnnouncement_clone(&*owner->contents.result);
8713 }
8714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8715         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
8716         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
8717         int64_t ret_ref = 0;
8718         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8719         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8720         return ret_ref;
8721 }
8722
8723 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8724 CHECK(!owner->result_ok);
8725         return DecodeError_clone(&*owner->contents.err);
8726 }
8727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8728         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
8729         LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
8730         int64_t ret_ref = 0;
8731         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8732         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8733         return ret_ref;
8734 }
8735
8736 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
8737 CHECK(owner->result_ok);
8738         return UnsignedChannelUpdate_clone(&*owner->contents.result);
8739 }
8740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8741         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(owner);
8742         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
8743         int64_t ret_ref = 0;
8744         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8745         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8746         return ret_ref;
8747 }
8748
8749 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
8750 CHECK(!owner->result_ok);
8751         return DecodeError_clone(&*owner->contents.err);
8752 }
8753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8754         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(owner);
8755         LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
8756         int64_t ret_ref = 0;
8757         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8758         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8759         return ret_ref;
8760 }
8761
8762 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
8763 CHECK(owner->result_ok);
8764         return ChannelUpdate_clone(&*owner->contents.result);
8765 }
8766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8767         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(owner);
8768         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
8769         int64_t ret_ref = 0;
8770         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8771         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8772         return ret_ref;
8773 }
8774
8775 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
8776 CHECK(!owner->result_ok);
8777         return DecodeError_clone(&*owner->contents.err);
8778 }
8779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8780         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(owner);
8781         LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
8782         int64_t ret_ref = 0;
8783         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8784         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8785         return ret_ref;
8786 }
8787
8788 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
8789 CHECK(owner->result_ok);
8790         return ErrorMessage_clone(&*owner->contents.result);
8791 }
8792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8793         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(owner);
8794         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
8795         int64_t ret_ref = 0;
8796         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8797         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8798         return ret_ref;
8799 }
8800
8801 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
8802 CHECK(!owner->result_ok);
8803         return DecodeError_clone(&*owner->contents.err);
8804 }
8805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8806         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(owner);
8807         LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
8808         int64_t ret_ref = 0;
8809         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8810         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8811         return ret_ref;
8812 }
8813
8814 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
8815 CHECK(owner->result_ok);
8816         return WarningMessage_clone(&*owner->contents.result);
8817 }
8818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8819         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(owner);
8820         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
8821         int64_t ret_ref = 0;
8822         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8823         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8824         return ret_ref;
8825 }
8826
8827 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
8828 CHECK(!owner->result_ok);
8829         return DecodeError_clone(&*owner->contents.err);
8830 }
8831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8832         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(owner);
8833         LDKDecodeError ret_var = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
8834         int64_t ret_ref = 0;
8835         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8836         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8837         return ret_ref;
8838 }
8839
8840 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8841 CHECK(owner->result_ok);
8842         return UnsignedNodeAnnouncement_clone(&*owner->contents.result);
8843 }
8844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8845         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
8846         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
8847         int64_t ret_ref = 0;
8848         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8849         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8850         return ret_ref;
8851 }
8852
8853 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8854 CHECK(!owner->result_ok);
8855         return DecodeError_clone(&*owner->contents.err);
8856 }
8857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8858         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
8859         LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
8860         int64_t ret_ref = 0;
8861         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8862         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8863         return ret_ref;
8864 }
8865
8866 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8867 CHECK(owner->result_ok);
8868         return NodeAnnouncement_clone(&*owner->contents.result);
8869 }
8870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8871         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
8872         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
8873         int64_t ret_ref = 0;
8874         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8875         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8876         return ret_ref;
8877 }
8878
8879 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8880 CHECK(!owner->result_ok);
8881         return DecodeError_clone(&*owner->contents.err);
8882 }
8883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8884         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
8885         LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
8886         int64_t ret_ref = 0;
8887         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8888         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8889         return ret_ref;
8890 }
8891
8892 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
8893 CHECK(owner->result_ok);
8894         return QueryShortChannelIds_clone(&*owner->contents.result);
8895 }
8896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8897         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(owner);
8898         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
8899         int64_t ret_ref = 0;
8900         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8901         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8902         return ret_ref;
8903 }
8904
8905 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
8906 CHECK(!owner->result_ok);
8907         return DecodeError_clone(&*owner->contents.err);
8908 }
8909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8910         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(owner);
8911         LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
8912         int64_t ret_ref = 0;
8913         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8914         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8915         return ret_ref;
8916 }
8917
8918 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
8919 CHECK(owner->result_ok);
8920         return ReplyShortChannelIdsEnd_clone(&*owner->contents.result);
8921 }
8922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8923         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(owner);
8924         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
8925         int64_t ret_ref = 0;
8926         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8927         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8928         return ret_ref;
8929 }
8930
8931 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
8932 CHECK(!owner->result_ok);
8933         return DecodeError_clone(&*owner->contents.err);
8934 }
8935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8936         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(owner);
8937         LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
8938         int64_t ret_ref = 0;
8939         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8940         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8941         return ret_ref;
8942 }
8943
8944 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
8945 CHECK(owner->result_ok);
8946         return QueryChannelRange_clone(&*owner->contents.result);
8947 }
8948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8949         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(owner);
8950         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
8951         int64_t ret_ref = 0;
8952         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8953         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8954         return ret_ref;
8955 }
8956
8957 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
8958 CHECK(!owner->result_ok);
8959         return DecodeError_clone(&*owner->contents.err);
8960 }
8961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8962         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(owner);
8963         LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
8964         int64_t ret_ref = 0;
8965         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8966         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8967         return ret_ref;
8968 }
8969
8970 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
8971 CHECK(owner->result_ok);
8972         return ReplyChannelRange_clone(&*owner->contents.result);
8973 }
8974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8975         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(owner);
8976         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
8977         int64_t ret_ref = 0;
8978         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8979         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8980         return ret_ref;
8981 }
8982
8983 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
8984 CHECK(!owner->result_ok);
8985         return DecodeError_clone(&*owner->contents.err);
8986 }
8987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8988         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(owner);
8989         LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
8990         int64_t ret_ref = 0;
8991         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8992         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8993         return ret_ref;
8994 }
8995
8996 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
8997 CHECK(owner->result_ok);
8998         return GossipTimestampFilter_clone(&*owner->contents.result);
8999 }
9000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9001         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(owner);
9002         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
9003         int64_t ret_ref = 0;
9004         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9005         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9006         return ret_ref;
9007 }
9008
9009 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
9010 CHECK(!owner->result_ok);
9011         return DecodeError_clone(&*owner->contents.err);
9012 }
9013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9014         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(owner);
9015         LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
9016         int64_t ret_ref = 0;
9017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9018         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9019         return ret_ref;
9020 }
9021
9022 static inline LDKCVec_PhantomRouteHintsZ CVec_PhantomRouteHintsZ_clone(const LDKCVec_PhantomRouteHintsZ *orig) {
9023         LDKCVec_PhantomRouteHintsZ ret = { .data = MALLOC(sizeof(LDKPhantomRouteHints) * orig->datalen, "LDKCVec_PhantomRouteHintsZ clone bytes"), .datalen = orig->datalen };
9024         for (size_t i = 0; i < ret.datalen; i++) {
9025                 ret.data[i] = PhantomRouteHints_clone(&orig->data[i]);
9026         }
9027         return ret;
9028 }
9029 static jclass LDKSignOrCreationError_SignError_class = NULL;
9030 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
9031 static jclass LDKSignOrCreationError_CreationError_class = NULL;
9032 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
9033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
9034         LDKSignOrCreationError_SignError_class =
9035                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$SignError"));
9036         CHECK(LDKSignOrCreationError_SignError_class != NULL);
9037         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
9038         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
9039         LDKSignOrCreationError_CreationError_class =
9040                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$CreationError"));
9041         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
9042         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
9043         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
9044 }
9045 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9046         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)untag_ptr(ptr);
9047         switch(obj->tag) {
9048                 case LDKSignOrCreationError_SignError: {
9049                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
9050                 }
9051                 case LDKSignOrCreationError_CreationError: {
9052                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
9053                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
9054                 }
9055                 default: abort();
9056         }
9057 }
9058 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
9059 CHECK(owner->result_ok);
9060         return Invoice_clone(&*owner->contents.result);
9061 }
9062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9063         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(owner);
9064         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
9065         int64_t ret_ref = 0;
9066         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9067         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9068         return ret_ref;
9069 }
9070
9071 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
9072 CHECK(!owner->result_ok);
9073         return SignOrCreationError_clone(&*owner->contents.err);
9074 }
9075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9076         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(owner);
9077         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
9078         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
9079         int64_t ret_ref = tag_ptr(ret_copy, true);
9080         return ret_ref;
9081 }
9082
9083 typedef struct LDKFilter_JCalls {
9084         atomic_size_t refcnt;
9085         JavaVM *vm;
9086         jweak o;
9087         jmethodID register_tx_meth;
9088         jmethodID register_output_meth;
9089 } LDKFilter_JCalls;
9090 static void LDKFilter_JCalls_free(void* this_arg) {
9091         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
9092         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9093                 JNIEnv *env;
9094                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9095                 if (get_jenv_res == JNI_EDETACHED) {
9096                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9097                 } else {
9098                         DO_ASSERT(get_jenv_res == JNI_OK);
9099                 }
9100                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9101                 if (get_jenv_res == JNI_EDETACHED) {
9102                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9103                 }
9104                 FREE(j_calls);
9105         }
9106 }
9107 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
9108         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
9109         JNIEnv *env;
9110         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9111         if (get_jenv_res == JNI_EDETACHED) {
9112                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9113         } else {
9114                 DO_ASSERT(get_jenv_res == JNI_OK);
9115         }
9116         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
9117         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
9118         LDKu8slice script_pubkey_var = script_pubkey;
9119         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
9120         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
9121         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9122         CHECK(obj != NULL);
9123         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
9124         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9125                 (*env)->ExceptionDescribe(env);
9126                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
9127         }
9128         if (get_jenv_res == JNI_EDETACHED) {
9129                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9130         }
9131 }
9132 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
9133         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
9134         JNIEnv *env;
9135         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9136         if (get_jenv_res == JNI_EDETACHED) {
9137                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9138         } else {
9139                 DO_ASSERT(get_jenv_res == JNI_OK);
9140         }
9141         LDKWatchedOutput output_var = output;
9142         int64_t output_ref = 0;
9143         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
9144         output_ref = tag_ptr(output_var.inner, output_var.is_owned);
9145         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9146         CHECK(obj != NULL);
9147         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
9148         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9149                 (*env)->ExceptionDescribe(env);
9150                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
9151         }
9152         void* ret_ptr = untag_ptr(ret);
9153         CHECK_ACCESS(ret_ptr);
9154         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
9155         FREE(untag_ptr(ret));
9156         if (get_jenv_res == JNI_EDETACHED) {
9157                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9158         }
9159         return ret_conv;
9160 }
9161 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
9162         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
9163         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9164 }
9165 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
9166         jclass c = (*env)->GetObjectClass(env, o);
9167         CHECK(c != NULL);
9168         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
9169         atomic_init(&calls->refcnt, 1);
9170         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9171         calls->o = (*env)->NewWeakGlobalRef(env, o);
9172         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
9173         CHECK(calls->register_tx_meth != NULL);
9174         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
9175         CHECK(calls->register_output_meth != NULL);
9176
9177         LDKFilter ret = {
9178                 .this_arg = (void*) calls,
9179                 .register_tx = register_tx_LDKFilter_jcall,
9180                 .register_output = register_output_LDKFilter_jcall,
9181                 .free = LDKFilter_JCalls_free,
9182         };
9183         return ret;
9184 }
9185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
9186         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
9187         *res_ptr = LDKFilter_init(env, clz, o);
9188         return tag_ptr(res_ptr, true);
9189 }
9190 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) {
9191         void* this_arg_ptr = untag_ptr(this_arg);
9192         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9193         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
9194         unsigned char txid_arr[32];
9195         CHECK((*env)->GetArrayLength(env, txid) == 32);
9196         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
9197         unsigned char (*txid_ref)[32] = &txid_arr;
9198         LDKu8slice script_pubkey_ref;
9199         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
9200         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
9201         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
9202         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
9203 }
9204
9205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
9206         void* this_arg_ptr = untag_ptr(this_arg);
9207         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9208         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
9209         LDKWatchedOutput output_conv;
9210         output_conv.inner = untag_ptr(output);
9211         output_conv.is_owned = ptr_is_owned(output);
9212         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
9213         output_conv = WatchedOutput_clone(&output_conv);
9214         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9215         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
9216         int64_t ret_ref = tag_ptr(ret_copy, true);
9217         return ret_ref;
9218 }
9219
9220 static jclass LDKCOption_FilterZ_Some_class = NULL;
9221 static jmethodID LDKCOption_FilterZ_Some_meth = NULL;
9222 static jclass LDKCOption_FilterZ_None_class = NULL;
9223 static jmethodID LDKCOption_FilterZ_None_meth = NULL;
9224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init (JNIEnv *env, jclass clz) {
9225         LDKCOption_FilterZ_Some_class =
9226                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$Some"));
9227         CHECK(LDKCOption_FilterZ_Some_class != NULL);
9228         LDKCOption_FilterZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_Some_class, "<init>", "(J)V");
9229         CHECK(LDKCOption_FilterZ_Some_meth != NULL);
9230         LDKCOption_FilterZ_None_class =
9231                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$None"));
9232         CHECK(LDKCOption_FilterZ_None_class != NULL);
9233         LDKCOption_FilterZ_None_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_None_class, "<init>", "()V");
9234         CHECK(LDKCOption_FilterZ_None_meth != NULL);
9235 }
9236 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9237         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)untag_ptr(ptr);
9238         switch(obj->tag) {
9239                 case LDKCOption_FilterZ_Some: {
9240                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
9241                         *some_ret = obj->some;
9242                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
9243                         if ((*some_ret).free == LDKFilter_JCalls_free) {
9244                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9245                                 LDKFilter_JCalls_cloned(&(*some_ret));
9246                         }
9247                         return (*env)->NewObject(env, LDKCOption_FilterZ_Some_class, LDKCOption_FilterZ_Some_meth, tag_ptr(some_ret, true));
9248                 }
9249                 case LDKCOption_FilterZ_None: {
9250                         return (*env)->NewObject(env, LDKCOption_FilterZ_None_class, LDKCOption_FilterZ_None_meth);
9251                 }
9252                 default: abort();
9253         }
9254 }
9255 static inline struct LDKLockedChannelMonitor *CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
9256 CHECK(owner->result_ok);
9257         return &*owner->contents.result;
9258 }
9259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9260         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(owner);
9261         LDKLockedChannelMonitor ret_var = *CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
9262         int64_t ret_ref = 0;
9263         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9264         ret_ref = tag_ptr(ret_var.inner, false);
9265         return ret_ref;
9266 }
9267
9268 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
9269 CHECK(!owner->result_ok);
9270         return *owner->contents.err;
9271 }
9272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9273         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(owner);
9274         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
9275 }
9276
9277 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
9278         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
9279         for (size_t i = 0; i < ret.datalen; i++) {
9280                 ret.data[i] = OutPoint_clone(&orig->data[i]);
9281         }
9282         return ret;
9283 }
9284 typedef struct LDKMessageSendEventsProvider_JCalls {
9285         atomic_size_t refcnt;
9286         JavaVM *vm;
9287         jweak o;
9288         jmethodID get_and_clear_pending_msg_events_meth;
9289 } LDKMessageSendEventsProvider_JCalls;
9290 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
9291         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
9292         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9293                 JNIEnv *env;
9294                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9295                 if (get_jenv_res == JNI_EDETACHED) {
9296                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9297                 } else {
9298                         DO_ASSERT(get_jenv_res == JNI_OK);
9299                 }
9300                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9301                 if (get_jenv_res == JNI_EDETACHED) {
9302                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9303                 }
9304                 FREE(j_calls);
9305         }
9306 }
9307 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
9308         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
9309         JNIEnv *env;
9310         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9311         if (get_jenv_res == JNI_EDETACHED) {
9312                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9313         } else {
9314                 DO_ASSERT(get_jenv_res == JNI_OK);
9315         }
9316         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9317         CHECK(obj != NULL);
9318         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
9319         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9320                 (*env)->ExceptionDescribe(env);
9321                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
9322         }
9323         LDKCVec_MessageSendEventZ ret_constr;
9324         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
9325         if (ret_constr.datalen > 0)
9326                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
9327         else
9328                 ret_constr.data = NULL;
9329         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
9330         for (size_t s = 0; s < ret_constr.datalen; s++) {
9331                 int64_t ret_conv_18 = ret_vals[s];
9332                 void* ret_conv_18_ptr = untag_ptr(ret_conv_18);
9333                 CHECK_ACCESS(ret_conv_18_ptr);
9334                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
9335                 FREE(untag_ptr(ret_conv_18));
9336                 ret_constr.data[s] = ret_conv_18_conv;
9337         }
9338         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
9339         if (get_jenv_res == JNI_EDETACHED) {
9340                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9341         }
9342         return ret_constr;
9343 }
9344 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
9345         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
9346         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9347 }
9348 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
9349         jclass c = (*env)->GetObjectClass(env, o);
9350         CHECK(c != NULL);
9351         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
9352         atomic_init(&calls->refcnt, 1);
9353         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9354         calls->o = (*env)->NewWeakGlobalRef(env, o);
9355         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
9356         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
9357
9358         LDKMessageSendEventsProvider ret = {
9359                 .this_arg = (void*) calls,
9360                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
9361                 .free = LDKMessageSendEventsProvider_JCalls_free,
9362         };
9363         return ret;
9364 }
9365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
9366         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
9367         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
9368         return tag_ptr(res_ptr, true);
9369 }
9370 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
9371         void* this_arg_ptr = untag_ptr(this_arg);
9372         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9373         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
9374         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
9375         int64_tArray ret_arr = NULL;
9376         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
9377         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
9378         for (size_t s = 0; s < ret_var.datalen; s++) {
9379                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
9380                 *ret_conv_18_copy = ret_var.data[s];
9381                 int64_t ret_conv_18_ref = tag_ptr(ret_conv_18_copy, true);
9382                 ret_arr_ptr[s] = ret_conv_18_ref;
9383         }
9384         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
9385         FREE(ret_var.data);
9386         return ret_arr;
9387 }
9388
9389 typedef struct LDKEventHandler_JCalls {
9390         atomic_size_t refcnt;
9391         JavaVM *vm;
9392         jweak o;
9393         jmethodID handle_event_meth;
9394 } LDKEventHandler_JCalls;
9395 static void LDKEventHandler_JCalls_free(void* this_arg) {
9396         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
9397         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9398                 JNIEnv *env;
9399                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9400                 if (get_jenv_res == JNI_EDETACHED) {
9401                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9402                 } else {
9403                         DO_ASSERT(get_jenv_res == JNI_OK);
9404                 }
9405                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9406                 if (get_jenv_res == JNI_EDETACHED) {
9407                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9408                 }
9409                 FREE(j_calls);
9410         }
9411 }
9412 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
9413         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
9414         JNIEnv *env;
9415         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9416         if (get_jenv_res == JNI_EDETACHED) {
9417                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9418         } else {
9419                 DO_ASSERT(get_jenv_res == JNI_OK);
9420         }
9421         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
9422         *ret_event = Event_clone(event);
9423         int64_t ref_event = tag_ptr(ret_event, true);
9424         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9425         CHECK(obj != NULL);
9426         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, ref_event);
9427         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9428                 (*env)->ExceptionDescribe(env);
9429                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
9430         }
9431         if (get_jenv_res == JNI_EDETACHED) {
9432                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9433         }
9434 }
9435 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
9436         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
9437         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9438 }
9439 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
9440         jclass c = (*env)->GetObjectClass(env, o);
9441         CHECK(c != NULL);
9442         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
9443         atomic_init(&calls->refcnt, 1);
9444         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9445         calls->o = (*env)->NewWeakGlobalRef(env, o);
9446         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
9447         CHECK(calls->handle_event_meth != NULL);
9448
9449         LDKEventHandler ret = {
9450                 .this_arg = (void*) calls,
9451                 .handle_event = handle_event_LDKEventHandler_jcall,
9452                 .free = LDKEventHandler_JCalls_free,
9453         };
9454         return ret;
9455 }
9456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
9457         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
9458         *res_ptr = LDKEventHandler_init(env, clz, o);
9459         return tag_ptr(res_ptr, true);
9460 }
9461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
9462         void* this_arg_ptr = untag_ptr(this_arg);
9463         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9464         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
9465         LDKEvent* event_conv = (LDKEvent*)untag_ptr(event);
9466         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
9467 }
9468
9469 typedef struct LDKEventsProvider_JCalls {
9470         atomic_size_t refcnt;
9471         JavaVM *vm;
9472         jweak o;
9473         jmethodID process_pending_events_meth;
9474 } LDKEventsProvider_JCalls;
9475 static void LDKEventsProvider_JCalls_free(void* this_arg) {
9476         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
9477         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9478                 JNIEnv *env;
9479                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9480                 if (get_jenv_res == JNI_EDETACHED) {
9481                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9482                 } else {
9483                         DO_ASSERT(get_jenv_res == JNI_OK);
9484                 }
9485                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9486                 if (get_jenv_res == JNI_EDETACHED) {
9487                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9488                 }
9489                 FREE(j_calls);
9490         }
9491 }
9492 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
9493         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
9494         JNIEnv *env;
9495         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9496         if (get_jenv_res == JNI_EDETACHED) {
9497                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9498         } else {
9499                 DO_ASSERT(get_jenv_res == JNI_OK);
9500         }
9501         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
9502         *handler_ret = handler;
9503         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9504         CHECK(obj != NULL);
9505         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, tag_ptr(handler_ret, true));
9506         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9507                 (*env)->ExceptionDescribe(env);
9508                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
9509         }
9510         if (get_jenv_res == JNI_EDETACHED) {
9511                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9512         }
9513 }
9514 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
9515         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
9516         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9517 }
9518 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
9519         jclass c = (*env)->GetObjectClass(env, o);
9520         CHECK(c != NULL);
9521         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
9522         atomic_init(&calls->refcnt, 1);
9523         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9524         calls->o = (*env)->NewWeakGlobalRef(env, o);
9525         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
9526         CHECK(calls->process_pending_events_meth != NULL);
9527
9528         LDKEventsProvider ret = {
9529                 .this_arg = (void*) calls,
9530                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
9531                 .free = LDKEventsProvider_JCalls_free,
9532         };
9533         return ret;
9534 }
9535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
9536         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
9537         *res_ptr = LDKEventsProvider_init(env, clz, o);
9538         return tag_ptr(res_ptr, true);
9539 }
9540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
9541         void* this_arg_ptr = untag_ptr(this_arg);
9542         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9543         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
9544         void* handler_ptr = untag_ptr(handler);
9545         CHECK_ACCESS(handler_ptr);
9546         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
9547         if (handler_conv.free == LDKEventHandler_JCalls_free) {
9548                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9549                 LDKEventHandler_JCalls_cloned(&handler_conv);
9550         }
9551         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
9552 }
9553
9554 typedef struct LDKScore_JCalls {
9555         atomic_size_t refcnt;
9556         JavaVM *vm;
9557         jweak o;
9558         jmethodID channel_penalty_msat_meth;
9559         jmethodID payment_path_failed_meth;
9560         jmethodID payment_path_successful_meth;
9561         jmethodID probe_failed_meth;
9562         jmethodID probe_successful_meth;
9563         jmethodID write_meth;
9564 } LDKScore_JCalls;
9565 static void LDKScore_JCalls_free(void* this_arg) {
9566         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9567         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9568                 JNIEnv *env;
9569                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9570                 if (get_jenv_res == JNI_EDETACHED) {
9571                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9572                 } else {
9573                         DO_ASSERT(get_jenv_res == JNI_OK);
9574                 }
9575                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9576                 if (get_jenv_res == JNI_EDETACHED) {
9577                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9578                 }
9579                 FREE(j_calls);
9580         }
9581 }
9582 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target, LDKChannelUsage usage) {
9583         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9584         JNIEnv *env;
9585         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9586         if (get_jenv_res == JNI_EDETACHED) {
9587                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9588         } else {
9589                 DO_ASSERT(get_jenv_res == JNI_OK);
9590         }
9591         int64_t short_channel_id_conv = short_channel_id;
9592         LDKNodeId source_var = *source;
9593         int64_t source_ref = 0;
9594         source_var = NodeId_clone(&source_var);
9595         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
9596         source_ref = tag_ptr(source_var.inner, source_var.is_owned);
9597         LDKNodeId target_var = *target;
9598         int64_t target_ref = 0;
9599         target_var = NodeId_clone(&target_var);
9600         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
9601         target_ref = tag_ptr(target_var.inner, target_var.is_owned);
9602         LDKChannelUsage usage_var = usage;
9603         int64_t usage_ref = 0;
9604         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_var);
9605         usage_ref = tag_ptr(usage_var.inner, usage_var.is_owned);
9606         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9607         CHECK(obj != NULL);
9608         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id_conv, source_ref, target_ref, usage_ref);
9609         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9610                 (*env)->ExceptionDescribe(env);
9611                 (*env)->FatalError(env, "A call to channel_penalty_msat in LDKScore from rust threw an exception.");
9612         }
9613         if (get_jenv_res == JNI_EDETACHED) {
9614                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9615         }
9616         return ret;
9617 }
9618 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
9619         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9620         JNIEnv *env;
9621         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9622         if (get_jenv_res == JNI_EDETACHED) {
9623                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9624         } else {
9625                 DO_ASSERT(get_jenv_res == JNI_OK);
9626         }
9627         LDKCVec_RouteHopZ path_var = path;
9628         int64_tArray path_arr = NULL;
9629         path_arr = (*env)->NewLongArray(env, path_var.datalen);
9630         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
9631         for (size_t k = 0; k < path_var.datalen; k++) {
9632                 LDKRouteHop path_conv_10_var = path_var.data[k];
9633                 int64_t path_conv_10_ref = 0;
9634                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
9635                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
9636                 path_arr_ptr[k] = path_conv_10_ref;
9637         }
9638         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
9639         FREE(path_var.data);
9640         int64_t short_channel_id_conv = short_channel_id;
9641         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9642         CHECK(obj != NULL);
9643         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_failed_meth, path_arr, short_channel_id_conv);
9644         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9645                 (*env)->ExceptionDescribe(env);
9646                 (*env)->FatalError(env, "A call to payment_path_failed in LDKScore from rust threw an exception.");
9647         }
9648         if (get_jenv_res == JNI_EDETACHED) {
9649                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9650         }
9651 }
9652 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
9653         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9654         JNIEnv *env;
9655         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9656         if (get_jenv_res == JNI_EDETACHED) {
9657                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9658         } else {
9659                 DO_ASSERT(get_jenv_res == JNI_OK);
9660         }
9661         LDKCVec_RouteHopZ path_var = path;
9662         int64_tArray path_arr = NULL;
9663         path_arr = (*env)->NewLongArray(env, path_var.datalen);
9664         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
9665         for (size_t k = 0; k < path_var.datalen; k++) {
9666                 LDKRouteHop path_conv_10_var = path_var.data[k];
9667                 int64_t path_conv_10_ref = 0;
9668                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
9669                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
9670                 path_arr_ptr[k] = path_conv_10_ref;
9671         }
9672         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
9673         FREE(path_var.data);
9674         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9675         CHECK(obj != NULL);
9676         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_successful_meth, path_arr);
9677         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9678                 (*env)->ExceptionDescribe(env);
9679                 (*env)->FatalError(env, "A call to payment_path_successful in LDKScore from rust threw an exception.");
9680         }
9681         if (get_jenv_res == JNI_EDETACHED) {
9682                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9683         }
9684 }
9685 void probe_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
9686         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9687         JNIEnv *env;
9688         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9689         if (get_jenv_res == JNI_EDETACHED) {
9690                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9691         } else {
9692                 DO_ASSERT(get_jenv_res == JNI_OK);
9693         }
9694         LDKCVec_RouteHopZ path_var = path;
9695         int64_tArray path_arr = NULL;
9696         path_arr = (*env)->NewLongArray(env, path_var.datalen);
9697         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
9698         for (size_t k = 0; k < path_var.datalen; k++) {
9699                 LDKRouteHop path_conv_10_var = path_var.data[k];
9700                 int64_t path_conv_10_ref = 0;
9701                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
9702                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
9703                 path_arr_ptr[k] = path_conv_10_ref;
9704         }
9705         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
9706         FREE(path_var.data);
9707         int64_t short_channel_id_conv = short_channel_id;
9708         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9709         CHECK(obj != NULL);
9710         (*env)->CallVoidMethod(env, obj, j_calls->probe_failed_meth, path_arr, short_channel_id_conv);
9711         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9712                 (*env)->ExceptionDescribe(env);
9713                 (*env)->FatalError(env, "A call to probe_failed in LDKScore from rust threw an exception.");
9714         }
9715         if (get_jenv_res == JNI_EDETACHED) {
9716                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9717         }
9718 }
9719 void probe_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
9720         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9721         JNIEnv *env;
9722         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9723         if (get_jenv_res == JNI_EDETACHED) {
9724                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9725         } else {
9726                 DO_ASSERT(get_jenv_res == JNI_OK);
9727         }
9728         LDKCVec_RouteHopZ path_var = path;
9729         int64_tArray path_arr = NULL;
9730         path_arr = (*env)->NewLongArray(env, path_var.datalen);
9731         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
9732         for (size_t k = 0; k < path_var.datalen; k++) {
9733                 LDKRouteHop path_conv_10_var = path_var.data[k];
9734                 int64_t path_conv_10_ref = 0;
9735                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
9736                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
9737                 path_arr_ptr[k] = path_conv_10_ref;
9738         }
9739         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
9740         FREE(path_var.data);
9741         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9742         CHECK(obj != NULL);
9743         (*env)->CallVoidMethod(env, obj, j_calls->probe_successful_meth, path_arr);
9744         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9745                 (*env)->ExceptionDescribe(env);
9746                 (*env)->FatalError(env, "A call to probe_successful in LDKScore from rust threw an exception.");
9747         }
9748         if (get_jenv_res == JNI_EDETACHED) {
9749                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9750         }
9751 }
9752 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
9753         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9754         JNIEnv *env;
9755         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9756         if (get_jenv_res == JNI_EDETACHED) {
9757                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9758         } else {
9759                 DO_ASSERT(get_jenv_res == JNI_OK);
9760         }
9761         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9762         CHECK(obj != NULL);
9763         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
9764         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9765                 (*env)->ExceptionDescribe(env);
9766                 (*env)->FatalError(env, "A call to write in LDKScore from rust threw an exception.");
9767         }
9768         LDKCVec_u8Z ret_ref;
9769         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
9770         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
9771         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
9772         if (get_jenv_res == JNI_EDETACHED) {
9773                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9774         }
9775         return ret_ref;
9776 }
9777 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
9778         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
9779         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9780 }
9781 static inline LDKScore LDKScore_init (JNIEnv *env, jclass clz, jobject o) {
9782         jclass c = (*env)->GetObjectClass(env, o);
9783         CHECK(c != NULL);
9784         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
9785         atomic_init(&calls->refcnt, 1);
9786         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9787         calls->o = (*env)->NewWeakGlobalRef(env, o);
9788         calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(JJJJ)J");
9789         CHECK(calls->channel_penalty_msat_meth != NULL);
9790         calls->payment_path_failed_meth = (*env)->GetMethodID(env, c, "payment_path_failed", "([JJ)V");
9791         CHECK(calls->payment_path_failed_meth != NULL);
9792         calls->payment_path_successful_meth = (*env)->GetMethodID(env, c, "payment_path_successful", "([J)V");
9793         CHECK(calls->payment_path_successful_meth != NULL);
9794         calls->probe_failed_meth = (*env)->GetMethodID(env, c, "probe_failed", "([JJ)V");
9795         CHECK(calls->probe_failed_meth != NULL);
9796         calls->probe_successful_meth = (*env)->GetMethodID(env, c, "probe_successful", "([J)V");
9797         CHECK(calls->probe_successful_meth != NULL);
9798         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
9799         CHECK(calls->write_meth != NULL);
9800
9801         LDKScore ret = {
9802                 .this_arg = (void*) calls,
9803                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
9804                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
9805                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
9806                 .probe_failed = probe_failed_LDKScore_jcall,
9807                 .probe_successful = probe_successful_LDKScore_jcall,
9808                 .write = write_LDKScore_jcall,
9809                 .free = LDKScore_JCalls_free,
9810         };
9811         return ret;
9812 }
9813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKScore_1new(JNIEnv *env, jclass clz, jobject o) {
9814         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
9815         *res_ptr = LDKScore_init(env, clz, o);
9816         return tag_ptr(res_ptr, true);
9817 }
9818 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) {
9819         void* this_arg_ptr = untag_ptr(this_arg);
9820         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9821         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
9822         LDKNodeId source_conv;
9823         source_conv.inner = untag_ptr(source);
9824         source_conv.is_owned = ptr_is_owned(source);
9825         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
9826         source_conv.is_owned = false;
9827         LDKNodeId target_conv;
9828         target_conv.inner = untag_ptr(target);
9829         target_conv.is_owned = ptr_is_owned(target);
9830         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
9831         target_conv.is_owned = false;
9832         LDKChannelUsage usage_conv;
9833         usage_conv.inner = untag_ptr(usage);
9834         usage_conv.is_owned = ptr_is_owned(usage);
9835         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_conv);
9836         usage_conv = ChannelUsage_clone(&usage_conv);
9837         int64_t ret_conv = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv, usage_conv);
9838         return ret_conv;
9839 }
9840
9841 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) {
9842         void* this_arg_ptr = untag_ptr(this_arg);
9843         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9844         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
9845         LDKCVec_RouteHopZ path_constr;
9846         path_constr.datalen = (*env)->GetArrayLength(env, path);
9847         if (path_constr.datalen > 0)
9848                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9849         else
9850                 path_constr.data = NULL;
9851         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
9852         for (size_t k = 0; k < path_constr.datalen; k++) {
9853                 int64_t path_conv_10 = path_vals[k];
9854                 LDKRouteHop path_conv_10_conv;
9855                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
9856                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
9857                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
9858                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
9859                 path_constr.data[k] = path_conv_10_conv;
9860         }
9861         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
9862         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
9863 }
9864
9865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
9866         void* this_arg_ptr = untag_ptr(this_arg);
9867         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9868         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
9869         LDKCVec_RouteHopZ path_constr;
9870         path_constr.datalen = (*env)->GetArrayLength(env, path);
9871         if (path_constr.datalen > 0)
9872                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9873         else
9874                 path_constr.data = NULL;
9875         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
9876         for (size_t k = 0; k < path_constr.datalen; k++) {
9877                 int64_t path_conv_10 = path_vals[k];
9878                 LDKRouteHop path_conv_10_conv;
9879                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
9880                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
9881                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
9882                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
9883                 path_constr.data[k] = path_conv_10_conv;
9884         }
9885         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
9886         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
9887 }
9888
9889 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) {
9890         void* this_arg_ptr = untag_ptr(this_arg);
9891         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9892         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
9893         LDKCVec_RouteHopZ path_constr;
9894         path_constr.datalen = (*env)->GetArrayLength(env, path);
9895         if (path_constr.datalen > 0)
9896                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9897         else
9898                 path_constr.data = NULL;
9899         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
9900         for (size_t k = 0; k < path_constr.datalen; k++) {
9901                 int64_t path_conv_10 = path_vals[k];
9902                 LDKRouteHop path_conv_10_conv;
9903                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
9904                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
9905                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
9906                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
9907                 path_constr.data[k] = path_conv_10_conv;
9908         }
9909         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
9910         (this_arg_conv->probe_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
9911 }
9912
9913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1probe_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
9914         void* this_arg_ptr = untag_ptr(this_arg);
9915         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9916         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
9917         LDKCVec_RouteHopZ path_constr;
9918         path_constr.datalen = (*env)->GetArrayLength(env, path);
9919         if (path_constr.datalen > 0)
9920                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9921         else
9922                 path_constr.data = NULL;
9923         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
9924         for (size_t k = 0; k < path_constr.datalen; k++) {
9925                 int64_t path_conv_10 = path_vals[k];
9926                 LDKRouteHop path_conv_10_conv;
9927                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
9928                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
9929                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
9930                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
9931                 path_constr.data[k] = path_conv_10_conv;
9932         }
9933         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
9934         (this_arg_conv->probe_successful)(this_arg_conv->this_arg, path_constr);
9935 }
9936
9937 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Score_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
9938         void* this_arg_ptr = untag_ptr(this_arg);
9939         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9940         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
9941         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
9942         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
9943         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
9944         CVec_u8Z_free(ret_var);
9945         return ret_arr;
9946 }
9947
9948 typedef struct LDKPersister_JCalls {
9949         atomic_size_t refcnt;
9950         JavaVM *vm;
9951         jweak o;
9952         jmethodID persist_manager_meth;
9953         jmethodID persist_graph_meth;
9954         jmethodID persist_scorer_meth;
9955 } LDKPersister_JCalls;
9956 static void LDKPersister_JCalls_free(void* this_arg) {
9957         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
9958         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9959                 JNIEnv *env;
9960                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9961                 if (get_jenv_res == JNI_EDETACHED) {
9962                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9963                 } else {
9964                         DO_ASSERT(get_jenv_res == JNI_OK);
9965                 }
9966                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9967                 if (get_jenv_res == JNI_EDETACHED) {
9968                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9969                 }
9970                 FREE(j_calls);
9971         }
9972 }
9973 LDKCResult_NoneErrorZ persist_manager_LDKPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
9974         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
9975         JNIEnv *env;
9976         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9977         if (get_jenv_res == JNI_EDETACHED) {
9978                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9979         } else {
9980                 DO_ASSERT(get_jenv_res == JNI_OK);
9981         }
9982         LDKChannelManager channel_manager_var = *channel_manager;
9983         int64_t channel_manager_ref = 0;
9984         // WARNING: we may need a move here but no clone is available for LDKChannelManager
9985         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
9986         channel_manager_ref = tag_ptr(channel_manager_var.inner, channel_manager_var.is_owned);
9987         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9988         CHECK(obj != NULL);
9989         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
9990         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9991                 (*env)->ExceptionDescribe(env);
9992                 (*env)->FatalError(env, "A call to persist_manager in LDKPersister from rust threw an exception.");
9993         }
9994         void* ret_ptr = untag_ptr(ret);
9995         CHECK_ACCESS(ret_ptr);
9996         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
9997         FREE(untag_ptr(ret));
9998         if (get_jenv_res == JNI_EDETACHED) {
9999                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10000         }
10001         return ret_conv;
10002 }
10003 LDKCResult_NoneErrorZ persist_graph_LDKPersister_jcall(const void* this_arg, const LDKNetworkGraph * network_graph) {
10004         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
10005         JNIEnv *env;
10006         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10007         if (get_jenv_res == JNI_EDETACHED) {
10008                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10009         } else {
10010                 DO_ASSERT(get_jenv_res == JNI_OK);
10011         }
10012         LDKNetworkGraph network_graph_var = *network_graph;
10013         int64_t network_graph_ref = 0;
10014         // WARNING: we may need a move here but no clone is available for LDKNetworkGraph
10015         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_var);
10016         network_graph_ref = tag_ptr(network_graph_var.inner, network_graph_var.is_owned);
10017         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10018         CHECK(obj != NULL);
10019         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_graph_meth, network_graph_ref);
10020         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10021                 (*env)->ExceptionDescribe(env);
10022                 (*env)->FatalError(env, "A call to persist_graph in LDKPersister from rust threw an exception.");
10023         }
10024         void* ret_ptr = untag_ptr(ret);
10025         CHECK_ACCESS(ret_ptr);
10026         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
10027         FREE(untag_ptr(ret));
10028         if (get_jenv_res == JNI_EDETACHED) {
10029                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10030         }
10031         return ret_conv;
10032 }
10033 LDKCResult_NoneErrorZ persist_scorer_LDKPersister_jcall(const void* this_arg, const LDKMultiThreadedLockableScore * scorer) {
10034         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
10035         JNIEnv *env;
10036         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10037         if (get_jenv_res == JNI_EDETACHED) {
10038                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10039         } else {
10040                 DO_ASSERT(get_jenv_res == JNI_OK);
10041         }
10042         LDKMultiThreadedLockableScore scorer_var = *scorer;
10043         int64_t scorer_ref = 0;
10044         // WARNING: we may need a move here but no clone is available for LDKMultiThreadedLockableScore
10045         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_var);
10046         scorer_ref = tag_ptr(scorer_var.inner, scorer_var.is_owned);
10047         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10048         CHECK(obj != NULL);
10049         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_scorer_meth, scorer_ref);
10050         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10051                 (*env)->ExceptionDescribe(env);
10052                 (*env)->FatalError(env, "A call to persist_scorer in LDKPersister from rust threw an exception.");
10053         }
10054         void* ret_ptr = untag_ptr(ret);
10055         CHECK_ACCESS(ret_ptr);
10056         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
10057         FREE(untag_ptr(ret));
10058         if (get_jenv_res == JNI_EDETACHED) {
10059                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10060         }
10061         return ret_conv;
10062 }
10063 static void LDKPersister_JCalls_cloned(LDKPersister* new_obj) {
10064         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) new_obj->this_arg;
10065         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10066 }
10067 static inline LDKPersister LDKPersister_init (JNIEnv *env, jclass clz, jobject o) {
10068         jclass c = (*env)->GetObjectClass(env, o);
10069         CHECK(c != NULL);
10070         LDKPersister_JCalls *calls = MALLOC(sizeof(LDKPersister_JCalls), "LDKPersister_JCalls");
10071         atomic_init(&calls->refcnt, 1);
10072         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10073         calls->o = (*env)->NewWeakGlobalRef(env, o);
10074         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
10075         CHECK(calls->persist_manager_meth != NULL);
10076         calls->persist_graph_meth = (*env)->GetMethodID(env, c, "persist_graph", "(J)J");
10077         CHECK(calls->persist_graph_meth != NULL);
10078         calls->persist_scorer_meth = (*env)->GetMethodID(env, c, "persist_scorer", "(J)J");
10079         CHECK(calls->persist_scorer_meth != NULL);
10080
10081         LDKPersister ret = {
10082                 .this_arg = (void*) calls,
10083                 .persist_manager = persist_manager_LDKPersister_jcall,
10084                 .persist_graph = persist_graph_LDKPersister_jcall,
10085                 .persist_scorer = persist_scorer_LDKPersister_jcall,
10086                 .free = LDKPersister_JCalls_free,
10087         };
10088         return ret;
10089 }
10090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersister_1new(JNIEnv *env, jclass clz, jobject o) {
10091         LDKPersister *res_ptr = MALLOC(sizeof(LDKPersister), "LDKPersister");
10092         *res_ptr = LDKPersister_init(env, clz, o);
10093         return tag_ptr(res_ptr, true);
10094 }
10095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
10096         void* this_arg_ptr = untag_ptr(this_arg);
10097         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10098         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
10099         LDKChannelManager channel_manager_conv;
10100         channel_manager_conv.inner = untag_ptr(channel_manager);
10101         channel_manager_conv.is_owned = ptr_is_owned(channel_manager);
10102         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
10103         channel_manager_conv.is_owned = false;
10104         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
10105         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
10106         return tag_ptr(ret_conv, true);
10107 }
10108
10109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1graph(JNIEnv *env, jclass clz, int64_t this_arg, int64_t network_graph) {
10110         void* this_arg_ptr = untag_ptr(this_arg);
10111         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10112         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
10113         LDKNetworkGraph network_graph_conv;
10114         network_graph_conv.inner = untag_ptr(network_graph);
10115         network_graph_conv.is_owned = ptr_is_owned(network_graph);
10116         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
10117         network_graph_conv.is_owned = false;
10118         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
10119         *ret_conv = (this_arg_conv->persist_graph)(this_arg_conv->this_arg, &network_graph_conv);
10120         return tag_ptr(ret_conv, true);
10121 }
10122
10123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1scorer(JNIEnv *env, jclass clz, int64_t this_arg, int64_t scorer) {
10124         void* this_arg_ptr = untag_ptr(this_arg);
10125         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10126         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
10127         LDKMultiThreadedLockableScore scorer_conv;
10128         scorer_conv.inner = untag_ptr(scorer);
10129         scorer_conv.is_owned = ptr_is_owned(scorer);
10130         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
10131         scorer_conv.is_owned = false;
10132         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
10133         *ret_conv = (this_arg_conv->persist_scorer)(this_arg_conv->this_arg, &scorer_conv);
10134         return tag_ptr(ret_conv, true);
10135 }
10136
10137 typedef struct LDKListen_JCalls {
10138         atomic_size_t refcnt;
10139         JavaVM *vm;
10140         jweak o;
10141         jmethodID filtered_block_connected_meth;
10142         jmethodID block_connected_meth;
10143         jmethodID block_disconnected_meth;
10144 } LDKListen_JCalls;
10145 static void LDKListen_JCalls_free(void* this_arg) {
10146         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
10147         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10148                 JNIEnv *env;
10149                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10150                 if (get_jenv_res == JNI_EDETACHED) {
10151                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10152                 } else {
10153                         DO_ASSERT(get_jenv_res == JNI_OK);
10154                 }
10155                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10156                 if (get_jenv_res == JNI_EDETACHED) {
10157                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10158                 }
10159                 FREE(j_calls);
10160         }
10161 }
10162 void filtered_block_connected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
10163         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
10164         JNIEnv *env;
10165         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10166         if (get_jenv_res == JNI_EDETACHED) {
10167                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10168         } else {
10169                 DO_ASSERT(get_jenv_res == JNI_OK);
10170         }
10171         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
10172         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
10173         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
10174         int64_tArray txdata_arr = NULL;
10175         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
10176         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
10177         for (size_t c = 0; c < txdata_var.datalen; c++) {
10178                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
10179                 *txdata_conv_28_conv = txdata_var.data[c];
10180                 txdata_arr_ptr[c] = tag_ptr(txdata_conv_28_conv, true);
10181         }
10182         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
10183         FREE(txdata_var.data);
10184         int32_t height_conv = height;
10185         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10186         CHECK(obj != NULL);
10187         (*env)->CallVoidMethod(env, obj, j_calls->filtered_block_connected_meth, header_arr, txdata_arr, height_conv);
10188         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10189                 (*env)->ExceptionDescribe(env);
10190                 (*env)->FatalError(env, "A call to filtered_block_connected in LDKListen from rust threw an exception.");
10191         }
10192         if (get_jenv_res == JNI_EDETACHED) {
10193                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10194         }
10195 }
10196 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
10197         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
10198         JNIEnv *env;
10199         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10200         if (get_jenv_res == JNI_EDETACHED) {
10201                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10202         } else {
10203                 DO_ASSERT(get_jenv_res == JNI_OK);
10204         }
10205         LDKu8slice block_var = block;
10206         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
10207         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
10208         int32_t height_conv = height;
10209         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10210         CHECK(obj != NULL);
10211         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height_conv);
10212         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10213                 (*env)->ExceptionDescribe(env);
10214                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
10215         }
10216         if (get_jenv_res == JNI_EDETACHED) {
10217                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10218         }
10219 }
10220 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
10221         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
10222         JNIEnv *env;
10223         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10224         if (get_jenv_res == JNI_EDETACHED) {
10225                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10226         } else {
10227                 DO_ASSERT(get_jenv_res == JNI_OK);
10228         }
10229         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
10230         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
10231         int32_t height_conv = height;
10232         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10233         CHECK(obj != NULL);
10234         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height_conv);
10235         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10236                 (*env)->ExceptionDescribe(env);
10237                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
10238         }
10239         if (get_jenv_res == JNI_EDETACHED) {
10240                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10241         }
10242 }
10243 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
10244         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
10245         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10246 }
10247 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
10248         jclass c = (*env)->GetObjectClass(env, o);
10249         CHECK(c != NULL);
10250         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
10251         atomic_init(&calls->refcnt, 1);
10252         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10253         calls->o = (*env)->NewWeakGlobalRef(env, o);
10254         calls->filtered_block_connected_meth = (*env)->GetMethodID(env, c, "filtered_block_connected", "([B[JI)V");
10255         CHECK(calls->filtered_block_connected_meth != NULL);
10256         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
10257         CHECK(calls->block_connected_meth != NULL);
10258         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
10259         CHECK(calls->block_disconnected_meth != NULL);
10260
10261         LDKListen ret = {
10262                 .this_arg = (void*) calls,
10263                 .filtered_block_connected = filtered_block_connected_LDKListen_jcall,
10264                 .block_connected = block_connected_LDKListen_jcall,
10265                 .block_disconnected = block_disconnected_LDKListen_jcall,
10266                 .free = LDKListen_JCalls_free,
10267         };
10268         return ret;
10269 }
10270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
10271         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
10272         *res_ptr = LDKListen_init(env, clz, o);
10273         return tag_ptr(res_ptr, true);
10274 }
10275 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) {
10276         void* this_arg_ptr = untag_ptr(this_arg);
10277         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10278         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
10279         unsigned char header_arr[80];
10280         CHECK((*env)->GetArrayLength(env, header) == 80);
10281         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
10282         unsigned char (*header_ref)[80] = &header_arr;
10283         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
10284         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
10285         if (txdata_constr.datalen > 0)
10286                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
10287         else
10288                 txdata_constr.data = NULL;
10289         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
10290         for (size_t c = 0; c < txdata_constr.datalen; c++) {
10291                 int64_t txdata_conv_28 = txdata_vals[c];
10292                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
10293                 CHECK_ACCESS(txdata_conv_28_ptr);
10294                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
10295                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
10296                 txdata_constr.data[c] = txdata_conv_28_conv;
10297         }
10298         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
10299         (this_arg_conv->filtered_block_connected)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
10300 }
10301
10302 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) {
10303         void* this_arg_ptr = untag_ptr(this_arg);
10304         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10305         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
10306         LDKu8slice block_ref;
10307         block_ref.datalen = (*env)->GetArrayLength(env, block);
10308         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
10309         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
10310         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
10311 }
10312
10313 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) {
10314         void* this_arg_ptr = untag_ptr(this_arg);
10315         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10316         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
10317         unsigned char header_arr[80];
10318         CHECK((*env)->GetArrayLength(env, header) == 80);
10319         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
10320         unsigned char (*header_ref)[80] = &header_arr;
10321         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
10322 }
10323
10324 typedef struct LDKConfirm_JCalls {
10325         atomic_size_t refcnt;
10326         JavaVM *vm;
10327         jweak o;
10328         jmethodID transactions_confirmed_meth;
10329         jmethodID transaction_unconfirmed_meth;
10330         jmethodID best_block_updated_meth;
10331         jmethodID get_relevant_txids_meth;
10332 } LDKConfirm_JCalls;
10333 static void LDKConfirm_JCalls_free(void* this_arg) {
10334         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
10335         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10336                 JNIEnv *env;
10337                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10338                 if (get_jenv_res == JNI_EDETACHED) {
10339                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10340                 } else {
10341                         DO_ASSERT(get_jenv_res == JNI_OK);
10342                 }
10343                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10344                 if (get_jenv_res == JNI_EDETACHED) {
10345                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10346                 }
10347                 FREE(j_calls);
10348         }
10349 }
10350 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
10351         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
10352         JNIEnv *env;
10353         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10354         if (get_jenv_res == JNI_EDETACHED) {
10355                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10356         } else {
10357                 DO_ASSERT(get_jenv_res == JNI_OK);
10358         }
10359         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
10360         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
10361         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
10362         int64_tArray txdata_arr = NULL;
10363         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
10364         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
10365         for (size_t c = 0; c < txdata_var.datalen; c++) {
10366                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
10367                 *txdata_conv_28_conv = txdata_var.data[c];
10368                 txdata_arr_ptr[c] = tag_ptr(txdata_conv_28_conv, true);
10369         }
10370         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
10371         FREE(txdata_var.data);
10372         int32_t height_conv = height;
10373         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10374         CHECK(obj != NULL);
10375         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height_conv);
10376         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10377                 (*env)->ExceptionDescribe(env);
10378                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
10379         }
10380         if (get_jenv_res == JNI_EDETACHED) {
10381                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10382         }
10383 }
10384 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
10385         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
10386         JNIEnv *env;
10387         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10388         if (get_jenv_res == JNI_EDETACHED) {
10389                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10390         } else {
10391                 DO_ASSERT(get_jenv_res == JNI_OK);
10392         }
10393         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
10394         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
10395         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10396         CHECK(obj != NULL);
10397         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
10398         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10399                 (*env)->ExceptionDescribe(env);
10400                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
10401         }
10402         if (get_jenv_res == JNI_EDETACHED) {
10403                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10404         }
10405 }
10406 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
10407         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
10408         JNIEnv *env;
10409         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10410         if (get_jenv_res == JNI_EDETACHED) {
10411                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10412         } else {
10413                 DO_ASSERT(get_jenv_res == JNI_OK);
10414         }
10415         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
10416         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
10417         int32_t height_conv = height;
10418         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10419         CHECK(obj != NULL);
10420         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height_conv);
10421         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10422                 (*env)->ExceptionDescribe(env);
10423                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
10424         }
10425         if (get_jenv_res == JNI_EDETACHED) {
10426                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10427         }
10428 }
10429 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
10430         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
10431         JNIEnv *env;
10432         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10433         if (get_jenv_res == JNI_EDETACHED) {
10434                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10435         } else {
10436                 DO_ASSERT(get_jenv_res == JNI_OK);
10437         }
10438         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10439         CHECK(obj != NULL);
10440         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
10441         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10442                 (*env)->ExceptionDescribe(env);
10443                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
10444         }
10445         LDKCVec_TxidZ ret_constr;
10446         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
10447         if (ret_constr.datalen > 0)
10448                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
10449         else
10450                 ret_constr.data = NULL;
10451         for (size_t i = 0; i < ret_constr.datalen; i++) {
10452                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
10453                 LDKThirtyTwoBytes ret_conv_8_ref;
10454                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
10455                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
10456                 ret_constr.data[i] = ret_conv_8_ref;
10457         }
10458         if (get_jenv_res == JNI_EDETACHED) {
10459                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10460         }
10461         return ret_constr;
10462 }
10463 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
10464         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
10465         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10466 }
10467 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
10468         jclass c = (*env)->GetObjectClass(env, o);
10469         CHECK(c != NULL);
10470         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
10471         atomic_init(&calls->refcnt, 1);
10472         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10473         calls->o = (*env)->NewWeakGlobalRef(env, o);
10474         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
10475         CHECK(calls->transactions_confirmed_meth != NULL);
10476         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
10477         CHECK(calls->transaction_unconfirmed_meth != NULL);
10478         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
10479         CHECK(calls->best_block_updated_meth != NULL);
10480         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
10481         CHECK(calls->get_relevant_txids_meth != NULL);
10482
10483         LDKConfirm ret = {
10484                 .this_arg = (void*) calls,
10485                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
10486                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
10487                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
10488                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
10489                 .free = LDKConfirm_JCalls_free,
10490         };
10491         return ret;
10492 }
10493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
10494         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
10495         *res_ptr = LDKConfirm_init(env, clz, o);
10496         return tag_ptr(res_ptr, true);
10497 }
10498 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) {
10499         void* this_arg_ptr = untag_ptr(this_arg);
10500         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10501         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
10502         unsigned char header_arr[80];
10503         CHECK((*env)->GetArrayLength(env, header) == 80);
10504         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
10505         unsigned char (*header_ref)[80] = &header_arr;
10506         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
10507         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
10508         if (txdata_constr.datalen > 0)
10509                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
10510         else
10511                 txdata_constr.data = NULL;
10512         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
10513         for (size_t c = 0; c < txdata_constr.datalen; c++) {
10514                 int64_t txdata_conv_28 = txdata_vals[c];
10515                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
10516                 CHECK_ACCESS(txdata_conv_28_ptr);
10517                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
10518                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
10519                 txdata_constr.data[c] = txdata_conv_28_conv;
10520         }
10521         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
10522         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
10523 }
10524
10525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
10526         void* this_arg_ptr = untag_ptr(this_arg);
10527         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10528         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
10529         unsigned char txid_arr[32];
10530         CHECK((*env)->GetArrayLength(env, txid) == 32);
10531         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
10532         unsigned char (*txid_ref)[32] = &txid_arr;
10533         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
10534 }
10535
10536 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) {
10537         void* this_arg_ptr = untag_ptr(this_arg);
10538         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10539         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
10540         unsigned char header_arr[80];
10541         CHECK((*env)->GetArrayLength(env, header) == 80);
10542         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
10543         unsigned char (*header_ref)[80] = &header_arr;
10544         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
10545 }
10546
10547 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
10548         void* this_arg_ptr = untag_ptr(this_arg);
10549         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10550         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
10551         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
10552         jobjectArray ret_arr = NULL;
10553         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
10554         ;
10555         for (size_t i = 0; i < ret_var.datalen; i++) {
10556                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
10557                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
10558                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
10559         }
10560         
10561         FREE(ret_var.data);
10562         return ret_arr;
10563 }
10564
10565 typedef struct LDKPersist_JCalls {
10566         atomic_size_t refcnt;
10567         JavaVM *vm;
10568         jweak o;
10569         jmethodID persist_new_channel_meth;
10570         jmethodID update_persisted_channel_meth;
10571 } LDKPersist_JCalls;
10572 static void LDKPersist_JCalls_free(void* this_arg) {
10573         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
10574         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10575                 JNIEnv *env;
10576                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10577                 if (get_jenv_res == JNI_EDETACHED) {
10578                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10579                 } else {
10580                         DO_ASSERT(get_jenv_res == JNI_OK);
10581                 }
10582                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10583                 if (get_jenv_res == JNI_EDETACHED) {
10584                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10585                 }
10586                 FREE(j_calls);
10587         }
10588 }
10589 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
10590         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
10591         JNIEnv *env;
10592         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10593         if (get_jenv_res == JNI_EDETACHED) {
10594                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10595         } else {
10596                 DO_ASSERT(get_jenv_res == JNI_OK);
10597         }
10598         LDKOutPoint channel_id_var = channel_id;
10599         int64_t channel_id_ref = 0;
10600         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
10601         channel_id_ref = tag_ptr(channel_id_var.inner, channel_id_var.is_owned);
10602         LDKChannelMonitor data_var = *data;
10603         int64_t data_ref = 0;
10604         data_var = ChannelMonitor_clone(&data_var);
10605         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
10606         data_ref = tag_ptr(data_var.inner, data_var.is_owned);
10607         LDKMonitorUpdateId update_id_var = update_id;
10608         int64_t update_id_ref = 0;
10609         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
10610         update_id_ref = tag_ptr(update_id_var.inner, update_id_var.is_owned);
10611         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10612         CHECK(obj != NULL);
10613         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
10614         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10615                 (*env)->ExceptionDescribe(env);
10616                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
10617         }
10618         void* ret_ptr = untag_ptr(ret);
10619         CHECK_ACCESS(ret_ptr);
10620         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
10621         FREE(untag_ptr(ret));
10622         if (get_jenv_res == JNI_EDETACHED) {
10623                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10624         }
10625         return ret_conv;
10626 }
10627 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
10628         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
10629         JNIEnv *env;
10630         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10631         if (get_jenv_res == JNI_EDETACHED) {
10632                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10633         } else {
10634                 DO_ASSERT(get_jenv_res == JNI_OK);
10635         }
10636         LDKOutPoint channel_id_var = channel_id;
10637         int64_t channel_id_ref = 0;
10638         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
10639         channel_id_ref = tag_ptr(channel_id_var.inner, channel_id_var.is_owned);
10640         LDKChannelMonitorUpdate update_var = *update;
10641         int64_t update_ref = 0;
10642         update_var = ChannelMonitorUpdate_clone(&update_var);
10643         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
10644         update_ref = tag_ptr(update_var.inner, update_var.is_owned);
10645         LDKChannelMonitor data_var = *data;
10646         int64_t data_ref = 0;
10647         data_var = ChannelMonitor_clone(&data_var);
10648         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
10649         data_ref = tag_ptr(data_var.inner, data_var.is_owned);
10650         LDKMonitorUpdateId update_id_var = update_id;
10651         int64_t update_id_ref = 0;
10652         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
10653         update_id_ref = tag_ptr(update_id_var.inner, update_id_var.is_owned);
10654         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10655         CHECK(obj != NULL);
10656         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
10657         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10658                 (*env)->ExceptionDescribe(env);
10659                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
10660         }
10661         void* ret_ptr = untag_ptr(ret);
10662         CHECK_ACCESS(ret_ptr);
10663         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
10664         FREE(untag_ptr(ret));
10665         if (get_jenv_res == JNI_EDETACHED) {
10666                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10667         }
10668         return ret_conv;
10669 }
10670 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
10671         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
10672         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10673 }
10674 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
10675         jclass c = (*env)->GetObjectClass(env, o);
10676         CHECK(c != NULL);
10677         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
10678         atomic_init(&calls->refcnt, 1);
10679         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10680         calls->o = (*env)->NewWeakGlobalRef(env, o);
10681         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJJ)J");
10682         CHECK(calls->persist_new_channel_meth != NULL);
10683         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJJ)J");
10684         CHECK(calls->update_persisted_channel_meth != NULL);
10685
10686         LDKPersist ret = {
10687                 .this_arg = (void*) calls,
10688                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
10689                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
10690                 .free = LDKPersist_JCalls_free,
10691         };
10692         return ret;
10693 }
10694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
10695         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
10696         *res_ptr = LDKPersist_init(env, clz, o);
10697         return tag_ptr(res_ptr, true);
10698 }
10699 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) {
10700         void* this_arg_ptr = untag_ptr(this_arg);
10701         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10702         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
10703         LDKOutPoint channel_id_conv;
10704         channel_id_conv.inner = untag_ptr(channel_id);
10705         channel_id_conv.is_owned = ptr_is_owned(channel_id);
10706         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
10707         channel_id_conv = OutPoint_clone(&channel_id_conv);
10708         LDKChannelMonitor data_conv;
10709         data_conv.inner = untag_ptr(data);
10710         data_conv.is_owned = ptr_is_owned(data);
10711         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
10712         data_conv.is_owned = false;
10713         LDKMonitorUpdateId update_id_conv;
10714         update_id_conv.inner = untag_ptr(update_id);
10715         update_id_conv.is_owned = ptr_is_owned(update_id);
10716         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
10717         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
10718         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
10719         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
10720         return tag_ptr(ret_conv, true);
10721 }
10722
10723 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) {
10724         void* this_arg_ptr = untag_ptr(this_arg);
10725         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10726         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
10727         LDKOutPoint channel_id_conv;
10728         channel_id_conv.inner = untag_ptr(channel_id);
10729         channel_id_conv.is_owned = ptr_is_owned(channel_id);
10730         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
10731         channel_id_conv = OutPoint_clone(&channel_id_conv);
10732         LDKChannelMonitorUpdate update_conv;
10733         update_conv.inner = untag_ptr(update);
10734         update_conv.is_owned = ptr_is_owned(update);
10735         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
10736         update_conv.is_owned = false;
10737         LDKChannelMonitor data_conv;
10738         data_conv.inner = untag_ptr(data);
10739         data_conv.is_owned = ptr_is_owned(data);
10740         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
10741         data_conv.is_owned = false;
10742         LDKMonitorUpdateId update_id_conv;
10743         update_id_conv.inner = untag_ptr(update_id);
10744         update_id_conv.is_owned = ptr_is_owned(update_id);
10745         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
10746         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
10747         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
10748         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
10749         return tag_ptr(ret_conv, true);
10750 }
10751
10752 typedef struct LDKChannelMessageHandler_JCalls {
10753         atomic_size_t refcnt;
10754         JavaVM *vm;
10755         jweak o;
10756         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
10757         jmethodID handle_open_channel_meth;
10758         jmethodID handle_accept_channel_meth;
10759         jmethodID handle_funding_created_meth;
10760         jmethodID handle_funding_signed_meth;
10761         jmethodID handle_channel_ready_meth;
10762         jmethodID handle_shutdown_meth;
10763         jmethodID handle_closing_signed_meth;
10764         jmethodID handle_update_add_htlc_meth;
10765         jmethodID handle_update_fulfill_htlc_meth;
10766         jmethodID handle_update_fail_htlc_meth;
10767         jmethodID handle_update_fail_malformed_htlc_meth;
10768         jmethodID handle_commitment_signed_meth;
10769         jmethodID handle_revoke_and_ack_meth;
10770         jmethodID handle_update_fee_meth;
10771         jmethodID handle_announcement_signatures_meth;
10772         jmethodID peer_disconnected_meth;
10773         jmethodID peer_connected_meth;
10774         jmethodID handle_channel_reestablish_meth;
10775         jmethodID handle_channel_update_meth;
10776         jmethodID handle_error_meth;
10777 } LDKChannelMessageHandler_JCalls;
10778 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
10779         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10780         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10781                 JNIEnv *env;
10782                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10783                 if (get_jenv_res == JNI_EDETACHED) {
10784                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10785                 } else {
10786                         DO_ASSERT(get_jenv_res == JNI_OK);
10787                 }
10788                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10789                 if (get_jenv_res == JNI_EDETACHED) {
10790                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10791                 }
10792                 FREE(j_calls);
10793         }
10794 }
10795 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
10796         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10797         JNIEnv *env;
10798         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10799         if (get_jenv_res == JNI_EDETACHED) {
10800                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10801         } else {
10802                 DO_ASSERT(get_jenv_res == JNI_OK);
10803         }
10804         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10805         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10806         LDKInitFeatures their_features_var = their_features;
10807         int64_t their_features_ref = 0;
10808         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
10809         their_features_ref = tag_ptr(their_features_var.inner, their_features_var.is_owned);
10810         LDKOpenChannel msg_var = *msg;
10811         int64_t msg_ref = 0;
10812         msg_var = OpenChannel_clone(&msg_var);
10813         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10814         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
10815         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10816         CHECK(obj != NULL);
10817         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
10818         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10819                 (*env)->ExceptionDescribe(env);
10820                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
10821         }
10822         if (get_jenv_res == JNI_EDETACHED) {
10823                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10824         }
10825 }
10826 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
10827         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10828         JNIEnv *env;
10829         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10830         if (get_jenv_res == JNI_EDETACHED) {
10831                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10832         } else {
10833                 DO_ASSERT(get_jenv_res == JNI_OK);
10834         }
10835         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10836         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10837         LDKInitFeatures their_features_var = their_features;
10838         int64_t their_features_ref = 0;
10839         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
10840         their_features_ref = tag_ptr(their_features_var.inner, their_features_var.is_owned);
10841         LDKAcceptChannel msg_var = *msg;
10842         int64_t msg_ref = 0;
10843         msg_var = AcceptChannel_clone(&msg_var);
10844         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10845         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
10846         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10847         CHECK(obj != NULL);
10848         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
10849         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10850                 (*env)->ExceptionDescribe(env);
10851                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
10852         }
10853         if (get_jenv_res == JNI_EDETACHED) {
10854                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10855         }
10856 }
10857 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
10858         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10859         JNIEnv *env;
10860         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10861         if (get_jenv_res == JNI_EDETACHED) {
10862                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10863         } else {
10864                 DO_ASSERT(get_jenv_res == JNI_OK);
10865         }
10866         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10867         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10868         LDKFundingCreated msg_var = *msg;
10869         int64_t msg_ref = 0;
10870         msg_var = FundingCreated_clone(&msg_var);
10871         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10872         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
10873         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10874         CHECK(obj != NULL);
10875         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
10876         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10877                 (*env)->ExceptionDescribe(env);
10878                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
10879         }
10880         if (get_jenv_res == JNI_EDETACHED) {
10881                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10882         }
10883 }
10884 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
10885         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10886         JNIEnv *env;
10887         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10888         if (get_jenv_res == JNI_EDETACHED) {
10889                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10890         } else {
10891                 DO_ASSERT(get_jenv_res == JNI_OK);
10892         }
10893         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10894         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10895         LDKFundingSigned msg_var = *msg;
10896         int64_t msg_ref = 0;
10897         msg_var = FundingSigned_clone(&msg_var);
10898         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10899         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
10900         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10901         CHECK(obj != NULL);
10902         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
10903         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10904                 (*env)->ExceptionDescribe(env);
10905                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
10906         }
10907         if (get_jenv_res == JNI_EDETACHED) {
10908                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10909         }
10910 }
10911 void handle_channel_ready_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReady * msg) {
10912         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10913         JNIEnv *env;
10914         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10915         if (get_jenv_res == JNI_EDETACHED) {
10916                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10917         } else {
10918                 DO_ASSERT(get_jenv_res == JNI_OK);
10919         }
10920         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10921         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10922         LDKChannelReady msg_var = *msg;
10923         int64_t msg_ref = 0;
10924         msg_var = ChannelReady_clone(&msg_var);
10925         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10926         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
10927         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10928         CHECK(obj != NULL);
10929         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_ready_meth, their_node_id_arr, msg_ref);
10930         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10931                 (*env)->ExceptionDescribe(env);
10932                 (*env)->FatalError(env, "A call to handle_channel_ready in LDKChannelMessageHandler from rust threw an exception.");
10933         }
10934         if (get_jenv_res == JNI_EDETACHED) {
10935                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10936         }
10937 }
10938 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
10939         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10940         JNIEnv *env;
10941         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10942         if (get_jenv_res == JNI_EDETACHED) {
10943                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10944         } else {
10945                 DO_ASSERT(get_jenv_res == JNI_OK);
10946         }
10947         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10948         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10949         LDKInitFeatures their_features_var = *their_features;
10950         int64_t their_features_ref = 0;
10951         their_features_var = InitFeatures_clone(&their_features_var);
10952         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
10953         their_features_ref = tag_ptr(their_features_var.inner, their_features_var.is_owned);
10954         LDKShutdown msg_var = *msg;
10955         int64_t msg_ref = 0;
10956         msg_var = Shutdown_clone(&msg_var);
10957         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10958         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
10959         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10960         CHECK(obj != NULL);
10961         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
10962         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10963                 (*env)->ExceptionDescribe(env);
10964                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
10965         }
10966         if (get_jenv_res == JNI_EDETACHED) {
10967                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10968         }
10969 }
10970 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
10971         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10972         JNIEnv *env;
10973         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10974         if (get_jenv_res == JNI_EDETACHED) {
10975                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10976         } else {
10977                 DO_ASSERT(get_jenv_res == JNI_OK);
10978         }
10979         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10980         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10981         LDKClosingSigned msg_var = *msg;
10982         int64_t msg_ref = 0;
10983         msg_var = ClosingSigned_clone(&msg_var);
10984         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10985         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
10986         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10987         CHECK(obj != NULL);
10988         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
10989         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10990                 (*env)->ExceptionDescribe(env);
10991                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
10992         }
10993         if (get_jenv_res == JNI_EDETACHED) {
10994                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10995         }
10996 }
10997 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
10998         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10999         JNIEnv *env;
11000         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11001         if (get_jenv_res == JNI_EDETACHED) {
11002                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11003         } else {
11004                 DO_ASSERT(get_jenv_res == JNI_OK);
11005         }
11006         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11007         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11008         LDKUpdateAddHTLC msg_var = *msg;
11009         int64_t msg_ref = 0;
11010         msg_var = UpdateAddHTLC_clone(&msg_var);
11011         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11012         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11013         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11014         CHECK(obj != NULL);
11015         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
11016         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11017                 (*env)->ExceptionDescribe(env);
11018                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
11019         }
11020         if (get_jenv_res == JNI_EDETACHED) {
11021                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11022         }
11023 }
11024 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
11025         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11026         JNIEnv *env;
11027         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11028         if (get_jenv_res == JNI_EDETACHED) {
11029                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11030         } else {
11031                 DO_ASSERT(get_jenv_res == JNI_OK);
11032         }
11033         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11034         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11035         LDKUpdateFulfillHTLC msg_var = *msg;
11036         int64_t msg_ref = 0;
11037         msg_var = UpdateFulfillHTLC_clone(&msg_var);
11038         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11039         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11040         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11041         CHECK(obj != NULL);
11042         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
11043         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11044                 (*env)->ExceptionDescribe(env);
11045                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
11046         }
11047         if (get_jenv_res == JNI_EDETACHED) {
11048                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11049         }
11050 }
11051 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
11052         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11053         JNIEnv *env;
11054         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11055         if (get_jenv_res == JNI_EDETACHED) {
11056                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11057         } else {
11058                 DO_ASSERT(get_jenv_res == JNI_OK);
11059         }
11060         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11061         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11062         LDKUpdateFailHTLC msg_var = *msg;
11063         int64_t msg_ref = 0;
11064         msg_var = UpdateFailHTLC_clone(&msg_var);
11065         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11066         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11067         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11068         CHECK(obj != NULL);
11069         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
11070         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11071                 (*env)->ExceptionDescribe(env);
11072                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
11073         }
11074         if (get_jenv_res == JNI_EDETACHED) {
11075                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11076         }
11077 }
11078 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
11079         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11080         JNIEnv *env;
11081         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11082         if (get_jenv_res == JNI_EDETACHED) {
11083                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11084         } else {
11085                 DO_ASSERT(get_jenv_res == JNI_OK);
11086         }
11087         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11088         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11089         LDKUpdateFailMalformedHTLC msg_var = *msg;
11090         int64_t msg_ref = 0;
11091         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
11092         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11093         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11094         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11095         CHECK(obj != NULL);
11096         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
11097         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11098                 (*env)->ExceptionDescribe(env);
11099                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
11100         }
11101         if (get_jenv_res == JNI_EDETACHED) {
11102                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11103         }
11104 }
11105 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
11106         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11107         JNIEnv *env;
11108         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11109         if (get_jenv_res == JNI_EDETACHED) {
11110                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11111         } else {
11112                 DO_ASSERT(get_jenv_res == JNI_OK);
11113         }
11114         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11115         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11116         LDKCommitmentSigned msg_var = *msg;
11117         int64_t msg_ref = 0;
11118         msg_var = CommitmentSigned_clone(&msg_var);
11119         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11120         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11121         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11122         CHECK(obj != NULL);
11123         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
11124         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11125                 (*env)->ExceptionDescribe(env);
11126                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
11127         }
11128         if (get_jenv_res == JNI_EDETACHED) {
11129                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11130         }
11131 }
11132 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
11133         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11134         JNIEnv *env;
11135         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11136         if (get_jenv_res == JNI_EDETACHED) {
11137                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11138         } else {
11139                 DO_ASSERT(get_jenv_res == JNI_OK);
11140         }
11141         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11142         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11143         LDKRevokeAndACK msg_var = *msg;
11144         int64_t msg_ref = 0;
11145         msg_var = RevokeAndACK_clone(&msg_var);
11146         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11147         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11148         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11149         CHECK(obj != NULL);
11150         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
11151         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11152                 (*env)->ExceptionDescribe(env);
11153                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
11154         }
11155         if (get_jenv_res == JNI_EDETACHED) {
11156                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11157         }
11158 }
11159 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
11160         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11161         JNIEnv *env;
11162         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11163         if (get_jenv_res == JNI_EDETACHED) {
11164                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11165         } else {
11166                 DO_ASSERT(get_jenv_res == JNI_OK);
11167         }
11168         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11169         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11170         LDKUpdateFee msg_var = *msg;
11171         int64_t msg_ref = 0;
11172         msg_var = UpdateFee_clone(&msg_var);
11173         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11174         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11175         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11176         CHECK(obj != NULL);
11177         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
11178         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11179                 (*env)->ExceptionDescribe(env);
11180                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
11181         }
11182         if (get_jenv_res == JNI_EDETACHED) {
11183                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11184         }
11185 }
11186 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
11187         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11188         JNIEnv *env;
11189         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11190         if (get_jenv_res == JNI_EDETACHED) {
11191                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11192         } else {
11193                 DO_ASSERT(get_jenv_res == JNI_OK);
11194         }
11195         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11196         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11197         LDKAnnouncementSignatures msg_var = *msg;
11198         int64_t msg_ref = 0;
11199         msg_var = AnnouncementSignatures_clone(&msg_var);
11200         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11201         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11202         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11203         CHECK(obj != NULL);
11204         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
11205         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11206                 (*env)->ExceptionDescribe(env);
11207                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
11208         }
11209         if (get_jenv_res == JNI_EDETACHED) {
11210                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11211         }
11212 }
11213 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
11214         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11215         JNIEnv *env;
11216         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11217         if (get_jenv_res == JNI_EDETACHED) {
11218                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11219         } else {
11220                 DO_ASSERT(get_jenv_res == JNI_OK);
11221         }
11222         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11223         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11224         jboolean no_connection_possible_conv = no_connection_possible;
11225         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11226         CHECK(obj != NULL);
11227         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible_conv);
11228         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11229                 (*env)->ExceptionDescribe(env);
11230                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
11231         }
11232         if (get_jenv_res == JNI_EDETACHED) {
11233                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11234         }
11235 }
11236 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
11237         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11238         JNIEnv *env;
11239         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11240         if (get_jenv_res == JNI_EDETACHED) {
11241                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11242         } else {
11243                 DO_ASSERT(get_jenv_res == JNI_OK);
11244         }
11245         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11246         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11247         LDKInit msg_var = *msg;
11248         int64_t msg_ref = 0;
11249         msg_var = Init_clone(&msg_var);
11250         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11251         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11252         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11253         CHECK(obj != NULL);
11254         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
11255         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11256                 (*env)->ExceptionDescribe(env);
11257                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
11258         }
11259         if (get_jenv_res == JNI_EDETACHED) {
11260                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11261         }
11262 }
11263 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
11264         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11265         JNIEnv *env;
11266         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11267         if (get_jenv_res == JNI_EDETACHED) {
11268                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11269         } else {
11270                 DO_ASSERT(get_jenv_res == JNI_OK);
11271         }
11272         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11273         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11274         LDKChannelReestablish msg_var = *msg;
11275         int64_t msg_ref = 0;
11276         msg_var = ChannelReestablish_clone(&msg_var);
11277         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11278         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11279         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11280         CHECK(obj != NULL);
11281         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
11282         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11283                 (*env)->ExceptionDescribe(env);
11284                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
11285         }
11286         if (get_jenv_res == JNI_EDETACHED) {
11287                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11288         }
11289 }
11290 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
11291         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11292         JNIEnv *env;
11293         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11294         if (get_jenv_res == JNI_EDETACHED) {
11295                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11296         } else {
11297                 DO_ASSERT(get_jenv_res == JNI_OK);
11298         }
11299         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11300         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11301         LDKChannelUpdate msg_var = *msg;
11302         int64_t msg_ref = 0;
11303         msg_var = ChannelUpdate_clone(&msg_var);
11304         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11305         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11306         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11307         CHECK(obj != NULL);
11308         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
11309         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11310                 (*env)->ExceptionDescribe(env);
11311                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
11312         }
11313         if (get_jenv_res == JNI_EDETACHED) {
11314                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11315         }
11316 }
11317 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
11318         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11319         JNIEnv *env;
11320         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11321         if (get_jenv_res == JNI_EDETACHED) {
11322                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11323         } else {
11324                 DO_ASSERT(get_jenv_res == JNI_OK);
11325         }
11326         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11327         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11328         LDKErrorMessage msg_var = *msg;
11329         int64_t msg_ref = 0;
11330         msg_var = ErrorMessage_clone(&msg_var);
11331         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11332         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11333         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11334         CHECK(obj != NULL);
11335         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
11336         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11337                 (*env)->ExceptionDescribe(env);
11338                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
11339         }
11340         if (get_jenv_res == JNI_EDETACHED) {
11341                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11342         }
11343 }
11344 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
11345         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
11346         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11347         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
11348 }
11349 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
11350         jclass c = (*env)->GetObjectClass(env, o);
11351         CHECK(c != NULL);
11352         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
11353         atomic_init(&calls->refcnt, 1);
11354         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11355         calls->o = (*env)->NewWeakGlobalRef(env, o);
11356         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
11357         CHECK(calls->handle_open_channel_meth != NULL);
11358         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
11359         CHECK(calls->handle_accept_channel_meth != NULL);
11360         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
11361         CHECK(calls->handle_funding_created_meth != NULL);
11362         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
11363         CHECK(calls->handle_funding_signed_meth != NULL);
11364         calls->handle_channel_ready_meth = (*env)->GetMethodID(env, c, "handle_channel_ready", "([BJ)V");
11365         CHECK(calls->handle_channel_ready_meth != NULL);
11366         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
11367         CHECK(calls->handle_shutdown_meth != NULL);
11368         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
11369         CHECK(calls->handle_closing_signed_meth != NULL);
11370         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
11371         CHECK(calls->handle_update_add_htlc_meth != NULL);
11372         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
11373         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
11374         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
11375         CHECK(calls->handle_update_fail_htlc_meth != NULL);
11376         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
11377         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
11378         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
11379         CHECK(calls->handle_commitment_signed_meth != NULL);
11380         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
11381         CHECK(calls->handle_revoke_and_ack_meth != NULL);
11382         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
11383         CHECK(calls->handle_update_fee_meth != NULL);
11384         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
11385         CHECK(calls->handle_announcement_signatures_meth != NULL);
11386         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
11387         CHECK(calls->peer_disconnected_meth != NULL);
11388         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
11389         CHECK(calls->peer_connected_meth != NULL);
11390         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
11391         CHECK(calls->handle_channel_reestablish_meth != NULL);
11392         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
11393         CHECK(calls->handle_channel_update_meth != NULL);
11394         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
11395         CHECK(calls->handle_error_meth != NULL);
11396
11397         LDKChannelMessageHandler ret = {
11398                 .this_arg = (void*) calls,
11399                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
11400                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
11401                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
11402                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
11403                 .handle_channel_ready = handle_channel_ready_LDKChannelMessageHandler_jcall,
11404                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
11405                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
11406                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
11407                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
11408                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
11409                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
11410                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
11411                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
11412                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
11413                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
11414                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
11415                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
11416                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
11417                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
11418                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
11419                 .free = LDKChannelMessageHandler_JCalls_free,
11420                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
11421         };
11422         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
11423         return ret;
11424 }
11425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
11426         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
11427         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
11428         return tag_ptr(res_ptr, true);
11429 }
11430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
11431         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)untag_ptr(arg);
11432         return tag_ptr(&inp->MessageSendEventsProvider, false);
11433 }
11434 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) {
11435         void* this_arg_ptr = untag_ptr(this_arg);
11436         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11437         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11438         LDKPublicKey their_node_id_ref;
11439         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11440         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11441         LDKInitFeatures their_features_conv;
11442         their_features_conv.inner = untag_ptr(their_features);
11443         their_features_conv.is_owned = ptr_is_owned(their_features);
11444         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
11445         their_features_conv = InitFeatures_clone(&their_features_conv);
11446         LDKOpenChannel msg_conv;
11447         msg_conv.inner = untag_ptr(msg);
11448         msg_conv.is_owned = ptr_is_owned(msg);
11449         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11450         msg_conv.is_owned = false;
11451         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
11452 }
11453
11454 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) {
11455         void* this_arg_ptr = untag_ptr(this_arg);
11456         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11457         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11458         LDKPublicKey their_node_id_ref;
11459         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11460         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11461         LDKInitFeatures their_features_conv;
11462         their_features_conv.inner = untag_ptr(their_features);
11463         their_features_conv.is_owned = ptr_is_owned(their_features);
11464         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
11465         their_features_conv = InitFeatures_clone(&their_features_conv);
11466         LDKAcceptChannel msg_conv;
11467         msg_conv.inner = untag_ptr(msg);
11468         msg_conv.is_owned = ptr_is_owned(msg);
11469         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11470         msg_conv.is_owned = false;
11471         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
11472 }
11473
11474 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) {
11475         void* this_arg_ptr = untag_ptr(this_arg);
11476         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11477         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11478         LDKPublicKey their_node_id_ref;
11479         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11480         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11481         LDKFundingCreated msg_conv;
11482         msg_conv.inner = untag_ptr(msg);
11483         msg_conv.is_owned = ptr_is_owned(msg);
11484         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11485         msg_conv.is_owned = false;
11486         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11487 }
11488
11489 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) {
11490         void* this_arg_ptr = untag_ptr(this_arg);
11491         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11492         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11493         LDKPublicKey their_node_id_ref;
11494         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11495         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11496         LDKFundingSigned msg_conv;
11497         msg_conv.inner = untag_ptr(msg);
11498         msg_conv.is_owned = ptr_is_owned(msg);
11499         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11500         msg_conv.is_owned = false;
11501         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11502 }
11503
11504 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) {
11505         void* this_arg_ptr = untag_ptr(this_arg);
11506         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11507         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11508         LDKPublicKey their_node_id_ref;
11509         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11510         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11511         LDKChannelReady msg_conv;
11512         msg_conv.inner = untag_ptr(msg);
11513         msg_conv.is_owned = ptr_is_owned(msg);
11514         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11515         msg_conv.is_owned = false;
11516         (this_arg_conv->handle_channel_ready)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11517 }
11518
11519 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) {
11520         void* this_arg_ptr = untag_ptr(this_arg);
11521         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11522         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11523         LDKPublicKey their_node_id_ref;
11524         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11525         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11526         LDKInitFeatures their_features_conv;
11527         their_features_conv.inner = untag_ptr(their_features);
11528         their_features_conv.is_owned = ptr_is_owned(their_features);
11529         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
11530         their_features_conv.is_owned = false;
11531         LDKShutdown msg_conv;
11532         msg_conv.inner = untag_ptr(msg);
11533         msg_conv.is_owned = ptr_is_owned(msg);
11534         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11535         msg_conv.is_owned = false;
11536         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
11537 }
11538
11539 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) {
11540         void* this_arg_ptr = untag_ptr(this_arg);
11541         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11542         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11543         LDKPublicKey their_node_id_ref;
11544         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11545         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11546         LDKClosingSigned msg_conv;
11547         msg_conv.inner = untag_ptr(msg);
11548         msg_conv.is_owned = ptr_is_owned(msg);
11549         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11550         msg_conv.is_owned = false;
11551         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11552 }
11553
11554 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) {
11555         void* this_arg_ptr = untag_ptr(this_arg);
11556         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11557         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11558         LDKPublicKey their_node_id_ref;
11559         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11560         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11561         LDKUpdateAddHTLC msg_conv;
11562         msg_conv.inner = untag_ptr(msg);
11563         msg_conv.is_owned = ptr_is_owned(msg);
11564         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11565         msg_conv.is_owned = false;
11566         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11567 }
11568
11569 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) {
11570         void* this_arg_ptr = untag_ptr(this_arg);
11571         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11572         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11573         LDKPublicKey their_node_id_ref;
11574         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11575         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11576         LDKUpdateFulfillHTLC msg_conv;
11577         msg_conv.inner = untag_ptr(msg);
11578         msg_conv.is_owned = ptr_is_owned(msg);
11579         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11580         msg_conv.is_owned = false;
11581         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11582 }
11583
11584 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) {
11585         void* this_arg_ptr = untag_ptr(this_arg);
11586         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11587         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11588         LDKPublicKey their_node_id_ref;
11589         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11590         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11591         LDKUpdateFailHTLC msg_conv;
11592         msg_conv.inner = untag_ptr(msg);
11593         msg_conv.is_owned = ptr_is_owned(msg);
11594         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11595         msg_conv.is_owned = false;
11596         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11597 }
11598
11599 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) {
11600         void* this_arg_ptr = untag_ptr(this_arg);
11601         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11602         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11603         LDKPublicKey their_node_id_ref;
11604         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11605         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11606         LDKUpdateFailMalformedHTLC msg_conv;
11607         msg_conv.inner = untag_ptr(msg);
11608         msg_conv.is_owned = ptr_is_owned(msg);
11609         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11610         msg_conv.is_owned = false;
11611         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11612 }
11613
11614 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) {
11615         void* this_arg_ptr = untag_ptr(this_arg);
11616         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11617         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11618         LDKPublicKey their_node_id_ref;
11619         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11620         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11621         LDKCommitmentSigned msg_conv;
11622         msg_conv.inner = untag_ptr(msg);
11623         msg_conv.is_owned = ptr_is_owned(msg);
11624         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11625         msg_conv.is_owned = false;
11626         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11627 }
11628
11629 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) {
11630         void* this_arg_ptr = untag_ptr(this_arg);
11631         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11632         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11633         LDKPublicKey their_node_id_ref;
11634         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11635         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11636         LDKRevokeAndACK msg_conv;
11637         msg_conv.inner = untag_ptr(msg);
11638         msg_conv.is_owned = ptr_is_owned(msg);
11639         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11640         msg_conv.is_owned = false;
11641         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11642 }
11643
11644 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) {
11645         void* this_arg_ptr = untag_ptr(this_arg);
11646         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11647         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11648         LDKPublicKey their_node_id_ref;
11649         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11650         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11651         LDKUpdateFee msg_conv;
11652         msg_conv.inner = untag_ptr(msg);
11653         msg_conv.is_owned = ptr_is_owned(msg);
11654         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11655         msg_conv.is_owned = false;
11656         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11657 }
11658
11659 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) {
11660         void* this_arg_ptr = untag_ptr(this_arg);
11661         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11662         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11663         LDKPublicKey their_node_id_ref;
11664         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11665         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11666         LDKAnnouncementSignatures msg_conv;
11667         msg_conv.inner = untag_ptr(msg);
11668         msg_conv.is_owned = ptr_is_owned(msg);
11669         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11670         msg_conv.is_owned = false;
11671         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11672 }
11673
11674 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) {
11675         void* this_arg_ptr = untag_ptr(this_arg);
11676         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11677         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11678         LDKPublicKey their_node_id_ref;
11679         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11680         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11681         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
11682 }
11683
11684 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) {
11685         void* this_arg_ptr = untag_ptr(this_arg);
11686         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11687         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11688         LDKPublicKey their_node_id_ref;
11689         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11690         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11691         LDKInit msg_conv;
11692         msg_conv.inner = untag_ptr(msg);
11693         msg_conv.is_owned = ptr_is_owned(msg);
11694         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11695         msg_conv.is_owned = false;
11696         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11697 }
11698
11699 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) {
11700         void* this_arg_ptr = untag_ptr(this_arg);
11701         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11702         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11703         LDKPublicKey their_node_id_ref;
11704         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11705         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11706         LDKChannelReestablish msg_conv;
11707         msg_conv.inner = untag_ptr(msg);
11708         msg_conv.is_owned = ptr_is_owned(msg);
11709         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11710         msg_conv.is_owned = false;
11711         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11712 }
11713
11714 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) {
11715         void* this_arg_ptr = untag_ptr(this_arg);
11716         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11717         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11718         LDKPublicKey their_node_id_ref;
11719         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11720         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11721         LDKChannelUpdate msg_conv;
11722         msg_conv.inner = untag_ptr(msg);
11723         msg_conv.is_owned = ptr_is_owned(msg);
11724         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11725         msg_conv.is_owned = false;
11726         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11727 }
11728
11729 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) {
11730         void* this_arg_ptr = untag_ptr(this_arg);
11731         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11732         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11733         LDKPublicKey their_node_id_ref;
11734         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11735         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11736         LDKErrorMessage msg_conv;
11737         msg_conv.inner = untag_ptr(msg);
11738         msg_conv.is_owned = ptr_is_owned(msg);
11739         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11740         msg_conv.is_owned = false;
11741         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11742 }
11743
11744 typedef struct LDKRoutingMessageHandler_JCalls {
11745         atomic_size_t refcnt;
11746         JavaVM *vm;
11747         jweak o;
11748         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
11749         jmethodID handle_node_announcement_meth;
11750         jmethodID handle_channel_announcement_meth;
11751         jmethodID handle_channel_update_meth;
11752         jmethodID get_next_channel_announcements_meth;
11753         jmethodID get_next_node_announcements_meth;
11754         jmethodID peer_connected_meth;
11755         jmethodID handle_reply_channel_range_meth;
11756         jmethodID handle_reply_short_channel_ids_end_meth;
11757         jmethodID handle_query_channel_range_meth;
11758         jmethodID handle_query_short_channel_ids_meth;
11759 } LDKRoutingMessageHandler_JCalls;
11760 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
11761         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11762         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11763                 JNIEnv *env;
11764                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11765                 if (get_jenv_res == JNI_EDETACHED) {
11766                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11767                 } else {
11768                         DO_ASSERT(get_jenv_res == JNI_OK);
11769                 }
11770                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11771                 if (get_jenv_res == JNI_EDETACHED) {
11772                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11773                 }
11774                 FREE(j_calls);
11775         }
11776 }
11777 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
11778         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11779         JNIEnv *env;
11780         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11781         if (get_jenv_res == JNI_EDETACHED) {
11782                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11783         } else {
11784                 DO_ASSERT(get_jenv_res == JNI_OK);
11785         }
11786         LDKNodeAnnouncement msg_var = *msg;
11787         int64_t msg_ref = 0;
11788         msg_var = NodeAnnouncement_clone(&msg_var);
11789         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11790         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11791         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11792         CHECK(obj != NULL);
11793         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
11794         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11795                 (*env)->ExceptionDescribe(env);
11796                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
11797         }
11798         void* ret_ptr = untag_ptr(ret);
11799         CHECK_ACCESS(ret_ptr);
11800         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
11801         FREE(untag_ptr(ret));
11802         if (get_jenv_res == JNI_EDETACHED) {
11803                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11804         }
11805         return ret_conv;
11806 }
11807 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
11808         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_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         LDKChannelAnnouncement msg_var = *msg;
11817         int64_t msg_ref = 0;
11818         msg_var = ChannelAnnouncement_clone(&msg_var);
11819         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11820         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11821         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11822         CHECK(obj != NULL);
11823         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
11824         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11825                 (*env)->ExceptionDescribe(env);
11826                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
11827         }
11828         void* ret_ptr = untag_ptr(ret);
11829         CHECK_ACCESS(ret_ptr);
11830         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
11831         FREE(untag_ptr(ret));
11832         if (get_jenv_res == JNI_EDETACHED) {
11833                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11834         }
11835         return ret_conv;
11836 }
11837 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
11838         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11839         JNIEnv *env;
11840         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11841         if (get_jenv_res == JNI_EDETACHED) {
11842                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11843         } else {
11844                 DO_ASSERT(get_jenv_res == JNI_OK);
11845         }
11846         LDKChannelUpdate msg_var = *msg;
11847         int64_t msg_ref = 0;
11848         msg_var = ChannelUpdate_clone(&msg_var);
11849         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11850         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11851         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11852         CHECK(obj != NULL);
11853         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
11854         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11855                 (*env)->ExceptionDescribe(env);
11856                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
11857         }
11858         void* ret_ptr = untag_ptr(ret);
11859         CHECK_ACCESS(ret_ptr);
11860         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
11861         FREE(untag_ptr(ret));
11862         if (get_jenv_res == JNI_EDETACHED) {
11863                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11864         }
11865         return ret_conv;
11866 }
11867 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
11868         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11869         JNIEnv *env;
11870         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11871         if (get_jenv_res == JNI_EDETACHED) {
11872                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11873         } else {
11874                 DO_ASSERT(get_jenv_res == JNI_OK);
11875         }
11876         int64_t starting_point_conv = starting_point;
11877         int8_t batch_amount_conv = batch_amount;
11878         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11879         CHECK(obj != NULL);
11880         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point_conv, batch_amount_conv);
11881         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11882                 (*env)->ExceptionDescribe(env);
11883                 (*env)->FatalError(env, "A call to get_next_channel_announcements in LDKRoutingMessageHandler from rust threw an exception.");
11884         }
11885         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
11886         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
11887         if (ret_constr.datalen > 0)
11888                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
11889         else
11890                 ret_constr.data = NULL;
11891         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
11892         for (size_t h = 0; h < ret_constr.datalen; h++) {
11893                 int64_t ret_conv_59 = ret_vals[h];
11894                 void* ret_conv_59_ptr = untag_ptr(ret_conv_59);
11895                 CHECK_ACCESS(ret_conv_59_ptr);
11896                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
11897                 FREE(untag_ptr(ret_conv_59));
11898                 ret_constr.data[h] = ret_conv_59_conv;
11899         }
11900         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
11901         if (get_jenv_res == JNI_EDETACHED) {
11902                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11903         }
11904         return ret_constr;
11905 }
11906 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
11907         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11908         JNIEnv *env;
11909         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11910         if (get_jenv_res == JNI_EDETACHED) {
11911                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11912         } else {
11913                 DO_ASSERT(get_jenv_res == JNI_OK);
11914         }
11915         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
11916         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
11917         int8_t batch_amount_conv = batch_amount;
11918         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11919         CHECK(obj != NULL);
11920         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount_conv);
11921         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11922                 (*env)->ExceptionDescribe(env);
11923                 (*env)->FatalError(env, "A call to get_next_node_announcements in LDKRoutingMessageHandler from rust threw an exception.");
11924         }
11925         LDKCVec_NodeAnnouncementZ ret_constr;
11926         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
11927         if (ret_constr.datalen > 0)
11928                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
11929         else
11930                 ret_constr.data = NULL;
11931         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
11932         for (size_t s = 0; s < ret_constr.datalen; s++) {
11933                 int64_t ret_conv_18 = ret_vals[s];
11934                 LDKNodeAnnouncement ret_conv_18_conv;
11935                 ret_conv_18_conv.inner = untag_ptr(ret_conv_18);
11936                 ret_conv_18_conv.is_owned = ptr_is_owned(ret_conv_18);
11937                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
11938                 ret_constr.data[s] = ret_conv_18_conv;
11939         }
11940         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
11941         if (get_jenv_res == JNI_EDETACHED) {
11942                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11943         }
11944         return ret_constr;
11945 }
11946 void peer_connected_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
11947         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11948         JNIEnv *env;
11949         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11950         if (get_jenv_res == JNI_EDETACHED) {
11951                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11952         } else {
11953                 DO_ASSERT(get_jenv_res == JNI_OK);
11954         }
11955         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11956         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11957         LDKInit init_var = *init;
11958         int64_t init_ref = 0;
11959         init_var = Init_clone(&init_var);
11960         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
11961         init_ref = tag_ptr(init_var.inner, init_var.is_owned);
11962         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11963         CHECK(obj != NULL);
11964         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, init_ref);
11965         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11966                 (*env)->ExceptionDescribe(env);
11967                 (*env)->FatalError(env, "A call to peer_connected in LDKRoutingMessageHandler from rust threw an exception.");
11968         }
11969         if (get_jenv_res == JNI_EDETACHED) {
11970                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11971         }
11972 }
11973 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
11974         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11975         JNIEnv *env;
11976         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11977         if (get_jenv_res == JNI_EDETACHED) {
11978                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11979         } else {
11980                 DO_ASSERT(get_jenv_res == JNI_OK);
11981         }
11982         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11983         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11984         LDKReplyChannelRange msg_var = msg;
11985         int64_t msg_ref = 0;
11986         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11987         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11988         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11989         CHECK(obj != NULL);
11990         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
11991         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11992                 (*env)->ExceptionDescribe(env);
11993                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
11994         }
11995         void* ret_ptr = untag_ptr(ret);
11996         CHECK_ACCESS(ret_ptr);
11997         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
11998         FREE(untag_ptr(ret));
11999         if (get_jenv_res == JNI_EDETACHED) {
12000                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12001         }
12002         return ret_conv;
12003 }
12004 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
12005         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12006         JNIEnv *env;
12007         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12008         if (get_jenv_res == JNI_EDETACHED) {
12009                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12010         } else {
12011                 DO_ASSERT(get_jenv_res == JNI_OK);
12012         }
12013         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12014         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12015         LDKReplyShortChannelIdsEnd msg_var = msg;
12016         int64_t msg_ref = 0;
12017         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12018         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12019         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12020         CHECK(obj != NULL);
12021         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
12022         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12023                 (*env)->ExceptionDescribe(env);
12024                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
12025         }
12026         void* ret_ptr = untag_ptr(ret);
12027         CHECK_ACCESS(ret_ptr);
12028         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12029         FREE(untag_ptr(ret));
12030         if (get_jenv_res == JNI_EDETACHED) {
12031                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12032         }
12033         return ret_conv;
12034 }
12035 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
12036         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12037         JNIEnv *env;
12038         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12039         if (get_jenv_res == JNI_EDETACHED) {
12040                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12041         } else {
12042                 DO_ASSERT(get_jenv_res == JNI_OK);
12043         }
12044         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12045         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12046         LDKQueryChannelRange msg_var = msg;
12047         int64_t msg_ref = 0;
12048         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12049         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12050         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12051         CHECK(obj != NULL);
12052         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
12053         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12054                 (*env)->ExceptionDescribe(env);
12055                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
12056         }
12057         void* ret_ptr = untag_ptr(ret);
12058         CHECK_ACCESS(ret_ptr);
12059         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12060         FREE(untag_ptr(ret));
12061         if (get_jenv_res == JNI_EDETACHED) {
12062                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12063         }
12064         return ret_conv;
12065 }
12066 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
12067         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12068         JNIEnv *env;
12069         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12070         if (get_jenv_res == JNI_EDETACHED) {
12071                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12072         } else {
12073                 DO_ASSERT(get_jenv_res == JNI_OK);
12074         }
12075         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12076         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12077         LDKQueryShortChannelIds msg_var = msg;
12078         int64_t msg_ref = 0;
12079         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12080         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12081         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12082         CHECK(obj != NULL);
12083         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
12084         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12085                 (*env)->ExceptionDescribe(env);
12086                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
12087         }
12088         void* ret_ptr = untag_ptr(ret);
12089         CHECK_ACCESS(ret_ptr);
12090         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12091         FREE(untag_ptr(ret));
12092         if (get_jenv_res == JNI_EDETACHED) {
12093                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12094         }
12095         return ret_conv;
12096 }
12097 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
12098         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
12099         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12100         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
12101 }
12102 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12103         jclass c = (*env)->GetObjectClass(env, o);
12104         CHECK(c != NULL);
12105         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
12106         atomic_init(&calls->refcnt, 1);
12107         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12108         calls->o = (*env)->NewWeakGlobalRef(env, o);
12109         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
12110         CHECK(calls->handle_node_announcement_meth != NULL);
12111         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
12112         CHECK(calls->handle_channel_announcement_meth != NULL);
12113         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
12114         CHECK(calls->handle_channel_update_meth != NULL);
12115         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
12116         CHECK(calls->get_next_channel_announcements_meth != NULL);
12117         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
12118         CHECK(calls->get_next_node_announcements_meth != NULL);
12119         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
12120         CHECK(calls->peer_connected_meth != NULL);
12121         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
12122         CHECK(calls->handle_reply_channel_range_meth != NULL);
12123         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
12124         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
12125         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
12126         CHECK(calls->handle_query_channel_range_meth != NULL);
12127         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
12128         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
12129
12130         LDKRoutingMessageHandler ret = {
12131                 .this_arg = (void*) calls,
12132                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
12133                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
12134                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
12135                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
12136                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
12137                 .peer_connected = peer_connected_LDKRoutingMessageHandler_jcall,
12138                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
12139                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
12140                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
12141                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
12142                 .free = LDKRoutingMessageHandler_JCalls_free,
12143                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
12144         };
12145         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
12146         return ret;
12147 }
12148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12149         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
12150         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
12151         return tag_ptr(res_ptr, true);
12152 }
12153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
12154         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)untag_ptr(arg);
12155         return tag_ptr(&inp->MessageSendEventsProvider, false);
12156 }
12157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
12158         void* this_arg_ptr = untag_ptr(this_arg);
12159         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12160         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12161         LDKNodeAnnouncement msg_conv;
12162         msg_conv.inner = untag_ptr(msg);
12163         msg_conv.is_owned = ptr_is_owned(msg);
12164         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12165         msg_conv.is_owned = false;
12166         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
12167         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
12168         return tag_ptr(ret_conv, true);
12169 }
12170
12171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
12172         void* this_arg_ptr = untag_ptr(this_arg);
12173         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12174         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12175         LDKChannelAnnouncement msg_conv;
12176         msg_conv.inner = untag_ptr(msg);
12177         msg_conv.is_owned = ptr_is_owned(msg);
12178         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12179         msg_conv.is_owned = false;
12180         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
12181         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
12182         return tag_ptr(ret_conv, true);
12183 }
12184
12185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
12186         void* this_arg_ptr = untag_ptr(this_arg);
12187         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12188         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12189         LDKChannelUpdate msg_conv;
12190         msg_conv.inner = untag_ptr(msg);
12191         msg_conv.is_owned = ptr_is_owned(msg);
12192         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12193         msg_conv.is_owned = false;
12194         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
12195         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
12196         return tag_ptr(ret_conv, true);
12197 }
12198
12199 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1channel_1announcements(JNIEnv *env, jclass clz, int64_t this_arg, int64_t starting_point, int8_t batch_amount) {
12200         void* this_arg_ptr = untag_ptr(this_arg);
12201         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12202         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12203         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
12204         int64_tArray ret_arr = NULL;
12205         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
12206         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
12207         for (size_t h = 0; h < ret_var.datalen; h++) {
12208                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
12209                 *ret_conv_59_conv = ret_var.data[h];
12210                 ret_arr_ptr[h] = tag_ptr(ret_conv_59_conv, true);
12211         }
12212         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
12213         FREE(ret_var.data);
12214         return ret_arr;
12215 }
12216
12217 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1node_1announcements(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray starting_point, int8_t batch_amount) {
12218         void* this_arg_ptr = untag_ptr(this_arg);
12219         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12220         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12221         LDKPublicKey starting_point_ref;
12222         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
12223         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
12224         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
12225         int64_tArray ret_arr = NULL;
12226         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
12227         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
12228         for (size_t s = 0; s < ret_var.datalen; s++) {
12229                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
12230                 int64_t ret_conv_18_ref = 0;
12231                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
12232                 ret_conv_18_ref = tag_ptr(ret_conv_18_var.inner, ret_conv_18_var.is_owned);
12233                 ret_arr_ptr[s] = ret_conv_18_ref;
12234         }
12235         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
12236         FREE(ret_var.data);
12237         return ret_arr;
12238 }
12239
12240 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) {
12241         void* this_arg_ptr = untag_ptr(this_arg);
12242         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12243         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12244         LDKPublicKey their_node_id_ref;
12245         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12246         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12247         LDKInit init_conv;
12248         init_conv.inner = untag_ptr(init);
12249         init_conv.is_owned = ptr_is_owned(init);
12250         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
12251         init_conv.is_owned = false;
12252         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
12253 }
12254
12255 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) {
12256         void* this_arg_ptr = untag_ptr(this_arg);
12257         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12258         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12259         LDKPublicKey their_node_id_ref;
12260         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12261         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12262         LDKReplyChannelRange msg_conv;
12263         msg_conv.inner = untag_ptr(msg);
12264         msg_conv.is_owned = ptr_is_owned(msg);
12265         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12266         msg_conv = ReplyChannelRange_clone(&msg_conv);
12267         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
12268         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
12269         return tag_ptr(ret_conv, true);
12270 }
12271
12272 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) {
12273         void* this_arg_ptr = untag_ptr(this_arg);
12274         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12275         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12276         LDKPublicKey their_node_id_ref;
12277         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12278         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12279         LDKReplyShortChannelIdsEnd msg_conv;
12280         msg_conv.inner = untag_ptr(msg);
12281         msg_conv.is_owned = ptr_is_owned(msg);
12282         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12283         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
12284         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
12285         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
12286         return tag_ptr(ret_conv, true);
12287 }
12288
12289 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) {
12290         void* this_arg_ptr = untag_ptr(this_arg);
12291         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12292         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12293         LDKPublicKey their_node_id_ref;
12294         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12295         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12296         LDKQueryChannelRange msg_conv;
12297         msg_conv.inner = untag_ptr(msg);
12298         msg_conv.is_owned = ptr_is_owned(msg);
12299         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12300         msg_conv = QueryChannelRange_clone(&msg_conv);
12301         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
12302         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
12303         return tag_ptr(ret_conv, true);
12304 }
12305
12306 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) {
12307         void* this_arg_ptr = untag_ptr(this_arg);
12308         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12309         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12310         LDKPublicKey their_node_id_ref;
12311         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12312         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12313         LDKQueryShortChannelIds msg_conv;
12314         msg_conv.inner = untag_ptr(msg);
12315         msg_conv.is_owned = ptr_is_owned(msg);
12316         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12317         msg_conv = QueryShortChannelIds_clone(&msg_conv);
12318         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
12319         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
12320         return tag_ptr(ret_conv, true);
12321 }
12322
12323 typedef struct LDKCustomMessageReader_JCalls {
12324         atomic_size_t refcnt;
12325         JavaVM *vm;
12326         jweak o;
12327         jmethodID read_meth;
12328 } LDKCustomMessageReader_JCalls;
12329 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
12330         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
12331         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12332                 JNIEnv *env;
12333                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12334                 if (get_jenv_res == JNI_EDETACHED) {
12335                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12336                 } else {
12337                         DO_ASSERT(get_jenv_res == JNI_OK);
12338                 }
12339                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12340                 if (get_jenv_res == JNI_EDETACHED) {
12341                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12342                 }
12343                 FREE(j_calls);
12344         }
12345 }
12346 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
12347         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
12348         JNIEnv *env;
12349         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12350         if (get_jenv_res == JNI_EDETACHED) {
12351                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12352         } else {
12353                 DO_ASSERT(get_jenv_res == JNI_OK);
12354         }
12355         int16_t message_type_conv = message_type;
12356         LDKu8slice buffer_var = buffer;
12357         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
12358         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
12359         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12360         CHECK(obj != NULL);
12361         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_meth, message_type_conv, buffer_arr);
12362         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12363                 (*env)->ExceptionDescribe(env);
12364                 (*env)->FatalError(env, "A call to read in LDKCustomMessageReader from rust threw an exception.");
12365         }
12366         void* ret_ptr = untag_ptr(ret);
12367         CHECK_ACCESS(ret_ptr);
12368         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
12369         FREE(untag_ptr(ret));
12370         if (get_jenv_res == JNI_EDETACHED) {
12371                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12372         }
12373         return ret_conv;
12374 }
12375 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
12376         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
12377         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12378 }
12379 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JNIEnv *env, jclass clz, jobject o) {
12380         jclass c = (*env)->GetObjectClass(env, o);
12381         CHECK(c != NULL);
12382         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
12383         atomic_init(&calls->refcnt, 1);
12384         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12385         calls->o = (*env)->NewWeakGlobalRef(env, o);
12386         calls->read_meth = (*env)->GetMethodID(env, c, "read", "(S[B)J");
12387         CHECK(calls->read_meth != NULL);
12388
12389         LDKCustomMessageReader ret = {
12390                 .this_arg = (void*) calls,
12391                 .read = read_LDKCustomMessageReader_jcall,
12392                 .free = LDKCustomMessageReader_JCalls_free,
12393         };
12394         return ret;
12395 }
12396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new(JNIEnv *env, jclass clz, jobject o) {
12397         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
12398         *res_ptr = LDKCustomMessageReader_init(env, clz, o);
12399         return tag_ptr(res_ptr, true);
12400 }
12401 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) {
12402         void* this_arg_ptr = untag_ptr(this_arg);
12403         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12404         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
12405         LDKu8slice buffer_ref;
12406         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
12407         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
12408         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
12409         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
12410         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
12411         return tag_ptr(ret_conv, true);
12412 }
12413
12414 typedef struct LDKCustomMessageHandler_JCalls {
12415         atomic_size_t refcnt;
12416         JavaVM *vm;
12417         jweak o;
12418         LDKCustomMessageReader_JCalls* CustomMessageReader;
12419         jmethodID handle_custom_message_meth;
12420         jmethodID get_and_clear_pending_msg_meth;
12421 } LDKCustomMessageHandler_JCalls;
12422 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
12423         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
12424         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12425                 JNIEnv *env;
12426                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12427                 if (get_jenv_res == JNI_EDETACHED) {
12428                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12429                 } else {
12430                         DO_ASSERT(get_jenv_res == JNI_OK);
12431                 }
12432                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12433                 if (get_jenv_res == JNI_EDETACHED) {
12434                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12435                 }
12436                 FREE(j_calls);
12437         }
12438 }
12439 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
12440         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
12441         JNIEnv *env;
12442         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12443         if (get_jenv_res == JNI_EDETACHED) {
12444                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12445         } else {
12446                 DO_ASSERT(get_jenv_res == JNI_OK);
12447         }
12448         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
12449         *msg_ret = msg;
12450         int8_tArray sender_node_id_arr = (*env)->NewByteArray(env, 33);
12451         (*env)->SetByteArrayRegion(env, sender_node_id_arr, 0, 33, sender_node_id.compressed_form);
12452         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12453         CHECK(obj != NULL);
12454         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_custom_message_meth, tag_ptr(msg_ret, true), sender_node_id_arr);
12455         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12456                 (*env)->ExceptionDescribe(env);
12457                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomMessageHandler from rust threw an exception.");
12458         }
12459         void* ret_ptr = untag_ptr(ret);
12460         CHECK_ACCESS(ret_ptr);
12461         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12462         FREE(untag_ptr(ret));
12463         if (get_jenv_res == JNI_EDETACHED) {
12464                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12465         }
12466         return ret_conv;
12467 }
12468 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
12469         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
12470         JNIEnv *env;
12471         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12472         if (get_jenv_res == JNI_EDETACHED) {
12473                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12474         } else {
12475                 DO_ASSERT(get_jenv_res == JNI_OK);
12476         }
12477         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12478         CHECK(obj != NULL);
12479         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_meth);
12480         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12481                 (*env)->ExceptionDescribe(env);
12482                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg in LDKCustomMessageHandler from rust threw an exception.");
12483         }
12484         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
12485         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
12486         if (ret_constr.datalen > 0)
12487                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
12488         else
12489                 ret_constr.data = NULL;
12490         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
12491         for (size_t z = 0; z < ret_constr.datalen; z++) {
12492                 int64_t ret_conv_25 = ret_vals[z];
12493                 void* ret_conv_25_ptr = untag_ptr(ret_conv_25);
12494                 CHECK_ACCESS(ret_conv_25_ptr);
12495                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
12496                 FREE(untag_ptr(ret_conv_25));
12497                 ret_constr.data[z] = ret_conv_25_conv;
12498         }
12499         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
12500         if (get_jenv_res == JNI_EDETACHED) {
12501                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12502         }
12503         return ret_constr;
12504 }
12505 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
12506         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
12507         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12508         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
12509 }
12510 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
12511         jclass c = (*env)->GetObjectClass(env, o);
12512         CHECK(c != NULL);
12513         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
12514         atomic_init(&calls->refcnt, 1);
12515         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12516         calls->o = (*env)->NewWeakGlobalRef(env, o);
12517         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J[B)J");
12518         CHECK(calls->handle_custom_message_meth != NULL);
12519         calls->get_and_clear_pending_msg_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg", "()[J");
12520         CHECK(calls->get_and_clear_pending_msg_meth != NULL);
12521
12522         LDKCustomMessageHandler ret = {
12523                 .this_arg = (void*) calls,
12524                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
12525                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
12526                 .free = LDKCustomMessageHandler_JCalls_free,
12527                 .CustomMessageReader = LDKCustomMessageReader_init(env, clz, CustomMessageReader),
12528         };
12529         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
12530         return ret;
12531 }
12532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
12533         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
12534         *res_ptr = LDKCustomMessageHandler_init(env, clz, o, CustomMessageReader);
12535         return tag_ptr(res_ptr, true);
12536 }
12537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t arg) {
12538         LDKCustomMessageHandler *inp = (LDKCustomMessageHandler *)untag_ptr(arg);
12539         return tag_ptr(&inp->CustomMessageReader, false);
12540 }
12541 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) {
12542         void* this_arg_ptr = untag_ptr(this_arg);
12543         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12544         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
12545         void* msg_ptr = untag_ptr(msg);
12546         CHECK_ACCESS(msg_ptr);
12547         LDKType msg_conv = *(LDKType*)(msg_ptr);
12548         if (msg_conv.free == LDKType_JCalls_free) {
12549                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12550                 LDKType_JCalls_cloned(&msg_conv);
12551         }
12552         LDKPublicKey sender_node_id_ref;
12553         CHECK((*env)->GetArrayLength(env, sender_node_id) == 33);
12554         (*env)->GetByteArrayRegion(env, sender_node_id, 0, 33, sender_node_id_ref.compressed_form);
12555         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
12556         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
12557         return tag_ptr(ret_conv, true);
12558 }
12559
12560 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg(JNIEnv *env, jclass clz, int64_t this_arg) {
12561         void* this_arg_ptr = untag_ptr(this_arg);
12562         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12563         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
12564         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
12565         int64_tArray ret_arr = NULL;
12566         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
12567         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
12568         for (size_t z = 0; z < ret_var.datalen; z++) {
12569                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
12570                 *ret_conv_25_conv = ret_var.data[z];
12571                 ret_arr_ptr[z] = tag_ptr(ret_conv_25_conv, true);
12572         }
12573         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
12574         FREE(ret_var.data);
12575         return ret_arr;
12576 }
12577
12578 typedef struct LDKSocketDescriptor_JCalls {
12579         atomic_size_t refcnt;
12580         JavaVM *vm;
12581         jweak o;
12582         jmethodID send_data_meth;
12583         jmethodID disconnect_socket_meth;
12584         jmethodID eq_meth;
12585         jmethodID hash_meth;
12586 } LDKSocketDescriptor_JCalls;
12587 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
12588         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
12589         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12590                 JNIEnv *env;
12591                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12592                 if (get_jenv_res == JNI_EDETACHED) {
12593                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12594                 } else {
12595                         DO_ASSERT(get_jenv_res == JNI_OK);
12596                 }
12597                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12598                 if (get_jenv_res == JNI_EDETACHED) {
12599                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12600                 }
12601                 FREE(j_calls);
12602         }
12603 }
12604 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
12605         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
12606         JNIEnv *env;
12607         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12608         if (get_jenv_res == JNI_EDETACHED) {
12609                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12610         } else {
12611                 DO_ASSERT(get_jenv_res == JNI_OK);
12612         }
12613         LDKu8slice data_var = data;
12614         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
12615         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
12616         jboolean resume_read_conv = resume_read;
12617         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12618         CHECK(obj != NULL);
12619         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read_conv);
12620         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12621                 (*env)->ExceptionDescribe(env);
12622                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
12623         }
12624         if (get_jenv_res == JNI_EDETACHED) {
12625                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12626         }
12627         return ret;
12628 }
12629 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
12630         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
12631         JNIEnv *env;
12632         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12633         if (get_jenv_res == JNI_EDETACHED) {
12634                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12635         } else {
12636                 DO_ASSERT(get_jenv_res == JNI_OK);
12637         }
12638         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12639         CHECK(obj != NULL);
12640         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
12641         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12642                 (*env)->ExceptionDescribe(env);
12643                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
12644         }
12645         if (get_jenv_res == JNI_EDETACHED) {
12646                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12647         }
12648 }
12649 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
12650         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
12651         JNIEnv *env;
12652         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12653         if (get_jenv_res == JNI_EDETACHED) {
12654                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12655         } else {
12656                 DO_ASSERT(get_jenv_res == JNI_OK);
12657         }
12658         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
12659         *other_arg_clone = SocketDescriptor_clone(other_arg);
12660         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12661         CHECK(obj != NULL);
12662         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, tag_ptr(other_arg_clone, true));
12663         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12664                 (*env)->ExceptionDescribe(env);
12665                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
12666         }
12667         if (get_jenv_res == JNI_EDETACHED) {
12668                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12669         }
12670         return ret;
12671 }
12672 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
12673         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
12674         JNIEnv *env;
12675         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12676         if (get_jenv_res == JNI_EDETACHED) {
12677                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12678         } else {
12679                 DO_ASSERT(get_jenv_res == JNI_OK);
12680         }
12681         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12682         CHECK(obj != NULL);
12683         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
12684         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12685                 (*env)->ExceptionDescribe(env);
12686                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
12687         }
12688         if (get_jenv_res == JNI_EDETACHED) {
12689                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12690         }
12691         return ret;
12692 }
12693 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
12694         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
12695         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12696 }
12697 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
12698         jclass c = (*env)->GetObjectClass(env, o);
12699         CHECK(c != NULL);
12700         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
12701         atomic_init(&calls->refcnt, 1);
12702         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12703         calls->o = (*env)->NewWeakGlobalRef(env, o);
12704         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
12705         CHECK(calls->send_data_meth != NULL);
12706         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
12707         CHECK(calls->disconnect_socket_meth != NULL);
12708         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
12709         CHECK(calls->eq_meth != NULL);
12710         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
12711         CHECK(calls->hash_meth != NULL);
12712
12713         LDKSocketDescriptor ret = {
12714                 .this_arg = (void*) calls,
12715                 .send_data = send_data_LDKSocketDescriptor_jcall,
12716                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
12717                 .eq = eq_LDKSocketDescriptor_jcall,
12718                 .hash = hash_LDKSocketDescriptor_jcall,
12719                 .cloned = LDKSocketDescriptor_JCalls_cloned,
12720                 .free = LDKSocketDescriptor_JCalls_free,
12721         };
12722         return ret;
12723 }
12724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
12725         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
12726         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
12727         return tag_ptr(res_ptr, true);
12728 }
12729 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) {
12730         void* this_arg_ptr = untag_ptr(this_arg);
12731         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12732         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
12733         LDKu8slice data_ref;
12734         data_ref.datalen = (*env)->GetArrayLength(env, data);
12735         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
12736         int64_t ret_conv = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
12737         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
12738         return ret_conv;
12739 }
12740
12741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
12742         void* this_arg_ptr = untag_ptr(this_arg);
12743         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12744         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
12745         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
12746 }
12747
12748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
12749         void* this_arg_ptr = untag_ptr(this_arg);
12750         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12751         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
12752         int64_t ret_conv = (this_arg_conv->hash)(this_arg_conv->this_arg);
12753         return ret_conv;
12754 }
12755
12756 static jclass LDKEffectiveCapacity_ExactLiquidity_class = NULL;
12757 static jmethodID LDKEffectiveCapacity_ExactLiquidity_meth = NULL;
12758 static jclass LDKEffectiveCapacity_MaximumHTLC_class = NULL;
12759 static jmethodID LDKEffectiveCapacity_MaximumHTLC_meth = NULL;
12760 static jclass LDKEffectiveCapacity_Total_class = NULL;
12761 static jmethodID LDKEffectiveCapacity_Total_meth = NULL;
12762 static jclass LDKEffectiveCapacity_Infinite_class = NULL;
12763 static jmethodID LDKEffectiveCapacity_Infinite_meth = NULL;
12764 static jclass LDKEffectiveCapacity_Unknown_class = NULL;
12765 static jmethodID LDKEffectiveCapacity_Unknown_meth = NULL;
12766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEffectiveCapacity_init (JNIEnv *env, jclass clz) {
12767         LDKEffectiveCapacity_ExactLiquidity_class =
12768                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$ExactLiquidity"));
12769         CHECK(LDKEffectiveCapacity_ExactLiquidity_class != NULL);
12770         LDKEffectiveCapacity_ExactLiquidity_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_ExactLiquidity_class, "<init>", "(J)V");
12771         CHECK(LDKEffectiveCapacity_ExactLiquidity_meth != NULL);
12772         LDKEffectiveCapacity_MaximumHTLC_class =
12773                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$MaximumHTLC"));
12774         CHECK(LDKEffectiveCapacity_MaximumHTLC_class != NULL);
12775         LDKEffectiveCapacity_MaximumHTLC_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_MaximumHTLC_class, "<init>", "(J)V");
12776         CHECK(LDKEffectiveCapacity_MaximumHTLC_meth != NULL);
12777         LDKEffectiveCapacity_Total_class =
12778                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Total"));
12779         CHECK(LDKEffectiveCapacity_Total_class != NULL);
12780         LDKEffectiveCapacity_Total_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Total_class, "<init>", "(JJ)V");
12781         CHECK(LDKEffectiveCapacity_Total_meth != NULL);
12782         LDKEffectiveCapacity_Infinite_class =
12783                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Infinite"));
12784         CHECK(LDKEffectiveCapacity_Infinite_class != NULL);
12785         LDKEffectiveCapacity_Infinite_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Infinite_class, "<init>", "()V");
12786         CHECK(LDKEffectiveCapacity_Infinite_meth != NULL);
12787         LDKEffectiveCapacity_Unknown_class =
12788                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Unknown"));
12789         CHECK(LDKEffectiveCapacity_Unknown_class != NULL);
12790         LDKEffectiveCapacity_Unknown_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Unknown_class, "<init>", "()V");
12791         CHECK(LDKEffectiveCapacity_Unknown_meth != NULL);
12792 }
12793 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEffectiveCapacity_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
12794         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)untag_ptr(ptr);
12795         switch(obj->tag) {
12796                 case LDKEffectiveCapacity_ExactLiquidity: {
12797                         int64_t liquidity_msat_conv = obj->exact_liquidity.liquidity_msat;
12798                         return (*env)->NewObject(env, LDKEffectiveCapacity_ExactLiquidity_class, LDKEffectiveCapacity_ExactLiquidity_meth, liquidity_msat_conv);
12799                 }
12800                 case LDKEffectiveCapacity_MaximumHTLC: {
12801                         int64_t amount_msat_conv = obj->maximum_htlc.amount_msat;
12802                         return (*env)->NewObject(env, LDKEffectiveCapacity_MaximumHTLC_class, LDKEffectiveCapacity_MaximumHTLC_meth, amount_msat_conv);
12803                 }
12804                 case LDKEffectiveCapacity_Total: {
12805                         int64_t capacity_msat_conv = obj->total.capacity_msat;
12806                         int64_t htlc_maximum_msat_ref = tag_ptr(&obj->total.htlc_maximum_msat, false);
12807                         return (*env)->NewObject(env, LDKEffectiveCapacity_Total_class, LDKEffectiveCapacity_Total_meth, capacity_msat_conv, htlc_maximum_msat_ref);
12808                 }
12809                 case LDKEffectiveCapacity_Infinite: {
12810                         return (*env)->NewObject(env, LDKEffectiveCapacity_Infinite_class, LDKEffectiveCapacity_Infinite_meth);
12811                 }
12812                 case LDKEffectiveCapacity_Unknown: {
12813                         return (*env)->NewObject(env, LDKEffectiveCapacity_Unknown_class, LDKEffectiveCapacity_Unknown_meth);
12814                 }
12815                 default: abort();
12816         }
12817 }
12818 typedef struct LDKLockableScore_JCalls {
12819         atomic_size_t refcnt;
12820         JavaVM *vm;
12821         jweak o;
12822         jmethodID lock_meth;
12823 } LDKLockableScore_JCalls;
12824 static void LDKLockableScore_JCalls_free(void* this_arg) {
12825         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
12826         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12827                 JNIEnv *env;
12828                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12829                 if (get_jenv_res == JNI_EDETACHED) {
12830                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12831                 } else {
12832                         DO_ASSERT(get_jenv_res == JNI_OK);
12833                 }
12834                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12835                 if (get_jenv_res == JNI_EDETACHED) {
12836                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12837                 }
12838                 FREE(j_calls);
12839         }
12840 }
12841 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
12842         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
12843         JNIEnv *env;
12844         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12845         if (get_jenv_res == JNI_EDETACHED) {
12846                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12847         } else {
12848                 DO_ASSERT(get_jenv_res == JNI_OK);
12849         }
12850         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12851         CHECK(obj != NULL);
12852         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->lock_meth);
12853         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12854                 (*env)->ExceptionDescribe(env);
12855                 (*env)->FatalError(env, "A call to lock in LDKLockableScore from rust threw an exception.");
12856         }
12857         void* ret_ptr = untag_ptr(ret);
12858         CHECK_ACCESS(ret_ptr);
12859         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
12860         if (ret_conv.free == LDKScore_JCalls_free) {
12861                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12862                 LDKScore_JCalls_cloned(&ret_conv);
12863         }// WARNING: we may need a move here but no clone is available for LDKScore
12864         
12865         if (get_jenv_res == JNI_EDETACHED) {
12866                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12867         }
12868         return ret_conv;
12869 }
12870 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
12871         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
12872         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12873 }
12874 static inline LDKLockableScore LDKLockableScore_init (JNIEnv *env, jclass clz, jobject o) {
12875         jclass c = (*env)->GetObjectClass(env, o);
12876         CHECK(c != NULL);
12877         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
12878         atomic_init(&calls->refcnt, 1);
12879         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12880         calls->o = (*env)->NewWeakGlobalRef(env, o);
12881         calls->lock_meth = (*env)->GetMethodID(env, c, "lock", "()J");
12882         CHECK(calls->lock_meth != NULL);
12883
12884         LDKLockableScore ret = {
12885                 .this_arg = (void*) calls,
12886                 .lock = lock_LDKLockableScore_jcall,
12887                 .free = LDKLockableScore_JCalls_free,
12888         };
12889         return ret;
12890 }
12891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLockableScore_1new(JNIEnv *env, jclass clz, jobject o) {
12892         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
12893         *res_ptr = LDKLockableScore_init(env, clz, o);
12894         return tag_ptr(res_ptr, true);
12895 }
12896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockableScore_1lock(JNIEnv *env, jclass clz, int64_t this_arg) {
12897         void* this_arg_ptr = untag_ptr(this_arg);
12898         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12899         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
12900         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
12901         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
12902         return tag_ptr(ret_ret, true);
12903 }
12904
12905 static jclass LDKGossipSync_P2P_class = NULL;
12906 static jmethodID LDKGossipSync_P2P_meth = NULL;
12907 static jclass LDKGossipSync_Rapid_class = NULL;
12908 static jmethodID LDKGossipSync_Rapid_meth = NULL;
12909 static jclass LDKGossipSync_None_class = NULL;
12910 static jmethodID LDKGossipSync_None_meth = NULL;
12911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKGossipSync_init (JNIEnv *env, jclass clz) {
12912         LDKGossipSync_P2P_class =
12913                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$P2P"));
12914         CHECK(LDKGossipSync_P2P_class != NULL);
12915         LDKGossipSync_P2P_meth = (*env)->GetMethodID(env, LDKGossipSync_P2P_class, "<init>", "(J)V");
12916         CHECK(LDKGossipSync_P2P_meth != NULL);
12917         LDKGossipSync_Rapid_class =
12918                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$Rapid"));
12919         CHECK(LDKGossipSync_Rapid_class != NULL);
12920         LDKGossipSync_Rapid_meth = (*env)->GetMethodID(env, LDKGossipSync_Rapid_class, "<init>", "(J)V");
12921         CHECK(LDKGossipSync_Rapid_meth != NULL);
12922         LDKGossipSync_None_class =
12923                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$None"));
12924         CHECK(LDKGossipSync_None_class != NULL);
12925         LDKGossipSync_None_meth = (*env)->GetMethodID(env, LDKGossipSync_None_class, "<init>", "()V");
12926         CHECK(LDKGossipSync_None_meth != NULL);
12927 }
12928 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKGossipSync_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
12929         LDKGossipSync *obj = (LDKGossipSync*)untag_ptr(ptr);
12930         switch(obj->tag) {
12931                 case LDKGossipSync_P2P: {
12932                         LDKP2PGossipSync p2p_var = obj->p2p;
12933                         int64_t p2p_ref = 0;
12934                         CHECK_INNER_FIELD_ACCESS_OR_NULL(p2p_var);
12935                         p2p_ref = tag_ptr(p2p_var.inner, false);
12936                         return (*env)->NewObject(env, LDKGossipSync_P2P_class, LDKGossipSync_P2P_meth, p2p_ref);
12937                 }
12938                 case LDKGossipSync_Rapid: {
12939                         LDKRapidGossipSync rapid_var = obj->rapid;
12940                         int64_t rapid_ref = 0;
12941                         CHECK_INNER_FIELD_ACCESS_OR_NULL(rapid_var);
12942                         rapid_ref = tag_ptr(rapid_var.inner, false);
12943                         return (*env)->NewObject(env, LDKGossipSync_Rapid_class, LDKGossipSync_Rapid_meth, rapid_ref);
12944                 }
12945                 case LDKGossipSync_None: {
12946                         return (*env)->NewObject(env, LDKGossipSync_None_class, LDKGossipSync_None_meth);
12947                 }
12948                 default: abort();
12949         }
12950 }
12951 static jclass LDKFallback_SegWitProgram_class = NULL;
12952 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
12953 static jclass LDKFallback_PubKeyHash_class = NULL;
12954 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
12955 static jclass LDKFallback_ScriptHash_class = NULL;
12956 static jmethodID LDKFallback_ScriptHash_meth = NULL;
12957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
12958         LDKFallback_SegWitProgram_class =
12959                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$SegWitProgram"));
12960         CHECK(LDKFallback_SegWitProgram_class != NULL);
12961         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
12962         CHECK(LDKFallback_SegWitProgram_meth != NULL);
12963         LDKFallback_PubKeyHash_class =
12964                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$PubKeyHash"));
12965         CHECK(LDKFallback_PubKeyHash_class != NULL);
12966         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
12967         CHECK(LDKFallback_PubKeyHash_meth != NULL);
12968         LDKFallback_ScriptHash_class =
12969                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$ScriptHash"));
12970         CHECK(LDKFallback_ScriptHash_class != NULL);
12971         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
12972         CHECK(LDKFallback_ScriptHash_meth != NULL);
12973 }
12974 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
12975         LDKFallback *obj = (LDKFallback*)untag_ptr(ptr);
12976         switch(obj->tag) {
12977                 case LDKFallback_SegWitProgram: {
12978                         uint8_t version_val = obj->seg_wit_program.version._0;
12979                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
12980                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
12981                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
12982                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
12983                 }
12984                 case LDKFallback_PubKeyHash: {
12985                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
12986                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
12987                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
12988                 }
12989                 case LDKFallback_ScriptHash: {
12990                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
12991                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
12992                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
12993                 }
12994                 default: abort();
12995         }
12996 }
12997 typedef struct LDKPayer_JCalls {
12998         atomic_size_t refcnt;
12999         JavaVM *vm;
13000         jweak o;
13001         jmethodID node_id_meth;
13002         jmethodID first_hops_meth;
13003         jmethodID send_payment_meth;
13004         jmethodID send_spontaneous_payment_meth;
13005         jmethodID retry_payment_meth;
13006         jmethodID abandon_payment_meth;
13007 } LDKPayer_JCalls;
13008 static void LDKPayer_JCalls_free(void* this_arg) {
13009         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13010         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13011                 JNIEnv *env;
13012                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13013                 if (get_jenv_res == JNI_EDETACHED) {
13014                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13015                 } else {
13016                         DO_ASSERT(get_jenv_res == JNI_OK);
13017                 }
13018                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13019                 if (get_jenv_res == JNI_EDETACHED) {
13020                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13021                 }
13022                 FREE(j_calls);
13023         }
13024 }
13025 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
13026         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13027         JNIEnv *env;
13028         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13029         if (get_jenv_res == JNI_EDETACHED) {
13030                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13031         } else {
13032                 DO_ASSERT(get_jenv_res == JNI_OK);
13033         }
13034         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13035         CHECK(obj != NULL);
13036         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->node_id_meth);
13037         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13038                 (*env)->ExceptionDescribe(env);
13039                 (*env)->FatalError(env, "A call to node_id in LDKPayer from rust threw an exception.");
13040         }
13041         LDKPublicKey ret_ref;
13042         CHECK((*env)->GetArrayLength(env, ret) == 33);
13043         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
13044         if (get_jenv_res == JNI_EDETACHED) {
13045                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13046         }
13047         return ret_ref;
13048 }
13049 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
13050         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13051         JNIEnv *env;
13052         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13053         if (get_jenv_res == JNI_EDETACHED) {
13054                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13055         } else {
13056                 DO_ASSERT(get_jenv_res == JNI_OK);
13057         }
13058         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13059         CHECK(obj != NULL);
13060         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->first_hops_meth);
13061         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13062                 (*env)->ExceptionDescribe(env);
13063                 (*env)->FatalError(env, "A call to first_hops in LDKPayer from rust threw an exception.");
13064         }
13065         LDKCVec_ChannelDetailsZ ret_constr;
13066         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
13067         if (ret_constr.datalen > 0)
13068                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
13069         else
13070                 ret_constr.data = NULL;
13071         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
13072         for (size_t q = 0; q < ret_constr.datalen; q++) {
13073                 int64_t ret_conv_16 = ret_vals[q];
13074                 LDKChannelDetails ret_conv_16_conv;
13075                 ret_conv_16_conv.inner = untag_ptr(ret_conv_16);
13076                 ret_conv_16_conv.is_owned = ptr_is_owned(ret_conv_16);
13077                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
13078                 ret_constr.data[q] = ret_conv_16_conv;
13079         }
13080         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
13081         if (get_jenv_res == JNI_EDETACHED) {
13082                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13083         }
13084         return ret_constr;
13085 }
13086 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
13087         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13088         JNIEnv *env;
13089         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13090         if (get_jenv_res == JNI_EDETACHED) {
13091                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13092         } else {
13093                 DO_ASSERT(get_jenv_res == JNI_OK);
13094         }
13095         LDKRoute route_var = *route;
13096         int64_t route_ref = 0;
13097         route_var = Route_clone(&route_var);
13098         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
13099         route_ref = tag_ptr(route_var.inner, route_var.is_owned);
13100         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
13101         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, payment_hash.data);
13102         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
13103         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, payment_secret.data);
13104         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13105         CHECK(obj != NULL);
13106         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_payment_meth, route_ref, payment_hash_arr, payment_secret_arr);
13107         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13108                 (*env)->ExceptionDescribe(env);
13109                 (*env)->FatalError(env, "A call to send_payment in LDKPayer from rust threw an exception.");
13110         }
13111         void* ret_ptr = untag_ptr(ret);
13112         CHECK_ACCESS(ret_ptr);
13113         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
13114         FREE(untag_ptr(ret));
13115         if (get_jenv_res == JNI_EDETACHED) {
13116                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13117         }
13118         return ret_conv;
13119 }
13120 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
13121         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13122         JNIEnv *env;
13123         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13124         if (get_jenv_res == JNI_EDETACHED) {
13125                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13126         } else {
13127                 DO_ASSERT(get_jenv_res == JNI_OK);
13128         }
13129         LDKRoute route_var = *route;
13130         int64_t route_ref = 0;
13131         route_var = Route_clone(&route_var);
13132         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
13133         route_ref = tag_ptr(route_var.inner, route_var.is_owned);
13134         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
13135         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, payment_preimage.data);
13136         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13137         CHECK(obj != NULL);
13138         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_spontaneous_payment_meth, route_ref, payment_preimage_arr);
13139         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13140                 (*env)->ExceptionDescribe(env);
13141                 (*env)->FatalError(env, "A call to send_spontaneous_payment in LDKPayer from rust threw an exception.");
13142         }
13143         void* ret_ptr = untag_ptr(ret);
13144         CHECK_ACCESS(ret_ptr);
13145         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
13146         FREE(untag_ptr(ret));
13147         if (get_jenv_res == JNI_EDETACHED) {
13148                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13149         }
13150         return ret_conv;
13151 }
13152 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
13153         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13154         JNIEnv *env;
13155         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13156         if (get_jenv_res == JNI_EDETACHED) {
13157                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13158         } else {
13159                 DO_ASSERT(get_jenv_res == JNI_OK);
13160         }
13161         LDKRoute route_var = *route;
13162         int64_t route_ref = 0;
13163         route_var = Route_clone(&route_var);
13164         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
13165         route_ref = tag_ptr(route_var.inner, route_var.is_owned);
13166         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
13167         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
13168         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13169         CHECK(obj != NULL);
13170         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->retry_payment_meth, route_ref, payment_id_arr);
13171         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13172                 (*env)->ExceptionDescribe(env);
13173                 (*env)->FatalError(env, "A call to retry_payment in LDKPayer from rust threw an exception.");
13174         }
13175         void* ret_ptr = untag_ptr(ret);
13176         CHECK_ACCESS(ret_ptr);
13177         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
13178         FREE(untag_ptr(ret));
13179         if (get_jenv_res == JNI_EDETACHED) {
13180                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13181         }
13182         return ret_conv;
13183 }
13184 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
13185         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13186         JNIEnv *env;
13187         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13188         if (get_jenv_res == JNI_EDETACHED) {
13189                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13190         } else {
13191                 DO_ASSERT(get_jenv_res == JNI_OK);
13192         }
13193         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
13194         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
13195         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13196         CHECK(obj != NULL);
13197         (*env)->CallVoidMethod(env, obj, j_calls->abandon_payment_meth, payment_id_arr);
13198         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13199                 (*env)->ExceptionDescribe(env);
13200                 (*env)->FatalError(env, "A call to abandon_payment in LDKPayer from rust threw an exception.");
13201         }
13202         if (get_jenv_res == JNI_EDETACHED) {
13203                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13204         }
13205 }
13206 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
13207         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
13208         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13209 }
13210 static inline LDKPayer LDKPayer_init (JNIEnv *env, jclass clz, jobject o) {
13211         jclass c = (*env)->GetObjectClass(env, o);
13212         CHECK(c != NULL);
13213         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
13214         atomic_init(&calls->refcnt, 1);
13215         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13216         calls->o = (*env)->NewWeakGlobalRef(env, o);
13217         calls->node_id_meth = (*env)->GetMethodID(env, c, "node_id", "()[B");
13218         CHECK(calls->node_id_meth != NULL);
13219         calls->first_hops_meth = (*env)->GetMethodID(env, c, "first_hops", "()[J");
13220         CHECK(calls->first_hops_meth != NULL);
13221         calls->send_payment_meth = (*env)->GetMethodID(env, c, "send_payment", "(J[B[B)J");
13222         CHECK(calls->send_payment_meth != NULL);
13223         calls->send_spontaneous_payment_meth = (*env)->GetMethodID(env, c, "send_spontaneous_payment", "(J[B)J");
13224         CHECK(calls->send_spontaneous_payment_meth != NULL);
13225         calls->retry_payment_meth = (*env)->GetMethodID(env, c, "retry_payment", "(J[B)J");
13226         CHECK(calls->retry_payment_meth != NULL);
13227         calls->abandon_payment_meth = (*env)->GetMethodID(env, c, "abandon_payment", "([B)V");
13228         CHECK(calls->abandon_payment_meth != NULL);
13229
13230         LDKPayer ret = {
13231                 .this_arg = (void*) calls,
13232                 .node_id = node_id_LDKPayer_jcall,
13233                 .first_hops = first_hops_LDKPayer_jcall,
13234                 .send_payment = send_payment_LDKPayer_jcall,
13235                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
13236                 .retry_payment = retry_payment_LDKPayer_jcall,
13237                 .abandon_payment = abandon_payment_LDKPayer_jcall,
13238                 .free = LDKPayer_JCalls_free,
13239         };
13240         return ret;
13241 }
13242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPayer_1new(JNIEnv *env, jclass clz, jobject o) {
13243         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
13244         *res_ptr = LDKPayer_init(env, clz, o);
13245         return tag_ptr(res_ptr, true);
13246 }
13247 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
13248         void* this_arg_ptr = untag_ptr(this_arg);
13249         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13250         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13251         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13252         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form);
13253         return ret_arr;
13254 }
13255
13256 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1first_1hops(JNIEnv *env, jclass clz, int64_t this_arg) {
13257         void* this_arg_ptr = untag_ptr(this_arg);
13258         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13259         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13260         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
13261         int64_tArray ret_arr = NULL;
13262         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13263         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13264         for (size_t q = 0; q < ret_var.datalen; q++) {
13265                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
13266                 int64_t ret_conv_16_ref = 0;
13267                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
13268                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
13269                 ret_arr_ptr[q] = ret_conv_16_ref;
13270         }
13271         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
13272         FREE(ret_var.data);
13273         return ret_arr;
13274 }
13275
13276 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) {
13277         void* this_arg_ptr = untag_ptr(this_arg);
13278         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13279         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13280         LDKRoute route_conv;
13281         route_conv.inner = untag_ptr(route);
13282         route_conv.is_owned = ptr_is_owned(route);
13283         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
13284         route_conv.is_owned = false;
13285         LDKThirtyTwoBytes payment_hash_ref;
13286         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
13287         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
13288         LDKThirtyTwoBytes payment_secret_ref;
13289         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
13290         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
13291         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
13292         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
13293         return tag_ptr(ret_conv, true);
13294 }
13295
13296 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) {
13297         void* this_arg_ptr = untag_ptr(this_arg);
13298         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13299         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13300         LDKRoute route_conv;
13301         route_conv.inner = untag_ptr(route);
13302         route_conv.is_owned = ptr_is_owned(route);
13303         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
13304         route_conv.is_owned = false;
13305         LDKThirtyTwoBytes payment_preimage_ref;
13306         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
13307         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
13308         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
13309         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
13310         return tag_ptr(ret_conv, true);
13311 }
13312
13313 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) {
13314         void* this_arg_ptr = untag_ptr(this_arg);
13315         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13316         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13317         LDKRoute route_conv;
13318         route_conv.inner = untag_ptr(route);
13319         route_conv.is_owned = ptr_is_owned(route);
13320         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
13321         route_conv.is_owned = false;
13322         LDKThirtyTwoBytes payment_id_ref;
13323         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
13324         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
13325         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
13326         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
13327         return tag_ptr(ret_conv, true);
13328 }
13329
13330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
13331         void* this_arg_ptr = untag_ptr(this_arg);
13332         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13333         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13334         LDKThirtyTwoBytes payment_id_ref;
13335         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
13336         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
13337         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
13338 }
13339
13340 typedef struct LDKRouter_JCalls {
13341         atomic_size_t refcnt;
13342         JavaVM *vm;
13343         jweak o;
13344         jmethodID find_route_meth;
13345 } LDKRouter_JCalls;
13346 static void LDKRouter_JCalls_free(void* this_arg) {
13347         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
13348         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13349                 JNIEnv *env;
13350                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13351                 if (get_jenv_res == JNI_EDETACHED) {
13352                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13353                 } else {
13354                         DO_ASSERT(get_jenv_res == JNI_OK);
13355                 }
13356                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13357                 if (get_jenv_res == JNI_EDETACHED) {
13358                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13359                 }
13360                 FREE(j_calls);
13361         }
13362 }
13363 LDKCResult_RouteLightningErrorZ find_route_LDKRouter_jcall(const void* this_arg, LDKPublicKey payer, const LDKRouteParameters * route_params, const uint8_t (* payment_hash)[32], LDKCVec_ChannelDetailsZ * first_hops, const LDKScore * scorer) {
13364         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
13365         JNIEnv *env;
13366         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13367         if (get_jenv_res == JNI_EDETACHED) {
13368                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13369         } else {
13370                 DO_ASSERT(get_jenv_res == JNI_OK);
13371         }
13372         int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
13373         (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
13374         LDKRouteParameters route_params_var = *route_params;
13375         int64_t route_params_ref = 0;
13376         route_params_var = RouteParameters_clone(&route_params_var);
13377         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
13378         route_params_ref = tag_ptr(route_params_var.inner, route_params_var.is_owned);
13379         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
13380         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, *payment_hash);
13381         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
13382         int64_tArray first_hops_arr = NULL;
13383         if (first_hops != NULL) {
13384                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
13385                 first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
13386                 int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
13387                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
13388                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
13389                         int64_t first_hops_conv_16_ref = 0;
13390                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
13391                         first_hops_conv_16_ref = tag_ptr(first_hops_conv_16_var.inner, first_hops_conv_16_var.is_owned);
13392                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
13393                 }
13394                 (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
13395         }
13396         // WARNING: This object doesn't live past this scope, needs clone!
13397         int64_t ret_scorer = tag_ptr(scorer, false);
13398         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13399         CHECK(obj != NULL);
13400         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->find_route_meth, payer_arr, route_params_ref, payment_hash_arr, first_hops_arr, ret_scorer);
13401         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13402                 (*env)->ExceptionDescribe(env);
13403                 (*env)->FatalError(env, "A call to find_route in LDKRouter from rust threw an exception.");
13404         }
13405         void* ret_ptr = untag_ptr(ret);
13406         CHECK_ACCESS(ret_ptr);
13407         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
13408         FREE(untag_ptr(ret));
13409         if (get_jenv_res == JNI_EDETACHED) {
13410                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13411         }
13412         return ret_conv;
13413 }
13414 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
13415         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
13416         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13417 }
13418 static inline LDKRouter LDKRouter_init (JNIEnv *env, jclass clz, jobject o) {
13419         jclass c = (*env)->GetObjectClass(env, o);
13420         CHECK(c != NULL);
13421         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
13422         atomic_init(&calls->refcnt, 1);
13423         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13424         calls->o = (*env)->NewWeakGlobalRef(env, o);
13425         calls->find_route_meth = (*env)->GetMethodID(env, c, "find_route", "([BJ[B[JJ)J");
13426         CHECK(calls->find_route_meth != NULL);
13427
13428         LDKRouter ret = {
13429                 .this_arg = (void*) calls,
13430                 .find_route = find_route_LDKRouter_jcall,
13431                 .free = LDKRouter_JCalls_free,
13432         };
13433         return ret;
13434 }
13435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRouter_1new(JNIEnv *env, jclass clz, jobject o) {
13436         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
13437         *res_ptr = LDKRouter_init(env, clz, o);
13438         return tag_ptr(res_ptr, true);
13439 }
13440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Router_1find_1route(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payer, int64_t route_params, int8_tArray payment_hash, int64_tArray first_hops, int64_t scorer) {
13441         void* this_arg_ptr = untag_ptr(this_arg);
13442         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13443         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
13444         LDKPublicKey payer_ref;
13445         CHECK((*env)->GetArrayLength(env, payer) == 33);
13446         (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
13447         LDKRouteParameters route_params_conv;
13448         route_params_conv.inner = untag_ptr(route_params);
13449         route_params_conv.is_owned = ptr_is_owned(route_params);
13450         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
13451         route_params_conv.is_owned = false;
13452         unsigned char payment_hash_arr[32];
13453         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
13454         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
13455         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
13456         LDKCVec_ChannelDetailsZ first_hops_constr;
13457         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
13458         if (first_hops != NULL) {
13459                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
13460                 if (first_hops_constr.datalen > 0)
13461                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
13462                 else
13463                         first_hops_constr.data = NULL;
13464                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
13465                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
13466                         int64_t first_hops_conv_16 = first_hops_vals[q];
13467                         LDKChannelDetails first_hops_conv_16_conv;
13468                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
13469                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
13470                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
13471                         first_hops_conv_16_conv.is_owned = false;
13472                         first_hops_constr.data[q] = first_hops_conv_16_conv;
13473                 }
13474                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
13475                 first_hops_ptr = &first_hops_constr;
13476         }
13477         void* scorer_ptr = untag_ptr(scorer);
13478         if (ptr_is_owned(scorer)) { CHECK_ACCESS(scorer_ptr); }
13479         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
13480         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
13481         *ret_conv = (this_arg_conv->find_route)(this_arg_conv->this_arg, payer_ref, &route_params_conv, payment_hash_ref, first_hops_ptr, scorer_conv);
13482         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
13483         return tag_ptr(ret_conv, true);
13484 }
13485
13486 static jclass LDKRetry_Attempts_class = NULL;
13487 static jmethodID LDKRetry_Attempts_meth = NULL;
13488 static jclass LDKRetry_Timeout_class = NULL;
13489 static jmethodID LDKRetry_Timeout_meth = NULL;
13490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKRetry_init (JNIEnv *env, jclass clz) {
13491         LDKRetry_Attempts_class =
13492                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRetry$Attempts"));
13493         CHECK(LDKRetry_Attempts_class != NULL);
13494         LDKRetry_Attempts_meth = (*env)->GetMethodID(env, LDKRetry_Attempts_class, "<init>", "(J)V");
13495         CHECK(LDKRetry_Attempts_meth != NULL);
13496         LDKRetry_Timeout_class =
13497                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRetry$Timeout"));
13498         CHECK(LDKRetry_Timeout_class != NULL);
13499         LDKRetry_Timeout_meth = (*env)->GetMethodID(env, LDKRetry_Timeout_class, "<init>", "(J)V");
13500         CHECK(LDKRetry_Timeout_meth != NULL);
13501 }
13502 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKRetry_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
13503         LDKRetry *obj = (LDKRetry*)untag_ptr(ptr);
13504         switch(obj->tag) {
13505                 case LDKRetry_Attempts: {
13506                         int64_t attempts_conv = obj->attempts;
13507                         return (*env)->NewObject(env, LDKRetry_Attempts_class, LDKRetry_Attempts_meth, attempts_conv);
13508                 }
13509                 case LDKRetry_Timeout: {
13510                         int64_t timeout_conv = obj->timeout;
13511                         return (*env)->NewObject(env, LDKRetry_Timeout_class, LDKRetry_Timeout_meth, timeout_conv);
13512                 }
13513                 default: abort();
13514         }
13515 }
13516 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
13517         LDKStr ret_str = _ldk_get_compiled_version();
13518         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
13519         Str_free(ret_str);
13520         return ret_conv;
13521 }
13522
13523 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
13524         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
13525         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
13526         Str_free(ret_str);
13527         return ret_conv;
13528 }
13529
13530 static inline uint64_t Bech32Error_clone_ptr(LDKBech32Error *NONNULL_PTR arg) {
13531         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
13532         *ret_copy = Bech32Error_clone(arg);
13533         int64_t ret_ref = tag_ptr(ret_copy, true);
13534         return ret_ref;
13535 }
13536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13537         LDKBech32Error* arg_conv = (LDKBech32Error*)untag_ptr(arg);
13538         int64_t ret_conv = Bech32Error_clone_ptr(arg_conv);
13539         return ret_conv;
13540 }
13541
13542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13543         LDKBech32Error* orig_conv = (LDKBech32Error*)untag_ptr(orig);
13544         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
13545         *ret_copy = Bech32Error_clone(orig_conv);
13546         int64_t ret_ref = tag_ptr(ret_copy, true);
13547         return ret_ref;
13548 }
13549
13550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bech32Error_1free(JNIEnv *env, jclass clz, int64_t o) {
13551         if (!ptr_is_owned(o)) return;
13552         void* o_ptr = untag_ptr(o);
13553         CHECK_ACCESS(o_ptr);
13554         LDKBech32Error o_conv = *(LDKBech32Error*)(o_ptr);
13555         FREE(untag_ptr(o));
13556         Bech32Error_free(o_conv);
13557 }
13558
13559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
13560         LDKTransaction _res_ref;
13561         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
13562         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
13563         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
13564         _res_ref.data_is_owned = true;
13565         Transaction_free(_res_ref);
13566 }
13567
13568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
13569         LDKCVec_u8Z script_pubkey_ref;
13570         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
13571         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
13572         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
13573         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
13574         *ret_ref = TxOut_new(script_pubkey_ref, value);
13575         return tag_ptr(ret_ref, true);
13576 }
13577
13578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
13579         if (!ptr_is_owned(_res)) return;
13580         void* _res_ptr = untag_ptr(_res);
13581         CHECK_ACCESS(_res_ptr);
13582         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
13583         FREE(untag_ptr(_res));
13584         TxOut_free(_res_conv);
13585 }
13586
13587 static inline uint64_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
13588         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
13589         *ret_ref = TxOut_clone(arg);
13590         return tag_ptr(ret_ref, true);
13591 }
13592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13593         LDKTxOut* arg_conv = (LDKTxOut*)untag_ptr(arg);
13594         int64_t ret_conv = TxOut_clone_ptr(arg_conv);
13595         return ret_conv;
13596 }
13597
13598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13599         LDKTxOut* orig_conv = (LDKTxOut*)untag_ptr(orig);
13600         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
13601         *ret_ref = TxOut_clone(orig_conv);
13602         return tag_ptr(ret_ref, true);
13603 }
13604
13605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
13606         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
13607         Str_free(dummy);
13608 }
13609
13610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1ok(JNIEnv *env, jclass clz) {
13611         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13612         *ret_conv = CResult_NoneNoneZ_ok();
13613         return tag_ptr(ret_conv, true);
13614 }
13615
13616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNIEnv *env, jclass clz) {
13617         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13618         *ret_conv = CResult_NoneNoneZ_err();
13619         return tag_ptr(ret_conv, true);
13620 }
13621
13622 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13623         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)untag_ptr(o);
13624         jboolean ret_conv = CResult_NoneNoneZ_is_ok(o_conv);
13625         return ret_conv;
13626 }
13627
13628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13629         if (!ptr_is_owned(_res)) return;
13630         void* _res_ptr = untag_ptr(_res);
13631         CHECK_ACCESS(_res_ptr);
13632         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
13633         FREE(untag_ptr(_res));
13634         CResult_NoneNoneZ_free(_res_conv);
13635 }
13636
13637 static inline uint64_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
13638         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13639         *ret_conv = CResult_NoneNoneZ_clone(arg);
13640         return tag_ptr(ret_conv, true);
13641 }
13642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13643         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)untag_ptr(arg);
13644         int64_t ret_conv = CResult_NoneNoneZ_clone_ptr(arg_conv);
13645         return ret_conv;
13646 }
13647
13648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13649         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)untag_ptr(orig);
13650         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13651         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
13652         return tag_ptr(ret_conv, true);
13653 }
13654
13655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13656         LDKCounterpartyCommitmentSecrets o_conv;
13657         o_conv.inner = untag_ptr(o);
13658         o_conv.is_owned = ptr_is_owned(o);
13659         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13660         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
13661         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
13662         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
13663         return tag_ptr(ret_conv, true);
13664 }
13665
13666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13667         LDKDecodeError e_conv;
13668         e_conv.inner = untag_ptr(e);
13669         e_conv.is_owned = ptr_is_owned(e);
13670         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13671         e_conv = DecodeError_clone(&e_conv);
13672         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
13673         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
13674         return tag_ptr(ret_conv, true);
13675 }
13676
13677 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13678         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(o);
13679         jboolean ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
13680         return ret_conv;
13681 }
13682
13683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13684         if (!ptr_is_owned(_res)) return;
13685         void* _res_ptr = untag_ptr(_res);
13686         CHECK_ACCESS(_res_ptr);
13687         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
13688         FREE(untag_ptr(_res));
13689         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
13690 }
13691
13692 static inline uint64_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
13693         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
13694         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
13695         return tag_ptr(ret_conv, true);
13696 }
13697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13698         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(arg);
13699         int64_t ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
13700         return ret_conv;
13701 }
13702
13703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13704         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(orig);
13705         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
13706         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
13707         return tag_ptr(ret_conv, true);
13708 }
13709
13710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
13711         LDKSecretKey o_ref;
13712         CHECK((*env)->GetArrayLength(env, o) == 32);
13713         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
13714         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
13715         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
13716         return tag_ptr(ret_conv, true);
13717 }
13718
13719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
13720         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
13721         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
13722         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
13723         return tag_ptr(ret_conv, true);
13724 }
13725
13726 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13727         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)untag_ptr(o);
13728         jboolean ret_conv = CResult_SecretKeyErrorZ_is_ok(o_conv);
13729         return ret_conv;
13730 }
13731
13732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13733         if (!ptr_is_owned(_res)) return;
13734         void* _res_ptr = untag_ptr(_res);
13735         CHECK_ACCESS(_res_ptr);
13736         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
13737         FREE(untag_ptr(_res));
13738         CResult_SecretKeyErrorZ_free(_res_conv);
13739 }
13740
13741 static inline uint64_t CResult_SecretKeyErrorZ_clone_ptr(LDKCResult_SecretKeyErrorZ *NONNULL_PTR arg) {
13742         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
13743         *ret_conv = CResult_SecretKeyErrorZ_clone(arg);
13744         return tag_ptr(ret_conv, true);
13745 }
13746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13747         LDKCResult_SecretKeyErrorZ* arg_conv = (LDKCResult_SecretKeyErrorZ*)untag_ptr(arg);
13748         int64_t ret_conv = CResult_SecretKeyErrorZ_clone_ptr(arg_conv);
13749         return ret_conv;
13750 }
13751
13752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13753         LDKCResult_SecretKeyErrorZ* orig_conv = (LDKCResult_SecretKeyErrorZ*)untag_ptr(orig);
13754         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
13755         *ret_conv = CResult_SecretKeyErrorZ_clone(orig_conv);
13756         return tag_ptr(ret_conv, true);
13757 }
13758
13759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
13760         LDKPublicKey o_ref;
13761         CHECK((*env)->GetArrayLength(env, o) == 33);
13762         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
13763         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
13764         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
13765         return tag_ptr(ret_conv, true);
13766 }
13767
13768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
13769         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
13770         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
13771         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
13772         return tag_ptr(ret_conv, true);
13773 }
13774
13775 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13776         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(o);
13777         jboolean ret_conv = CResult_PublicKeyErrorZ_is_ok(o_conv);
13778         return ret_conv;
13779 }
13780
13781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13782         if (!ptr_is_owned(_res)) return;
13783         void* _res_ptr = untag_ptr(_res);
13784         CHECK_ACCESS(_res_ptr);
13785         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
13786         FREE(untag_ptr(_res));
13787         CResult_PublicKeyErrorZ_free(_res_conv);
13788 }
13789
13790 static inline uint64_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
13791         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
13792         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
13793         return tag_ptr(ret_conv, true);
13794 }
13795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13796         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(arg);
13797         int64_t ret_conv = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
13798         return ret_conv;
13799 }
13800
13801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13802         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(orig);
13803         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
13804         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
13805         return tag_ptr(ret_conv, true);
13806 }
13807
13808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13809         LDKTxCreationKeys o_conv;
13810         o_conv.inner = untag_ptr(o);
13811         o_conv.is_owned = ptr_is_owned(o);
13812         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13813         o_conv = TxCreationKeys_clone(&o_conv);
13814         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
13815         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
13816         return tag_ptr(ret_conv, true);
13817 }
13818
13819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13820         LDKDecodeError e_conv;
13821         e_conv.inner = untag_ptr(e);
13822         e_conv.is_owned = ptr_is_owned(e);
13823         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13824         e_conv = DecodeError_clone(&e_conv);
13825         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
13826         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
13827         return tag_ptr(ret_conv, true);
13828 }
13829
13830 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13831         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(o);
13832         jboolean ret_conv = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
13833         return ret_conv;
13834 }
13835
13836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13837         if (!ptr_is_owned(_res)) return;
13838         void* _res_ptr = untag_ptr(_res);
13839         CHECK_ACCESS(_res_ptr);
13840         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
13841         FREE(untag_ptr(_res));
13842         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
13843 }
13844
13845 static inline uint64_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
13846         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
13847         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
13848         return tag_ptr(ret_conv, true);
13849 }
13850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13851         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(arg);
13852         int64_t ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
13853         return ret_conv;
13854 }
13855
13856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13857         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(orig);
13858         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
13859         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
13860         return tag_ptr(ret_conv, true);
13861 }
13862
13863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13864         LDKChannelPublicKeys o_conv;
13865         o_conv.inner = untag_ptr(o);
13866         o_conv.is_owned = ptr_is_owned(o);
13867         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13868         o_conv = ChannelPublicKeys_clone(&o_conv);
13869         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
13870         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
13871         return tag_ptr(ret_conv, true);
13872 }
13873
13874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13875         LDKDecodeError e_conv;
13876         e_conv.inner = untag_ptr(e);
13877         e_conv.is_owned = ptr_is_owned(e);
13878         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13879         e_conv = DecodeError_clone(&e_conv);
13880         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
13881         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
13882         return tag_ptr(ret_conv, true);
13883 }
13884
13885 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13886         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(o);
13887         jboolean ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
13888         return ret_conv;
13889 }
13890
13891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13892         if (!ptr_is_owned(_res)) return;
13893         void* _res_ptr = untag_ptr(_res);
13894         CHECK_ACCESS(_res_ptr);
13895         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
13896         FREE(untag_ptr(_res));
13897         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
13898 }
13899
13900 static inline uint64_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
13901         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
13902         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
13903         return tag_ptr(ret_conv, true);
13904 }
13905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13906         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(arg);
13907         int64_t ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
13908         return ret_conv;
13909 }
13910
13911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13912         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(orig);
13913         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
13914         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
13915         return tag_ptr(ret_conv, true);
13916 }
13917
13918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13919         LDKTxCreationKeys o_conv;
13920         o_conv.inner = untag_ptr(o);
13921         o_conv.is_owned = ptr_is_owned(o);
13922         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13923         o_conv = TxCreationKeys_clone(&o_conv);
13924         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
13925         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
13926         return tag_ptr(ret_conv, true);
13927 }
13928
13929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
13930         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
13931         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
13932         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
13933         return tag_ptr(ret_conv, true);
13934 }
13935
13936 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13937         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)untag_ptr(o);
13938         jboolean ret_conv = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
13939         return ret_conv;
13940 }
13941
13942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13943         if (!ptr_is_owned(_res)) return;
13944         void* _res_ptr = untag_ptr(_res);
13945         CHECK_ACCESS(_res_ptr);
13946         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
13947         FREE(untag_ptr(_res));
13948         CResult_TxCreationKeysErrorZ_free(_res_conv);
13949 }
13950
13951 static inline uint64_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
13952         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
13953         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
13954         return tag_ptr(ret_conv, true);
13955 }
13956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13957         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)untag_ptr(arg);
13958         int64_t ret_conv = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
13959         return ret_conv;
13960 }
13961
13962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13963         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)untag_ptr(orig);
13964         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
13965         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
13966         return tag_ptr(ret_conv, true);
13967 }
13968
13969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
13970         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
13971         *ret_copy = COption_u32Z_some(o);
13972         int64_t ret_ref = tag_ptr(ret_copy, true);
13973         return ret_ref;
13974 }
13975
13976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
13977         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
13978         *ret_copy = COption_u32Z_none();
13979         int64_t ret_ref = tag_ptr(ret_copy, true);
13980         return ret_ref;
13981 }
13982
13983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
13984         if (!ptr_is_owned(_res)) return;
13985         void* _res_ptr = untag_ptr(_res);
13986         CHECK_ACCESS(_res_ptr);
13987         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
13988         FREE(untag_ptr(_res));
13989         COption_u32Z_free(_res_conv);
13990 }
13991
13992 static inline uint64_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
13993         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
13994         *ret_copy = COption_u32Z_clone(arg);
13995         int64_t ret_ref = tag_ptr(ret_copy, true);
13996         return ret_ref;
13997 }
13998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13999         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)untag_ptr(arg);
14000         int64_t ret_conv = COption_u32Z_clone_ptr(arg_conv);
14001         return ret_conv;
14002 }
14003
14004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14005         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)untag_ptr(orig);
14006         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14007         *ret_copy = COption_u32Z_clone(orig_conv);
14008         int64_t ret_ref = tag_ptr(ret_copy, true);
14009         return ret_ref;
14010 }
14011
14012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14013         LDKHTLCOutputInCommitment o_conv;
14014         o_conv.inner = untag_ptr(o);
14015         o_conv.is_owned = ptr_is_owned(o);
14016         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14017         o_conv = HTLCOutputInCommitment_clone(&o_conv);
14018         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14019         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
14020         return tag_ptr(ret_conv, true);
14021 }
14022
14023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14024         LDKDecodeError e_conv;
14025         e_conv.inner = untag_ptr(e);
14026         e_conv.is_owned = ptr_is_owned(e);
14027         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14028         e_conv = DecodeError_clone(&e_conv);
14029         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14030         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
14031         return tag_ptr(ret_conv, true);
14032 }
14033
14034 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14035         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(o);
14036         jboolean ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
14037         return ret_conv;
14038 }
14039
14040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14041         if (!ptr_is_owned(_res)) return;
14042         void* _res_ptr = untag_ptr(_res);
14043         CHECK_ACCESS(_res_ptr);
14044         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
14045         FREE(untag_ptr(_res));
14046         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
14047 }
14048
14049 static inline uint64_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
14050         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14051         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
14052         return tag_ptr(ret_conv, true);
14053 }
14054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14055         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(arg);
14056         int64_t ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
14057         return ret_conv;
14058 }
14059
14060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14061         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(orig);
14062         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14063         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
14064         return tag_ptr(ret_conv, true);
14065 }
14066
14067 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1some(JNIEnv *env, jclass clz) {
14068         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_some());
14069         return ret_conv;
14070 }
14071
14072 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1none(JNIEnv *env, jclass clz) {
14073         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_none());
14074         return ret_conv;
14075 }
14076
14077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1free(JNIEnv *env, jclass clz, jclass _res) {
14078         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_java(env, _res);
14079         COption_NoneZ_free(_res_conv);
14080 }
14081
14082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14083         LDKCounterpartyChannelTransactionParameters o_conv;
14084         o_conv.inner = untag_ptr(o);
14085         o_conv.is_owned = ptr_is_owned(o);
14086         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14087         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
14088         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
14089         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
14090         return tag_ptr(ret_conv, true);
14091 }
14092
14093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14094         LDKDecodeError e_conv;
14095         e_conv.inner = untag_ptr(e);
14096         e_conv.is_owned = ptr_is_owned(e);
14097         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14098         e_conv = DecodeError_clone(&e_conv);
14099         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
14100         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
14101         return tag_ptr(ret_conv, true);
14102 }
14103
14104 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14105         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(o);
14106         jboolean ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
14107         return ret_conv;
14108 }
14109
14110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14111         if (!ptr_is_owned(_res)) return;
14112         void* _res_ptr = untag_ptr(_res);
14113         CHECK_ACCESS(_res_ptr);
14114         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
14115         FREE(untag_ptr(_res));
14116         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
14117 }
14118
14119 static inline uint64_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
14120         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
14121         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
14122         return tag_ptr(ret_conv, true);
14123 }
14124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14125         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(arg);
14126         int64_t ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
14127         return ret_conv;
14128 }
14129
14130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14131         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(orig);
14132         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
14133         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
14134         return tag_ptr(ret_conv, true);
14135 }
14136
14137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14138         LDKChannelTransactionParameters o_conv;
14139         o_conv.inner = untag_ptr(o);
14140         o_conv.is_owned = ptr_is_owned(o);
14141         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14142         o_conv = ChannelTransactionParameters_clone(&o_conv);
14143         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
14144         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
14145         return tag_ptr(ret_conv, true);
14146 }
14147
14148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14149         LDKDecodeError e_conv;
14150         e_conv.inner = untag_ptr(e);
14151         e_conv.is_owned = ptr_is_owned(e);
14152         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14153         e_conv = DecodeError_clone(&e_conv);
14154         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
14155         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
14156         return tag_ptr(ret_conv, true);
14157 }
14158
14159 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14160         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(o);
14161         jboolean ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
14162         return ret_conv;
14163 }
14164
14165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14166         if (!ptr_is_owned(_res)) return;
14167         void* _res_ptr = untag_ptr(_res);
14168         CHECK_ACCESS(_res_ptr);
14169         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
14170         FREE(untag_ptr(_res));
14171         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
14172 }
14173
14174 static inline uint64_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
14175         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
14176         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
14177         return tag_ptr(ret_conv, true);
14178 }
14179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14180         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(arg);
14181         int64_t ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
14182         return ret_conv;
14183 }
14184
14185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14186         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(orig);
14187         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
14188         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
14189         return tag_ptr(ret_conv, true);
14190 }
14191
14192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
14193         LDKCVec_SignatureZ _res_constr;
14194         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14195         if (_res_constr.datalen > 0)
14196                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
14197         else
14198                 _res_constr.data = NULL;
14199         for (size_t i = 0; i < _res_constr.datalen; i++) {
14200                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
14201                 LDKSignature _res_conv_8_ref;
14202                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
14203                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
14204                 _res_constr.data[i] = _res_conv_8_ref;
14205         }
14206         CVec_SignatureZ_free(_res_constr);
14207 }
14208
14209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14210         LDKHolderCommitmentTransaction o_conv;
14211         o_conv.inner = untag_ptr(o);
14212         o_conv.is_owned = ptr_is_owned(o);
14213         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14214         o_conv = HolderCommitmentTransaction_clone(&o_conv);
14215         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
14216         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
14217         return tag_ptr(ret_conv, true);
14218 }
14219
14220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14221         LDKDecodeError e_conv;
14222         e_conv.inner = untag_ptr(e);
14223         e_conv.is_owned = ptr_is_owned(e);
14224         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14225         e_conv = DecodeError_clone(&e_conv);
14226         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
14227         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
14228         return tag_ptr(ret_conv, true);
14229 }
14230
14231 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14232         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(o);
14233         jboolean ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
14234         return ret_conv;
14235 }
14236
14237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14238         if (!ptr_is_owned(_res)) return;
14239         void* _res_ptr = untag_ptr(_res);
14240         CHECK_ACCESS(_res_ptr);
14241         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
14242         FREE(untag_ptr(_res));
14243         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
14244 }
14245
14246 static inline uint64_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
14247         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
14248         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
14249         return tag_ptr(ret_conv, true);
14250 }
14251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14252         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
14253         int64_t ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
14254         return ret_conv;
14255 }
14256
14257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14258         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
14259         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
14260         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
14261         return tag_ptr(ret_conv, true);
14262 }
14263
14264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14265         LDKBuiltCommitmentTransaction o_conv;
14266         o_conv.inner = untag_ptr(o);
14267         o_conv.is_owned = ptr_is_owned(o);
14268         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14269         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
14270         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
14271         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
14272         return tag_ptr(ret_conv, true);
14273 }
14274
14275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14276         LDKDecodeError e_conv;
14277         e_conv.inner = untag_ptr(e);
14278         e_conv.is_owned = ptr_is_owned(e);
14279         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14280         e_conv = DecodeError_clone(&e_conv);
14281         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
14282         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
14283         return tag_ptr(ret_conv, true);
14284 }
14285
14286 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14287         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(o);
14288         jboolean ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
14289         return ret_conv;
14290 }
14291
14292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14293         if (!ptr_is_owned(_res)) return;
14294         void* _res_ptr = untag_ptr(_res);
14295         CHECK_ACCESS(_res_ptr);
14296         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
14297         FREE(untag_ptr(_res));
14298         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
14299 }
14300
14301 static inline uint64_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
14302         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
14303         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
14304         return tag_ptr(ret_conv, true);
14305 }
14306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14307         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
14308         int64_t ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
14309         return ret_conv;
14310 }
14311
14312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14313         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
14314         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
14315         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
14316         return tag_ptr(ret_conv, true);
14317 }
14318
14319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14320         LDKTrustedClosingTransaction o_conv;
14321         o_conv.inner = untag_ptr(o);
14322         o_conv.is_owned = ptr_is_owned(o);
14323         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14324         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
14325         
14326         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
14327         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
14328         return tag_ptr(ret_conv, true);
14329 }
14330
14331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
14332         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
14333         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
14334         return tag_ptr(ret_conv, true);
14335 }
14336
14337 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14338         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(o);
14339         jboolean ret_conv = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
14340         return ret_conv;
14341 }
14342
14343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14344         if (!ptr_is_owned(_res)) return;
14345         void* _res_ptr = untag_ptr(_res);
14346         CHECK_ACCESS(_res_ptr);
14347         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
14348         FREE(untag_ptr(_res));
14349         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
14350 }
14351
14352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14353         LDKCommitmentTransaction o_conv;
14354         o_conv.inner = untag_ptr(o);
14355         o_conv.is_owned = ptr_is_owned(o);
14356         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14357         o_conv = CommitmentTransaction_clone(&o_conv);
14358         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
14359         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
14360         return tag_ptr(ret_conv, true);
14361 }
14362
14363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14364         LDKDecodeError e_conv;
14365         e_conv.inner = untag_ptr(e);
14366         e_conv.is_owned = ptr_is_owned(e);
14367         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14368         e_conv = DecodeError_clone(&e_conv);
14369         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
14370         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
14371         return tag_ptr(ret_conv, true);
14372 }
14373
14374 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14375         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(o);
14376         jboolean ret_conv = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
14377         return ret_conv;
14378 }
14379
14380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14381         if (!ptr_is_owned(_res)) return;
14382         void* _res_ptr = untag_ptr(_res);
14383         CHECK_ACCESS(_res_ptr);
14384         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
14385         FREE(untag_ptr(_res));
14386         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
14387 }
14388
14389 static inline uint64_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
14390         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
14391         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
14392         return tag_ptr(ret_conv, true);
14393 }
14394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14395         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
14396         int64_t ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
14397         return ret_conv;
14398 }
14399
14400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14401         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
14402         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
14403         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
14404         return tag_ptr(ret_conv, true);
14405 }
14406
14407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14408         LDKTrustedCommitmentTransaction o_conv;
14409         o_conv.inner = untag_ptr(o);
14410         o_conv.is_owned = ptr_is_owned(o);
14411         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14412         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
14413         
14414         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
14415         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
14416         return tag_ptr(ret_conv, true);
14417 }
14418
14419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
14420         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
14421         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
14422         return tag_ptr(ret_conv, true);
14423 }
14424
14425 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14426         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(o);
14427         jboolean ret_conv = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
14428         return ret_conv;
14429 }
14430
14431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14432         if (!ptr_is_owned(_res)) return;
14433         void* _res_ptr = untag_ptr(_res);
14434         CHECK_ACCESS(_res_ptr);
14435         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
14436         FREE(untag_ptr(_res));
14437         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
14438 }
14439
14440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
14441         LDKCVec_SignatureZ o_constr;
14442         o_constr.datalen = (*env)->GetArrayLength(env, o);
14443         if (o_constr.datalen > 0)
14444                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
14445         else
14446                 o_constr.data = NULL;
14447         for (size_t i = 0; i < o_constr.datalen; i++) {
14448                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
14449                 LDKSignature o_conv_8_ref;
14450                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
14451                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
14452                 o_constr.data[i] = o_conv_8_ref;
14453         }
14454         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
14455         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
14456         return tag_ptr(ret_conv, true);
14457 }
14458
14459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
14460         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
14461         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
14462         return tag_ptr(ret_conv, true);
14463 }
14464
14465 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14466         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(o);
14467         jboolean ret_conv = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
14468         return ret_conv;
14469 }
14470
14471 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14472         if (!ptr_is_owned(_res)) return;
14473         void* _res_ptr = untag_ptr(_res);
14474         CHECK_ACCESS(_res_ptr);
14475         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
14476         FREE(untag_ptr(_res));
14477         CResult_CVec_SignatureZNoneZ_free(_res_conv);
14478 }
14479
14480 static inline uint64_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
14481         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
14482         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
14483         return tag_ptr(ret_conv, true);
14484 }
14485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14486         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(arg);
14487         int64_t ret_conv = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
14488         return ret_conv;
14489 }
14490
14491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14492         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(orig);
14493         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
14494         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
14495         return tag_ptr(ret_conv, true);
14496 }
14497
14498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14499         LDKShutdownScript o_conv;
14500         o_conv.inner = untag_ptr(o);
14501         o_conv.is_owned = ptr_is_owned(o);
14502         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14503         o_conv = ShutdownScript_clone(&o_conv);
14504         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
14505         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
14506         return tag_ptr(ret_conv, true);
14507 }
14508
14509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14510         LDKDecodeError e_conv;
14511         e_conv.inner = untag_ptr(e);
14512         e_conv.is_owned = ptr_is_owned(e);
14513         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14514         e_conv = DecodeError_clone(&e_conv);
14515         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
14516         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
14517         return tag_ptr(ret_conv, true);
14518 }
14519
14520 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14521         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(o);
14522         jboolean ret_conv = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
14523         return ret_conv;
14524 }
14525
14526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14527         if (!ptr_is_owned(_res)) return;
14528         void* _res_ptr = untag_ptr(_res);
14529         CHECK_ACCESS(_res_ptr);
14530         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
14531         FREE(untag_ptr(_res));
14532         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
14533 }
14534
14535 static inline uint64_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
14536         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
14537         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
14538         return tag_ptr(ret_conv, true);
14539 }
14540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14541         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(arg);
14542         int64_t ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
14543         return ret_conv;
14544 }
14545
14546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14547         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(orig);
14548         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
14549         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
14550         return tag_ptr(ret_conv, true);
14551 }
14552
14553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14554         LDKShutdownScript o_conv;
14555         o_conv.inner = untag_ptr(o);
14556         o_conv.is_owned = ptr_is_owned(o);
14557         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14558         o_conv = ShutdownScript_clone(&o_conv);
14559         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
14560         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
14561         return tag_ptr(ret_conv, true);
14562 }
14563
14564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14565         LDKInvalidShutdownScript e_conv;
14566         e_conv.inner = untag_ptr(e);
14567         e_conv.is_owned = ptr_is_owned(e);
14568         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14569         e_conv = InvalidShutdownScript_clone(&e_conv);
14570         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
14571         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
14572         return tag_ptr(ret_conv, true);
14573 }
14574
14575 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14576         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(o);
14577         jboolean ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
14578         return ret_conv;
14579 }
14580
14581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14582         if (!ptr_is_owned(_res)) return;
14583         void* _res_ptr = untag_ptr(_res);
14584         CHECK_ACCESS(_res_ptr);
14585         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
14586         FREE(untag_ptr(_res));
14587         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
14588 }
14589
14590 static inline uint64_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
14591         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
14592         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
14593         return tag_ptr(ret_conv, true);
14594 }
14595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14596         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(arg);
14597         int64_t ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
14598         return ret_conv;
14599 }
14600
14601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14602         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(orig);
14603         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
14604         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
14605         return tag_ptr(ret_conv, true);
14606 }
14607
14608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
14609         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
14610         *ret_conv = CResult_NoneErrorZ_ok();
14611         return tag_ptr(ret_conv, true);
14612 }
14613
14614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14615         LDKIOError e_conv = LDKIOError_from_java(env, e);
14616         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
14617         *ret_conv = CResult_NoneErrorZ_err(e_conv);
14618         return tag_ptr(ret_conv, true);
14619 }
14620
14621 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14622         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)untag_ptr(o);
14623         jboolean ret_conv = CResult_NoneErrorZ_is_ok(o_conv);
14624         return ret_conv;
14625 }
14626
14627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14628         if (!ptr_is_owned(_res)) return;
14629         void* _res_ptr = untag_ptr(_res);
14630         CHECK_ACCESS(_res_ptr);
14631         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
14632         FREE(untag_ptr(_res));
14633         CResult_NoneErrorZ_free(_res_conv);
14634 }
14635
14636 static inline uint64_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
14637         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
14638         *ret_conv = CResult_NoneErrorZ_clone(arg);
14639         return tag_ptr(ret_conv, true);
14640 }
14641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14642         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)untag_ptr(arg);
14643         int64_t ret_conv = CResult_NoneErrorZ_clone_ptr(arg_conv);
14644         return ret_conv;
14645 }
14646
14647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14648         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)untag_ptr(orig);
14649         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
14650         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
14651         return tag_ptr(ret_conv, true);
14652 }
14653
14654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14655         LDKRouteHop o_conv;
14656         o_conv.inner = untag_ptr(o);
14657         o_conv.is_owned = ptr_is_owned(o);
14658         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14659         o_conv = RouteHop_clone(&o_conv);
14660         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
14661         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
14662         return tag_ptr(ret_conv, true);
14663 }
14664
14665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14666         LDKDecodeError e_conv;
14667         e_conv.inner = untag_ptr(e);
14668         e_conv.is_owned = ptr_is_owned(e);
14669         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14670         e_conv = DecodeError_clone(&e_conv);
14671         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
14672         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
14673         return tag_ptr(ret_conv, true);
14674 }
14675
14676 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14677         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(o);
14678         jboolean ret_conv = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
14679         return ret_conv;
14680 }
14681
14682 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14683         if (!ptr_is_owned(_res)) return;
14684         void* _res_ptr = untag_ptr(_res);
14685         CHECK_ACCESS(_res_ptr);
14686         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
14687         FREE(untag_ptr(_res));
14688         CResult_RouteHopDecodeErrorZ_free(_res_conv);
14689 }
14690
14691 static inline uint64_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
14692         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
14693         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
14694         return tag_ptr(ret_conv, true);
14695 }
14696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14697         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(arg);
14698         int64_t ret_conv = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
14699         return ret_conv;
14700 }
14701
14702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14703         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(orig);
14704         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
14705         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
14706         return tag_ptr(ret_conv, true);
14707 }
14708
14709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14710         LDKCVec_RouteHopZ _res_constr;
14711         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14712         if (_res_constr.datalen > 0)
14713                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
14714         else
14715                 _res_constr.data = NULL;
14716         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14717         for (size_t k = 0; k < _res_constr.datalen; k++) {
14718                 int64_t _res_conv_10 = _res_vals[k];
14719                 LDKRouteHop _res_conv_10_conv;
14720                 _res_conv_10_conv.inner = untag_ptr(_res_conv_10);
14721                 _res_conv_10_conv.is_owned = ptr_is_owned(_res_conv_10);
14722                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
14723                 _res_constr.data[k] = _res_conv_10_conv;
14724         }
14725         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14726         CVec_RouteHopZ_free(_res_constr);
14727 }
14728
14729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
14730         LDKCVec_CVec_RouteHopZZ _res_constr;
14731         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14732         if (_res_constr.datalen > 0)
14733                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
14734         else
14735                 _res_constr.data = NULL;
14736         for (size_t m = 0; m < _res_constr.datalen; m++) {
14737                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
14738                 LDKCVec_RouteHopZ _res_conv_12_constr;
14739                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
14740                 if (_res_conv_12_constr.datalen > 0)
14741                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
14742                 else
14743                         _res_conv_12_constr.data = NULL;
14744                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
14745                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
14746                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
14747                         LDKRouteHop _res_conv_12_conv_10_conv;
14748                         _res_conv_12_conv_10_conv.inner = untag_ptr(_res_conv_12_conv_10);
14749                         _res_conv_12_conv_10_conv.is_owned = ptr_is_owned(_res_conv_12_conv_10);
14750                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
14751                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
14752                 }
14753                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
14754                 _res_constr.data[m] = _res_conv_12_constr;
14755         }
14756         CVec_CVec_RouteHopZZ_free(_res_constr);
14757 }
14758
14759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14760         LDKRoute o_conv;
14761         o_conv.inner = untag_ptr(o);
14762         o_conv.is_owned = ptr_is_owned(o);
14763         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14764         o_conv = Route_clone(&o_conv);
14765         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
14766         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
14767         return tag_ptr(ret_conv, true);
14768 }
14769
14770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14771         LDKDecodeError e_conv;
14772         e_conv.inner = untag_ptr(e);
14773         e_conv.is_owned = ptr_is_owned(e);
14774         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14775         e_conv = DecodeError_clone(&e_conv);
14776         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
14777         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
14778         return tag_ptr(ret_conv, true);
14779 }
14780
14781 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14782         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(o);
14783         jboolean ret_conv = CResult_RouteDecodeErrorZ_is_ok(o_conv);
14784         return ret_conv;
14785 }
14786
14787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14788         if (!ptr_is_owned(_res)) return;
14789         void* _res_ptr = untag_ptr(_res);
14790         CHECK_ACCESS(_res_ptr);
14791         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
14792         FREE(untag_ptr(_res));
14793         CResult_RouteDecodeErrorZ_free(_res_conv);
14794 }
14795
14796 static inline uint64_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
14797         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
14798         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
14799         return tag_ptr(ret_conv, true);
14800 }
14801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14802         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(arg);
14803         int64_t ret_conv = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
14804         return ret_conv;
14805 }
14806
14807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14808         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(orig);
14809         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
14810         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
14811         return tag_ptr(ret_conv, true);
14812 }
14813
14814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14815         LDKRouteParameters o_conv;
14816         o_conv.inner = untag_ptr(o);
14817         o_conv.is_owned = ptr_is_owned(o);
14818         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14819         o_conv = RouteParameters_clone(&o_conv);
14820         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
14821         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
14822         return tag_ptr(ret_conv, true);
14823 }
14824
14825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14826         LDKDecodeError e_conv;
14827         e_conv.inner = untag_ptr(e);
14828         e_conv.is_owned = ptr_is_owned(e);
14829         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14830         e_conv = DecodeError_clone(&e_conv);
14831         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
14832         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
14833         return tag_ptr(ret_conv, true);
14834 }
14835
14836 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14837         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(o);
14838         jboolean ret_conv = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
14839         return ret_conv;
14840 }
14841
14842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14843         if (!ptr_is_owned(_res)) return;
14844         void* _res_ptr = untag_ptr(_res);
14845         CHECK_ACCESS(_res_ptr);
14846         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
14847         FREE(untag_ptr(_res));
14848         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
14849 }
14850
14851 static inline uint64_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
14852         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
14853         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
14854         return tag_ptr(ret_conv, true);
14855 }
14856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14857         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(arg);
14858         int64_t ret_conv = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
14859         return ret_conv;
14860 }
14861
14862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14863         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(orig);
14864         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
14865         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
14866         return tag_ptr(ret_conv, true);
14867 }
14868
14869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14870         LDKCVec_RouteHintZ _res_constr;
14871         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14872         if (_res_constr.datalen > 0)
14873                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
14874         else
14875                 _res_constr.data = NULL;
14876         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14877         for (size_t l = 0; l < _res_constr.datalen; l++) {
14878                 int64_t _res_conv_11 = _res_vals[l];
14879                 LDKRouteHint _res_conv_11_conv;
14880                 _res_conv_11_conv.inner = untag_ptr(_res_conv_11);
14881                 _res_conv_11_conv.is_owned = ptr_is_owned(_res_conv_11);
14882                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
14883                 _res_constr.data[l] = _res_conv_11_conv;
14884         }
14885         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14886         CVec_RouteHintZ_free(_res_constr);
14887 }
14888
14889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
14890         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
14891         *ret_copy = COption_u64Z_some(o);
14892         int64_t ret_ref = tag_ptr(ret_copy, true);
14893         return ret_ref;
14894 }
14895
14896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
14897         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
14898         *ret_copy = COption_u64Z_none();
14899         int64_t ret_ref = tag_ptr(ret_copy, true);
14900         return ret_ref;
14901 }
14902
14903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
14904         if (!ptr_is_owned(_res)) return;
14905         void* _res_ptr = untag_ptr(_res);
14906         CHECK_ACCESS(_res_ptr);
14907         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
14908         FREE(untag_ptr(_res));
14909         COption_u64Z_free(_res_conv);
14910 }
14911
14912 static inline uint64_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
14913         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
14914         *ret_copy = COption_u64Z_clone(arg);
14915         int64_t ret_ref = tag_ptr(ret_copy, true);
14916         return ret_ref;
14917 }
14918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14919         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)untag_ptr(arg);
14920         int64_t ret_conv = COption_u64Z_clone_ptr(arg_conv);
14921         return ret_conv;
14922 }
14923
14924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14925         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)untag_ptr(orig);
14926         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
14927         *ret_copy = COption_u64Z_clone(orig_conv);
14928         int64_t ret_ref = tag_ptr(ret_copy, true);
14929         return ret_ref;
14930 }
14931
14932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14933         LDKCVec_u64Z _res_constr;
14934         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14935         if (_res_constr.datalen > 0)
14936                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
14937         else
14938                 _res_constr.data = NULL;
14939         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14940         for (size_t g = 0; g < _res_constr.datalen; g++) {
14941                 int64_t _res_conv_6 = _res_vals[g];
14942                 _res_constr.data[g] = _res_conv_6;
14943         }
14944         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14945         CVec_u64Z_free(_res_constr);
14946 }
14947
14948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14949         LDKPaymentParameters o_conv;
14950         o_conv.inner = untag_ptr(o);
14951         o_conv.is_owned = ptr_is_owned(o);
14952         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14953         o_conv = PaymentParameters_clone(&o_conv);
14954         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
14955         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
14956         return tag_ptr(ret_conv, true);
14957 }
14958
14959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14960         LDKDecodeError e_conv;
14961         e_conv.inner = untag_ptr(e);
14962         e_conv.is_owned = ptr_is_owned(e);
14963         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14964         e_conv = DecodeError_clone(&e_conv);
14965         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
14966         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
14967         return tag_ptr(ret_conv, true);
14968 }
14969
14970 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14971         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(o);
14972         jboolean ret_conv = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
14973         return ret_conv;
14974 }
14975
14976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14977         if (!ptr_is_owned(_res)) return;
14978         void* _res_ptr = untag_ptr(_res);
14979         CHECK_ACCESS(_res_ptr);
14980         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
14981         FREE(untag_ptr(_res));
14982         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
14983 }
14984
14985 static inline uint64_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
14986         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
14987         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
14988         return tag_ptr(ret_conv, true);
14989 }
14990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14991         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(arg);
14992         int64_t ret_conv = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
14993         return ret_conv;
14994 }
14995
14996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14997         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(orig);
14998         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
14999         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
15000         return tag_ptr(ret_conv, true);
15001 }
15002
15003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15004         LDKCVec_RouteHintHopZ _res_constr;
15005         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15006         if (_res_constr.datalen > 0)
15007                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
15008         else
15009                 _res_constr.data = NULL;
15010         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15011         for (size_t o = 0; o < _res_constr.datalen; o++) {
15012                 int64_t _res_conv_14 = _res_vals[o];
15013                 LDKRouteHintHop _res_conv_14_conv;
15014                 _res_conv_14_conv.inner = untag_ptr(_res_conv_14);
15015                 _res_conv_14_conv.is_owned = ptr_is_owned(_res_conv_14);
15016                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
15017                 _res_constr.data[o] = _res_conv_14_conv;
15018         }
15019         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15020         CVec_RouteHintHopZ_free(_res_constr);
15021 }
15022
15023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15024         LDKRouteHint o_conv;
15025         o_conv.inner = untag_ptr(o);
15026         o_conv.is_owned = ptr_is_owned(o);
15027         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15028         o_conv = RouteHint_clone(&o_conv);
15029         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15030         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
15031         return tag_ptr(ret_conv, true);
15032 }
15033
15034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15035         LDKDecodeError e_conv;
15036         e_conv.inner = untag_ptr(e);
15037         e_conv.is_owned = ptr_is_owned(e);
15038         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15039         e_conv = DecodeError_clone(&e_conv);
15040         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15041         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
15042         return tag_ptr(ret_conv, true);
15043 }
15044
15045 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15046         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(o);
15047         jboolean ret_conv = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
15048         return ret_conv;
15049 }
15050
15051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15052         if (!ptr_is_owned(_res)) return;
15053         void* _res_ptr = untag_ptr(_res);
15054         CHECK_ACCESS(_res_ptr);
15055         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
15056         FREE(untag_ptr(_res));
15057         CResult_RouteHintDecodeErrorZ_free(_res_conv);
15058 }
15059
15060 static inline uint64_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
15061         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15062         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
15063         return tag_ptr(ret_conv, true);
15064 }
15065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15066         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(arg);
15067         int64_t ret_conv = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
15068         return ret_conv;
15069 }
15070
15071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15072         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(orig);
15073         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15074         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
15075         return tag_ptr(ret_conv, true);
15076 }
15077
15078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15079         LDKRouteHintHop o_conv;
15080         o_conv.inner = untag_ptr(o);
15081         o_conv.is_owned = ptr_is_owned(o);
15082         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15083         o_conv = RouteHintHop_clone(&o_conv);
15084         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
15085         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
15086         return tag_ptr(ret_conv, true);
15087 }
15088
15089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15090         LDKDecodeError e_conv;
15091         e_conv.inner = untag_ptr(e);
15092         e_conv.is_owned = ptr_is_owned(e);
15093         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15094         e_conv = DecodeError_clone(&e_conv);
15095         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
15096         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
15097         return tag_ptr(ret_conv, true);
15098 }
15099
15100 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15101         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(o);
15102         jboolean ret_conv = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
15103         return ret_conv;
15104 }
15105
15106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15107         if (!ptr_is_owned(_res)) return;
15108         void* _res_ptr = untag_ptr(_res);
15109         CHECK_ACCESS(_res_ptr);
15110         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
15111         FREE(untag_ptr(_res));
15112         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
15113 }
15114
15115 static inline uint64_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
15116         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
15117         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
15118         return tag_ptr(ret_conv, true);
15119 }
15120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15121         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(arg);
15122         int64_t ret_conv = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
15123         return ret_conv;
15124 }
15125
15126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15127         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(orig);
15128         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
15129         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
15130         return tag_ptr(ret_conv, true);
15131 }
15132
15133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15134         LDKCVec_ChannelDetailsZ _res_constr;
15135         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15136         if (_res_constr.datalen > 0)
15137                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
15138         else
15139                 _res_constr.data = NULL;
15140         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15141         for (size_t q = 0; q < _res_constr.datalen; q++) {
15142                 int64_t _res_conv_16 = _res_vals[q];
15143                 LDKChannelDetails _res_conv_16_conv;
15144                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
15145                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
15146                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
15147                 _res_constr.data[q] = _res_conv_16_conv;
15148         }
15149         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15150         CVec_ChannelDetailsZ_free(_res_constr);
15151 }
15152
15153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15154         LDKRoute o_conv;
15155         o_conv.inner = untag_ptr(o);
15156         o_conv.is_owned = ptr_is_owned(o);
15157         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15158         o_conv = Route_clone(&o_conv);
15159         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
15160         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
15161         return tag_ptr(ret_conv, true);
15162 }
15163
15164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15165         LDKLightningError e_conv;
15166         e_conv.inner = untag_ptr(e);
15167         e_conv.is_owned = ptr_is_owned(e);
15168         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15169         e_conv = LightningError_clone(&e_conv);
15170         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
15171         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
15172         return tag_ptr(ret_conv, true);
15173 }
15174
15175 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15176         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(o);
15177         jboolean ret_conv = CResult_RouteLightningErrorZ_is_ok(o_conv);
15178         return ret_conv;
15179 }
15180
15181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15182         if (!ptr_is_owned(_res)) return;
15183         void* _res_ptr = untag_ptr(_res);
15184         CHECK_ACCESS(_res_ptr);
15185         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
15186         FREE(untag_ptr(_res));
15187         CResult_RouteLightningErrorZ_free(_res_conv);
15188 }
15189
15190 static inline uint64_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
15191         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
15192         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
15193         return tag_ptr(ret_conv, true);
15194 }
15195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15196         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(arg);
15197         int64_t ret_conv = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
15198         return ret_conv;
15199 }
15200
15201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15202         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(orig);
15203         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
15204         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
15205         return tag_ptr(ret_conv, true);
15206 }
15207
15208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
15209         LDKCVec_PublicKeyZ _res_constr;
15210         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15211         if (_res_constr.datalen > 0)
15212                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
15213         else
15214                 _res_constr.data = NULL;
15215         for (size_t i = 0; i < _res_constr.datalen; i++) {
15216                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
15217                 LDKPublicKey _res_conv_8_ref;
15218                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
15219                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
15220                 _res_constr.data[i] = _res_conv_8_ref;
15221         }
15222         CVec_PublicKeyZ_free(_res_constr);
15223 }
15224
15225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15226         void* o_ptr = untag_ptr(o);
15227         CHECK_ACCESS(o_ptr);
15228         LDKPaymentPurpose o_conv = *(LDKPaymentPurpose*)(o_ptr);
15229         o_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(o));
15230         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
15231         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_ok(o_conv);
15232         return tag_ptr(ret_conv, true);
15233 }
15234
15235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15236         LDKDecodeError e_conv;
15237         e_conv.inner = untag_ptr(e);
15238         e_conv.is_owned = ptr_is_owned(e);
15239         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15240         e_conv = DecodeError_clone(&e_conv);
15241         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
15242         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_err(e_conv);
15243         return tag_ptr(ret_conv, true);
15244 }
15245
15246 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15247         LDKCResult_PaymentPurposeDecodeErrorZ* o_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(o);
15248         jboolean ret_conv = CResult_PaymentPurposeDecodeErrorZ_is_ok(o_conv);
15249         return ret_conv;
15250 }
15251
15252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15253         if (!ptr_is_owned(_res)) return;
15254         void* _res_ptr = untag_ptr(_res);
15255         CHECK_ACCESS(_res_ptr);
15256         LDKCResult_PaymentPurposeDecodeErrorZ _res_conv = *(LDKCResult_PaymentPurposeDecodeErrorZ*)(_res_ptr);
15257         FREE(untag_ptr(_res));
15258         CResult_PaymentPurposeDecodeErrorZ_free(_res_conv);
15259 }
15260
15261 static inline uint64_t CResult_PaymentPurposeDecodeErrorZ_clone_ptr(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR arg) {
15262         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
15263         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(arg);
15264         return tag_ptr(ret_conv, true);
15265 }
15266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15267         LDKCResult_PaymentPurposeDecodeErrorZ* arg_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(arg);
15268         int64_t ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone_ptr(arg_conv);
15269         return ret_conv;
15270 }
15271
15272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15273         LDKCResult_PaymentPurposeDecodeErrorZ* orig_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(orig);
15274         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
15275         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(orig_conv);
15276         return tag_ptr(ret_conv, true);
15277 }
15278
15279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1some(JNIEnv *env, jclass clz, int64_t o) {
15280         void* o_ptr = untag_ptr(o);
15281         CHECK_ACCESS(o_ptr);
15282         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
15283         o_conv = ClosureReason_clone((LDKClosureReason*)untag_ptr(o));
15284         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
15285         *ret_copy = COption_ClosureReasonZ_some(o_conv);
15286         int64_t ret_ref = tag_ptr(ret_copy, true);
15287         return ret_ref;
15288 }
15289
15290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1none(JNIEnv *env, jclass clz) {
15291         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
15292         *ret_copy = COption_ClosureReasonZ_none();
15293         int64_t ret_ref = tag_ptr(ret_copy, true);
15294         return ret_ref;
15295 }
15296
15297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15298         if (!ptr_is_owned(_res)) return;
15299         void* _res_ptr = untag_ptr(_res);
15300         CHECK_ACCESS(_res_ptr);
15301         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
15302         FREE(untag_ptr(_res));
15303         COption_ClosureReasonZ_free(_res_conv);
15304 }
15305
15306 static inline uint64_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
15307         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
15308         *ret_copy = COption_ClosureReasonZ_clone(arg);
15309         int64_t ret_ref = tag_ptr(ret_copy, true);
15310         return ret_ref;
15311 }
15312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15313         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)untag_ptr(arg);
15314         int64_t ret_conv = COption_ClosureReasonZ_clone_ptr(arg_conv);
15315         return ret_conv;
15316 }
15317
15318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15319         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)untag_ptr(orig);
15320         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
15321         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
15322         int64_t ret_ref = tag_ptr(ret_copy, true);
15323         return ret_ref;
15324 }
15325
15326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15327         void* o_ptr = untag_ptr(o);
15328         CHECK_ACCESS(o_ptr);
15329         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
15330         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)untag_ptr(o));
15331         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
15332         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
15333         return tag_ptr(ret_conv, true);
15334 }
15335
15336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15337         LDKDecodeError e_conv;
15338         e_conv.inner = untag_ptr(e);
15339         e_conv.is_owned = ptr_is_owned(e);
15340         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15341         e_conv = DecodeError_clone(&e_conv);
15342         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
15343         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
15344         return tag_ptr(ret_conv, true);
15345 }
15346
15347 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15348         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(o);
15349         jboolean ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
15350         return ret_conv;
15351 }
15352
15353 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15354         if (!ptr_is_owned(_res)) return;
15355         void* _res_ptr = untag_ptr(_res);
15356         CHECK_ACCESS(_res_ptr);
15357         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
15358         FREE(untag_ptr(_res));
15359         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
15360 }
15361
15362 static inline uint64_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
15363         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
15364         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
15365         return tag_ptr(ret_conv, true);
15366 }
15367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15368         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(arg);
15369         int64_t ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
15370         return ret_conv;
15371 }
15372
15373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15374         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(orig);
15375         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
15376         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
15377         return tag_ptr(ret_conv, true);
15378 }
15379
15380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1some(JNIEnv *env, jclass clz, int64_t o) {
15381         void* o_ptr = untag_ptr(o);
15382         CHECK_ACCESS(o_ptr);
15383         LDKHTLCDestination o_conv = *(LDKHTLCDestination*)(o_ptr);
15384         o_conv = HTLCDestination_clone((LDKHTLCDestination*)untag_ptr(o));
15385         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
15386         *ret_copy = COption_HTLCDestinationZ_some(o_conv);
15387         int64_t ret_ref = tag_ptr(ret_copy, true);
15388         return ret_ref;
15389 }
15390
15391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1none(JNIEnv *env, jclass clz) {
15392         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
15393         *ret_copy = COption_HTLCDestinationZ_none();
15394         int64_t ret_ref = tag_ptr(ret_copy, true);
15395         return ret_ref;
15396 }
15397
15398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15399         if (!ptr_is_owned(_res)) return;
15400         void* _res_ptr = untag_ptr(_res);
15401         CHECK_ACCESS(_res_ptr);
15402         LDKCOption_HTLCDestinationZ _res_conv = *(LDKCOption_HTLCDestinationZ*)(_res_ptr);
15403         FREE(untag_ptr(_res));
15404         COption_HTLCDestinationZ_free(_res_conv);
15405 }
15406
15407 static inline uint64_t COption_HTLCDestinationZ_clone_ptr(LDKCOption_HTLCDestinationZ *NONNULL_PTR arg) {
15408         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
15409         *ret_copy = COption_HTLCDestinationZ_clone(arg);
15410         int64_t ret_ref = tag_ptr(ret_copy, true);
15411         return ret_ref;
15412 }
15413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15414         LDKCOption_HTLCDestinationZ* arg_conv = (LDKCOption_HTLCDestinationZ*)untag_ptr(arg);
15415         int64_t ret_conv = COption_HTLCDestinationZ_clone_ptr(arg_conv);
15416         return ret_conv;
15417 }
15418
15419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15420         LDKCOption_HTLCDestinationZ* orig_conv = (LDKCOption_HTLCDestinationZ*)untag_ptr(orig);
15421         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
15422         *ret_copy = COption_HTLCDestinationZ_clone(orig_conv);
15423         int64_t ret_ref = tag_ptr(ret_copy, true);
15424         return ret_ref;
15425 }
15426
15427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15428         void* o_ptr = untag_ptr(o);
15429         CHECK_ACCESS(o_ptr);
15430         LDKCOption_HTLCDestinationZ o_conv = *(LDKCOption_HTLCDestinationZ*)(o_ptr);
15431         o_conv = COption_HTLCDestinationZ_clone((LDKCOption_HTLCDestinationZ*)untag_ptr(o));
15432         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
15433         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_ok(o_conv);
15434         return tag_ptr(ret_conv, true);
15435 }
15436
15437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15438         LDKDecodeError e_conv;
15439         e_conv.inner = untag_ptr(e);
15440         e_conv.is_owned = ptr_is_owned(e);
15441         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15442         e_conv = DecodeError_clone(&e_conv);
15443         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
15444         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_err(e_conv);
15445         return tag_ptr(ret_conv, true);
15446 }
15447
15448 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15449         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* o_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(o);
15450         jboolean ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(o_conv);
15451         return ret_conv;
15452 }
15453
15454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15455         if (!ptr_is_owned(_res)) return;
15456         void* _res_ptr = untag_ptr(_res);
15457         CHECK_ACCESS(_res_ptr);
15458         LDKCResult_COption_HTLCDestinationZDecodeErrorZ _res_conv = *(LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(_res_ptr);
15459         FREE(untag_ptr(_res));
15460         CResult_COption_HTLCDestinationZDecodeErrorZ_free(_res_conv);
15461 }
15462
15463 static inline uint64_t CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR arg) {
15464         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
15465         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(arg);
15466         return tag_ptr(ret_conv, true);
15467 }
15468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15469         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* arg_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(arg);
15470         int64_t ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(arg_conv);
15471         return ret_conv;
15472 }
15473
15474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15475         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* orig_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(orig);
15476         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
15477         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(orig_conv);
15478         return tag_ptr(ret_conv, true);
15479 }
15480
15481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1some(JNIEnv *env, jclass clz, int64_t o) {
15482         void* o_ptr = untag_ptr(o);
15483         CHECK_ACCESS(o_ptr);
15484         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
15485         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)untag_ptr(o));
15486         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
15487         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
15488         int64_t ret_ref = tag_ptr(ret_copy, true);
15489         return ret_ref;
15490 }
15491
15492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1none(JNIEnv *env, jclass clz) {
15493         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
15494         *ret_copy = COption_NetworkUpdateZ_none();
15495         int64_t ret_ref = tag_ptr(ret_copy, true);
15496         return ret_ref;
15497 }
15498
15499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15500         if (!ptr_is_owned(_res)) return;
15501         void* _res_ptr = untag_ptr(_res);
15502         CHECK_ACCESS(_res_ptr);
15503         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
15504         FREE(untag_ptr(_res));
15505         COption_NetworkUpdateZ_free(_res_conv);
15506 }
15507
15508 static inline uint64_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
15509         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
15510         *ret_copy = COption_NetworkUpdateZ_clone(arg);
15511         int64_t ret_ref = tag_ptr(ret_copy, true);
15512         return ret_ref;
15513 }
15514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15515         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)untag_ptr(arg);
15516         int64_t ret_conv = COption_NetworkUpdateZ_clone_ptr(arg_conv);
15517         return ret_conv;
15518 }
15519
15520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15521         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)untag_ptr(orig);
15522         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
15523         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
15524         int64_t ret_ref = tag_ptr(ret_copy, true);
15525         return ret_ref;
15526 }
15527
15528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15529         LDKCVec_SpendableOutputDescriptorZ _res_constr;
15530         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15531         if (_res_constr.datalen > 0)
15532                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
15533         else
15534                 _res_constr.data = NULL;
15535         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15536         for (size_t b = 0; b < _res_constr.datalen; b++) {
15537                 int64_t _res_conv_27 = _res_vals[b];
15538                 void* _res_conv_27_ptr = untag_ptr(_res_conv_27);
15539                 CHECK_ACCESS(_res_conv_27_ptr);
15540                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
15541                 FREE(untag_ptr(_res_conv_27));
15542                 _res_constr.data[b] = _res_conv_27_conv;
15543         }
15544         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15545         CVec_SpendableOutputDescriptorZ_free(_res_constr);
15546 }
15547
15548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
15549         void* o_ptr = untag_ptr(o);
15550         CHECK_ACCESS(o_ptr);
15551         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
15552         o_conv = Event_clone((LDKEvent*)untag_ptr(o));
15553         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
15554         *ret_copy = COption_EventZ_some(o_conv);
15555         int64_t ret_ref = tag_ptr(ret_copy, true);
15556         return ret_ref;
15557 }
15558
15559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1none(JNIEnv *env, jclass clz) {
15560         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
15561         *ret_copy = COption_EventZ_none();
15562         int64_t ret_ref = tag_ptr(ret_copy, true);
15563         return ret_ref;
15564 }
15565
15566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15567         if (!ptr_is_owned(_res)) return;
15568         void* _res_ptr = untag_ptr(_res);
15569         CHECK_ACCESS(_res_ptr);
15570         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
15571         FREE(untag_ptr(_res));
15572         COption_EventZ_free(_res_conv);
15573 }
15574
15575 static inline uint64_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
15576         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
15577         *ret_copy = COption_EventZ_clone(arg);
15578         int64_t ret_ref = tag_ptr(ret_copy, true);
15579         return ret_ref;
15580 }
15581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15582         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)untag_ptr(arg);
15583         int64_t ret_conv = COption_EventZ_clone_ptr(arg_conv);
15584         return ret_conv;
15585 }
15586
15587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15588         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)untag_ptr(orig);
15589         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
15590         *ret_copy = COption_EventZ_clone(orig_conv);
15591         int64_t ret_ref = tag_ptr(ret_copy, true);
15592         return ret_ref;
15593 }
15594
15595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15596         void* o_ptr = untag_ptr(o);
15597         CHECK_ACCESS(o_ptr);
15598         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
15599         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)untag_ptr(o));
15600         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
15601         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
15602         return tag_ptr(ret_conv, true);
15603 }
15604
15605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15606         LDKDecodeError e_conv;
15607         e_conv.inner = untag_ptr(e);
15608         e_conv.is_owned = ptr_is_owned(e);
15609         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15610         e_conv = DecodeError_clone(&e_conv);
15611         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
15612         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
15613         return tag_ptr(ret_conv, true);
15614 }
15615
15616 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15617         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(o);
15618         jboolean ret_conv = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
15619         return ret_conv;
15620 }
15621
15622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15623         if (!ptr_is_owned(_res)) return;
15624         void* _res_ptr = untag_ptr(_res);
15625         CHECK_ACCESS(_res_ptr);
15626         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
15627         FREE(untag_ptr(_res));
15628         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
15629 }
15630
15631 static inline uint64_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
15632         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
15633         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
15634         return tag_ptr(ret_conv, true);
15635 }
15636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15637         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(arg);
15638         int64_t ret_conv = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
15639         return ret_conv;
15640 }
15641
15642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15643         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(orig);
15644         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
15645         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
15646         return tag_ptr(ret_conv, true);
15647 }
15648
15649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15650         LDKCVec_MessageSendEventZ _res_constr;
15651         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15652         if (_res_constr.datalen > 0)
15653                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
15654         else
15655                 _res_constr.data = NULL;
15656         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15657         for (size_t s = 0; s < _res_constr.datalen; s++) {
15658                 int64_t _res_conv_18 = _res_vals[s];
15659                 void* _res_conv_18_ptr = untag_ptr(_res_conv_18);
15660                 CHECK_ACCESS(_res_conv_18_ptr);
15661                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
15662                 FREE(untag_ptr(_res_conv_18));
15663                 _res_constr.data[s] = _res_conv_18_conv;
15664         }
15665         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15666         CVec_MessageSendEventZ_free(_res_constr);
15667 }
15668
15669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15670         void* o_ptr = untag_ptr(o);
15671         CHECK_ACCESS(o_ptr);
15672         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
15673         o_conv = TxOut_clone((LDKTxOut*)untag_ptr(o));
15674         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
15675         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
15676         return tag_ptr(ret_conv, true);
15677 }
15678
15679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15680         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
15681         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
15682         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
15683         return tag_ptr(ret_conv, true);
15684 }
15685
15686 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15687         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(o);
15688         jboolean ret_conv = CResult_TxOutAccessErrorZ_is_ok(o_conv);
15689         return ret_conv;
15690 }
15691
15692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15693         if (!ptr_is_owned(_res)) return;
15694         void* _res_ptr = untag_ptr(_res);
15695         CHECK_ACCESS(_res_ptr);
15696         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
15697         FREE(untag_ptr(_res));
15698         CResult_TxOutAccessErrorZ_free(_res_conv);
15699 }
15700
15701 static inline uint64_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
15702         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
15703         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
15704         return tag_ptr(ret_conv, true);
15705 }
15706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15707         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(arg);
15708         int64_t ret_conv = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
15709         return ret_conv;
15710 }
15711
15712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15713         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(orig);
15714         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
15715         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
15716         return tag_ptr(ret_conv, true);
15717 }
15718
15719 static inline uint64_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
15720         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
15721         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
15722         return tag_ptr(ret_conv, true);
15723 }
15724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15725         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(arg);
15726         int64_t ret_conv = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
15727         return ret_conv;
15728 }
15729
15730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15731         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(orig);
15732         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
15733         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
15734         return tag_ptr(ret_conv, true);
15735 }
15736
15737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
15738         LDKTransaction b_ref;
15739         b_ref.datalen = (*env)->GetArrayLength(env, b);
15740         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
15741         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
15742         b_ref.data_is_owned = true;
15743         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
15744         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
15745         return tag_ptr(ret_conv, true);
15746 }
15747
15748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15749         if (!ptr_is_owned(_res)) return;
15750         void* _res_ptr = untag_ptr(_res);
15751         CHECK_ACCESS(_res_ptr);
15752         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
15753         FREE(untag_ptr(_res));
15754         C2Tuple_usizeTransactionZ_free(_res_conv);
15755 }
15756
15757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15758         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
15759         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15760         if (_res_constr.datalen > 0)
15761                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
15762         else
15763                 _res_constr.data = NULL;
15764         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15765         for (size_t c = 0; c < _res_constr.datalen; c++) {
15766                 int64_t _res_conv_28 = _res_vals[c];
15767                 void* _res_conv_28_ptr = untag_ptr(_res_conv_28);
15768                 CHECK_ACCESS(_res_conv_28_ptr);
15769                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
15770                 FREE(untag_ptr(_res_conv_28));
15771                 _res_constr.data[c] = _res_conv_28_conv;
15772         }
15773         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15774         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
15775 }
15776
15777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
15778         LDKCVec_TxidZ _res_constr;
15779         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15780         if (_res_constr.datalen > 0)
15781                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
15782         else
15783                 _res_constr.data = NULL;
15784         for (size_t i = 0; i < _res_constr.datalen; i++) {
15785                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
15786                 LDKThirtyTwoBytes _res_conv_8_ref;
15787                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
15788                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
15789                 _res_constr.data[i] = _res_conv_8_ref;
15790         }
15791         CVec_TxidZ_free(_res_constr);
15792 }
15793
15794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
15795         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
15796         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
15797         return tag_ptr(ret_conv, true);
15798 }
15799
15800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
15801         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
15802         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
15803         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
15804         return tag_ptr(ret_conv, true);
15805 }
15806
15807 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15808         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)untag_ptr(o);
15809         jboolean ret_conv = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
15810         return ret_conv;
15811 }
15812
15813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_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_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
15818         FREE(untag_ptr(_res));
15819         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
15820 }
15821
15822 static inline uint64_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
15823         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
15824         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
15825         return tag_ptr(ret_conv, true);
15826 }
15827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15828         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)untag_ptr(arg);
15829         int64_t ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
15830         return ret_conv;
15831 }
15832
15833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15834         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)untag_ptr(orig);
15835         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
15836         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
15837         return tag_ptr(ret_conv, true);
15838 }
15839
15840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15841         LDKCVec_MonitorEventZ _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(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
15845         else
15846                 _res_constr.data = NULL;
15847         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15848         for (size_t o = 0; o < _res_constr.datalen; o++) {
15849                 int64_t _res_conv_14 = _res_vals[o];
15850                 void* _res_conv_14_ptr = untag_ptr(_res_conv_14);
15851                 CHECK_ACCESS(_res_conv_14_ptr);
15852                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
15853                 FREE(untag_ptr(_res_conv_14));
15854                 _res_constr.data[o] = _res_conv_14_conv;
15855         }
15856         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15857         CVec_MonitorEventZ_free(_res_constr);
15858 }
15859
15860 static inline uint64_t C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR arg) {
15861         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
15862         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(arg);
15863         return tag_ptr(ret_conv, true);
15864 }
15865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15866         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* arg_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(arg);
15867         int64_t ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(arg_conv);
15868         return ret_conv;
15869 }
15870
15871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15872         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* orig_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(orig);
15873         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
15874         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(orig_conv);
15875         return tag_ptr(ret_conv, true);
15876 }
15877
15878 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) {
15879         LDKOutPoint a_conv;
15880         a_conv.inner = untag_ptr(a);
15881         a_conv.is_owned = ptr_is_owned(a);
15882         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
15883         a_conv = OutPoint_clone(&a_conv);
15884         LDKCVec_MonitorEventZ b_constr;
15885         b_constr.datalen = (*env)->GetArrayLength(env, b);
15886         if (b_constr.datalen > 0)
15887                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
15888         else
15889                 b_constr.data = NULL;
15890         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
15891         for (size_t o = 0; o < b_constr.datalen; o++) {
15892                 int64_t b_conv_14 = b_vals[o];
15893                 void* b_conv_14_ptr = untag_ptr(b_conv_14);
15894                 CHECK_ACCESS(b_conv_14_ptr);
15895                 LDKMonitorEvent b_conv_14_conv = *(LDKMonitorEvent*)(b_conv_14_ptr);
15896                 b_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)untag_ptr(b_conv_14));
15897                 b_constr.data[o] = b_conv_14_conv;
15898         }
15899         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
15900         LDKPublicKey c_ref;
15901         CHECK((*env)->GetArrayLength(env, c) == 33);
15902         (*env)->GetByteArrayRegion(env, c, 0, 33, c_ref.compressed_form);
15903         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
15904         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(a_conv, b_constr, c_ref);
15905         return tag_ptr(ret_conv, true);
15906 }
15907
15908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15909         if (!ptr_is_owned(_res)) return;
15910         void* _res_ptr = untag_ptr(_res);
15911         CHECK_ACCESS(_res_ptr);
15912         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_ptr);
15913         FREE(untag_ptr(_res));
15914         C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(_res_conv);
15915 }
15916
15917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15918         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ _res_constr;
15919         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15920         if (_res_constr.datalen > 0)
15921                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
15922         else
15923                 _res_constr.data = NULL;
15924         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15925         for (size_t x = 0; x < _res_constr.datalen; x++) {
15926                 int64_t _res_conv_49 = _res_vals[x];
15927                 void* _res_conv_49_ptr = untag_ptr(_res_conv_49);
15928                 CHECK_ACCESS(_res_conv_49_ptr);
15929                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_conv_49_ptr);
15930                 FREE(untag_ptr(_res_conv_49));
15931                 _res_constr.data[x] = _res_conv_49_conv;
15932         }
15933         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15934         CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(_res_constr);
15935 }
15936
15937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
15938         void* o_ptr = untag_ptr(o);
15939         CHECK_ACCESS(o_ptr);
15940         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
15941         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(o));
15942         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
15943         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
15944         int64_t ret_ref = tag_ptr(ret_copy, true);
15945         return ret_ref;
15946 }
15947
15948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
15949         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
15950         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
15951         int64_t ret_ref = tag_ptr(ret_copy, true);
15952         return ret_ref;
15953 }
15954
15955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15956         if (!ptr_is_owned(_res)) return;
15957         void* _res_ptr = untag_ptr(_res);
15958         CHECK_ACCESS(_res_ptr);
15959         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
15960         FREE(untag_ptr(_res));
15961         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
15962 }
15963
15964 static inline uint64_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
15965         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
15966         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
15967         int64_t ret_ref = tag_ptr(ret_copy, true);
15968         return ret_ref;
15969 }
15970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15971         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)untag_ptr(arg);
15972         int64_t ret_conv = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
15973         return ret_conv;
15974 }
15975
15976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15977         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)untag_ptr(orig);
15978         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
15979         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
15980         int64_t ret_ref = tag_ptr(ret_copy, true);
15981         return ret_ref;
15982 }
15983
15984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15985         LDKFixedPenaltyScorer o_conv;
15986         o_conv.inner = untag_ptr(o);
15987         o_conv.is_owned = ptr_is_owned(o);
15988         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15989         o_conv = FixedPenaltyScorer_clone(&o_conv);
15990         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
15991         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
15992         return tag_ptr(ret_conv, true);
15993 }
15994
15995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15996         LDKDecodeError e_conv;
15997         e_conv.inner = untag_ptr(e);
15998         e_conv.is_owned = ptr_is_owned(e);
15999         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16000         e_conv = DecodeError_clone(&e_conv);
16001         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
16002         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
16003         return tag_ptr(ret_conv, true);
16004 }
16005
16006 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16007         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(o);
16008         jboolean ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
16009         return ret_conv;
16010 }
16011
16012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16013         if (!ptr_is_owned(_res)) return;
16014         void* _res_ptr = untag_ptr(_res);
16015         CHECK_ACCESS(_res_ptr);
16016         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
16017         FREE(untag_ptr(_res));
16018         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
16019 }
16020
16021 static inline uint64_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
16022         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
16023         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
16024         return tag_ptr(ret_conv, true);
16025 }
16026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16027         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(arg);
16028         int64_t ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
16029         return ret_conv;
16030 }
16031
16032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16033         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(orig);
16034         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
16035         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
16036         return tag_ptr(ret_conv, true);
16037 }
16038
16039 static inline uint64_t C2Tuple_u64u64Z_clone_ptr(LDKC2Tuple_u64u64Z *NONNULL_PTR arg) {
16040         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
16041         *ret_conv = C2Tuple_u64u64Z_clone(arg);
16042         return tag_ptr(ret_conv, true);
16043 }
16044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16045         LDKC2Tuple_u64u64Z* arg_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(arg);
16046         int64_t ret_conv = C2Tuple_u64u64Z_clone_ptr(arg_conv);
16047         return ret_conv;
16048 }
16049
16050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16051         LDKC2Tuple_u64u64Z* orig_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(orig);
16052         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
16053         *ret_conv = C2Tuple_u64u64Z_clone(orig_conv);
16054         return tag_ptr(ret_conv, true);
16055 }
16056
16057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1new(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
16058         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
16059         *ret_conv = C2Tuple_u64u64Z_new(a, b);
16060         return tag_ptr(ret_conv, true);
16061 }
16062
16063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
16064         if (!ptr_is_owned(_res)) return;
16065         void* _res_ptr = untag_ptr(_res);
16066         CHECK_ACCESS(_res_ptr);
16067         LDKC2Tuple_u64u64Z _res_conv = *(LDKC2Tuple_u64u64Z*)(_res_ptr);
16068         FREE(untag_ptr(_res));
16069         C2Tuple_u64u64Z_free(_res_conv);
16070 }
16071
16072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16073         void* o_ptr = untag_ptr(o);
16074         CHECK_ACCESS(o_ptr);
16075         LDKC2Tuple_u64u64Z o_conv = *(LDKC2Tuple_u64u64Z*)(o_ptr);
16076         o_conv = C2Tuple_u64u64Z_clone((LDKC2Tuple_u64u64Z*)untag_ptr(o));
16077         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
16078         *ret_copy = COption_C2Tuple_u64u64ZZ_some(o_conv);
16079         int64_t ret_ref = tag_ptr(ret_copy, true);
16080         return ret_ref;
16081 }
16082
16083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1none(JNIEnv *env, jclass clz) {
16084         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
16085         *ret_copy = COption_C2Tuple_u64u64ZZ_none();
16086         int64_t ret_ref = tag_ptr(ret_copy, true);
16087         return ret_ref;
16088 }
16089
16090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16091         if (!ptr_is_owned(_res)) return;
16092         void* _res_ptr = untag_ptr(_res);
16093         CHECK_ACCESS(_res_ptr);
16094         LDKCOption_C2Tuple_u64u64ZZ _res_conv = *(LDKCOption_C2Tuple_u64u64ZZ*)(_res_ptr);
16095         FREE(untag_ptr(_res));
16096         COption_C2Tuple_u64u64ZZ_free(_res_conv);
16097 }
16098
16099 static inline uint64_t COption_C2Tuple_u64u64ZZ_clone_ptr(LDKCOption_C2Tuple_u64u64ZZ *NONNULL_PTR arg) {
16100         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
16101         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(arg);
16102         int64_t ret_ref = tag_ptr(ret_copy, true);
16103         return ret_ref;
16104 }
16105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16106         LDKCOption_C2Tuple_u64u64ZZ* arg_conv = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(arg);
16107         int64_t ret_conv = COption_C2Tuple_u64u64ZZ_clone_ptr(arg_conv);
16108         return ret_conv;
16109 }
16110
16111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16112         LDKCOption_C2Tuple_u64u64ZZ* orig_conv = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(orig);
16113         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
16114         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(orig_conv);
16115         int64_t ret_ref = tag_ptr(ret_copy, true);
16116         return ret_ref;
16117 }
16118
16119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeIdZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16120         LDKCVec_NodeIdZ _res_constr;
16121         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16122         if (_res_constr.datalen > 0)
16123                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
16124         else
16125                 _res_constr.data = NULL;
16126         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16127         for (size_t i = 0; i < _res_constr.datalen; i++) {
16128                 int64_t _res_conv_8 = _res_vals[i];
16129                 LDKNodeId _res_conv_8_conv;
16130                 _res_conv_8_conv.inner = untag_ptr(_res_conv_8);
16131                 _res_conv_8_conv.is_owned = ptr_is_owned(_res_conv_8);
16132                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_8_conv);
16133                 _res_constr.data[i] = _res_conv_8_conv;
16134         }
16135         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16136         CVec_NodeIdZ_free(_res_constr);
16137 }
16138
16139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16140         LDKProbabilisticScorer o_conv;
16141         o_conv.inner = untag_ptr(o);
16142         o_conv.is_owned = ptr_is_owned(o);
16143         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16144         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
16145         
16146         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
16147         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
16148         return tag_ptr(ret_conv, true);
16149 }
16150
16151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16152         LDKDecodeError e_conv;
16153         e_conv.inner = untag_ptr(e);
16154         e_conv.is_owned = ptr_is_owned(e);
16155         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16156         e_conv = DecodeError_clone(&e_conv);
16157         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
16158         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
16159         return tag_ptr(ret_conv, true);
16160 }
16161
16162 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16163         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(o);
16164         jboolean ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
16165         return ret_conv;
16166 }
16167
16168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16169         if (!ptr_is_owned(_res)) return;
16170         void* _res_ptr = untag_ptr(_res);
16171         CHECK_ACCESS(_res_ptr);
16172         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
16173         FREE(untag_ptr(_res));
16174         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
16175 }
16176
16177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16178         LDKInitFeatures o_conv;
16179         o_conv.inner = untag_ptr(o);
16180         o_conv.is_owned = ptr_is_owned(o);
16181         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16182         o_conv = InitFeatures_clone(&o_conv);
16183         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
16184         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
16185         return tag_ptr(ret_conv, true);
16186 }
16187
16188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16189         LDKDecodeError e_conv;
16190         e_conv.inner = untag_ptr(e);
16191         e_conv.is_owned = ptr_is_owned(e);
16192         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16193         e_conv = DecodeError_clone(&e_conv);
16194         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
16195         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
16196         return tag_ptr(ret_conv, true);
16197 }
16198
16199 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16200         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(o);
16201         jboolean ret_conv = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
16202         return ret_conv;
16203 }
16204
16205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16206         if (!ptr_is_owned(_res)) return;
16207         void* _res_ptr = untag_ptr(_res);
16208         CHECK_ACCESS(_res_ptr);
16209         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
16210         FREE(untag_ptr(_res));
16211         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
16212 }
16213
16214 static inline uint64_t CResult_InitFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR arg) {
16215         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
16216         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(arg);
16217         return tag_ptr(ret_conv, true);
16218 }
16219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16220         LDKCResult_InitFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(arg);
16221         int64_t ret_conv = CResult_InitFeaturesDecodeErrorZ_clone_ptr(arg_conv);
16222         return ret_conv;
16223 }
16224
16225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16226         LDKCResult_InitFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(orig);
16227         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
16228         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(orig_conv);
16229         return tag_ptr(ret_conv, true);
16230 }
16231
16232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16233         LDKChannelFeatures o_conv;
16234         o_conv.inner = untag_ptr(o);
16235         o_conv.is_owned = ptr_is_owned(o);
16236         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16237         o_conv = ChannelFeatures_clone(&o_conv);
16238         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
16239         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
16240         return tag_ptr(ret_conv, true);
16241 }
16242
16243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16244         LDKDecodeError e_conv;
16245         e_conv.inner = untag_ptr(e);
16246         e_conv.is_owned = ptr_is_owned(e);
16247         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16248         e_conv = DecodeError_clone(&e_conv);
16249         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
16250         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
16251         return tag_ptr(ret_conv, true);
16252 }
16253
16254 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16255         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(o);
16256         jboolean ret_conv = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
16257         return ret_conv;
16258 }
16259
16260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16261         if (!ptr_is_owned(_res)) return;
16262         void* _res_ptr = untag_ptr(_res);
16263         CHECK_ACCESS(_res_ptr);
16264         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
16265         FREE(untag_ptr(_res));
16266         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
16267 }
16268
16269 static inline uint64_t CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR arg) {
16270         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
16271         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(arg);
16272         return tag_ptr(ret_conv, true);
16273 }
16274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16275         LDKCResult_ChannelFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(arg);
16276         int64_t ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(arg_conv);
16277         return ret_conv;
16278 }
16279
16280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16281         LDKCResult_ChannelFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(orig);
16282         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
16283         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(orig_conv);
16284         return tag_ptr(ret_conv, true);
16285 }
16286
16287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16288         LDKNodeFeatures o_conv;
16289         o_conv.inner = untag_ptr(o);
16290         o_conv.is_owned = ptr_is_owned(o);
16291         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16292         o_conv = NodeFeatures_clone(&o_conv);
16293         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
16294         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
16295         return tag_ptr(ret_conv, true);
16296 }
16297
16298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16299         LDKDecodeError e_conv;
16300         e_conv.inner = untag_ptr(e);
16301         e_conv.is_owned = ptr_is_owned(e);
16302         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16303         e_conv = DecodeError_clone(&e_conv);
16304         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
16305         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
16306         return tag_ptr(ret_conv, true);
16307 }
16308
16309 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16310         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(o);
16311         jboolean ret_conv = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
16312         return ret_conv;
16313 }
16314
16315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16316         if (!ptr_is_owned(_res)) return;
16317         void* _res_ptr = untag_ptr(_res);
16318         CHECK_ACCESS(_res_ptr);
16319         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
16320         FREE(untag_ptr(_res));
16321         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
16322 }
16323
16324 static inline uint64_t CResult_NodeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
16325         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
16326         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(arg);
16327         return tag_ptr(ret_conv, true);
16328 }
16329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16330         LDKCResult_NodeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(arg);
16331         int64_t ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
16332         return ret_conv;
16333 }
16334
16335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16336         LDKCResult_NodeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(orig);
16337         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
16338         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(orig_conv);
16339         return tag_ptr(ret_conv, true);
16340 }
16341
16342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16343         LDKInvoiceFeatures o_conv;
16344         o_conv.inner = untag_ptr(o);
16345         o_conv.is_owned = ptr_is_owned(o);
16346         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16347         o_conv = InvoiceFeatures_clone(&o_conv);
16348         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
16349         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
16350         return tag_ptr(ret_conv, true);
16351 }
16352
16353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16354         LDKDecodeError e_conv;
16355         e_conv.inner = untag_ptr(e);
16356         e_conv.is_owned = ptr_is_owned(e);
16357         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16358         e_conv = DecodeError_clone(&e_conv);
16359         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
16360         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
16361         return tag_ptr(ret_conv, true);
16362 }
16363
16364 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16365         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(o);
16366         jboolean ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
16367         return ret_conv;
16368 }
16369
16370 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16371         if (!ptr_is_owned(_res)) return;
16372         void* _res_ptr = untag_ptr(_res);
16373         CHECK_ACCESS(_res_ptr);
16374         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
16375         FREE(untag_ptr(_res));
16376         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
16377 }
16378
16379 static inline uint64_t CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR arg) {
16380         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
16381         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(arg);
16382         return tag_ptr(ret_conv, true);
16383 }
16384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16385         LDKCResult_InvoiceFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(arg);
16386         int64_t ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(arg_conv);
16387         return ret_conv;
16388 }
16389
16390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16391         LDKCResult_InvoiceFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(orig);
16392         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
16393         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(orig_conv);
16394         return tag_ptr(ret_conv, true);
16395 }
16396
16397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16398         LDKChannelTypeFeatures o_conv;
16399         o_conv.inner = untag_ptr(o);
16400         o_conv.is_owned = ptr_is_owned(o);
16401         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16402         o_conv = ChannelTypeFeatures_clone(&o_conv);
16403         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
16404         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
16405         return tag_ptr(ret_conv, true);
16406 }
16407
16408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16409         LDKDecodeError e_conv;
16410         e_conv.inner = untag_ptr(e);
16411         e_conv.is_owned = ptr_is_owned(e);
16412         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16413         e_conv = DecodeError_clone(&e_conv);
16414         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
16415         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
16416         return tag_ptr(ret_conv, true);
16417 }
16418
16419 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16420         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(o);
16421         jboolean ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
16422         return ret_conv;
16423 }
16424
16425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16426         if (!ptr_is_owned(_res)) return;
16427         void* _res_ptr = untag_ptr(_res);
16428         CHECK_ACCESS(_res_ptr);
16429         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
16430         FREE(untag_ptr(_res));
16431         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
16432 }
16433
16434 static inline uint64_t CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
16435         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
16436         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(arg);
16437         return tag_ptr(ret_conv, true);
16438 }
16439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16440         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(arg);
16441         int64_t ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
16442         return ret_conv;
16443 }
16444
16445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16446         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(orig);
16447         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
16448         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig_conv);
16449         return tag_ptr(ret_conv, true);
16450 }
16451
16452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16453         LDKNodeId o_conv;
16454         o_conv.inner = untag_ptr(o);
16455         o_conv.is_owned = ptr_is_owned(o);
16456         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16457         o_conv = NodeId_clone(&o_conv);
16458         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16459         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
16460         return tag_ptr(ret_conv, true);
16461 }
16462
16463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16464         LDKDecodeError e_conv;
16465         e_conv.inner = untag_ptr(e);
16466         e_conv.is_owned = ptr_is_owned(e);
16467         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16468         e_conv = DecodeError_clone(&e_conv);
16469         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16470         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
16471         return tag_ptr(ret_conv, true);
16472 }
16473
16474 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16475         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(o);
16476         jboolean ret_conv = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
16477         return ret_conv;
16478 }
16479
16480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16481         if (!ptr_is_owned(_res)) return;
16482         void* _res_ptr = untag_ptr(_res);
16483         CHECK_ACCESS(_res_ptr);
16484         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
16485         FREE(untag_ptr(_res));
16486         CResult_NodeIdDecodeErrorZ_free(_res_conv);
16487 }
16488
16489 static inline uint64_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
16490         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16491         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
16492         return tag_ptr(ret_conv, true);
16493 }
16494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16495         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(arg);
16496         int64_t ret_conv = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
16497         return ret_conv;
16498 }
16499
16500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16501         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(orig);
16502         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16503         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
16504         return tag_ptr(ret_conv, true);
16505 }
16506
16507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16508         void* o_ptr = untag_ptr(o);
16509         CHECK_ACCESS(o_ptr);
16510         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
16511         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)untag_ptr(o));
16512         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16513         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
16514         return tag_ptr(ret_conv, true);
16515 }
16516
16517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16518         LDKDecodeError e_conv;
16519         e_conv.inner = untag_ptr(e);
16520         e_conv.is_owned = ptr_is_owned(e);
16521         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16522         e_conv = DecodeError_clone(&e_conv);
16523         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16524         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
16525         return tag_ptr(ret_conv, true);
16526 }
16527
16528 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16529         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(o);
16530         jboolean ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
16531         return ret_conv;
16532 }
16533
16534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16535         if (!ptr_is_owned(_res)) return;
16536         void* _res_ptr = untag_ptr(_res);
16537         CHECK_ACCESS(_res_ptr);
16538         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
16539         FREE(untag_ptr(_res));
16540         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
16541 }
16542
16543 static inline uint64_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
16544         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16545         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
16546         return tag_ptr(ret_conv, true);
16547 }
16548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16549         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(arg);
16550         int64_t ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
16551         return ret_conv;
16552 }
16553
16554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16555         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(orig);
16556         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16557         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
16558         return tag_ptr(ret_conv, true);
16559 }
16560
16561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16562         void* o_ptr = untag_ptr(o);
16563         CHECK_ACCESS(o_ptr);
16564         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
16565         if (o_conv.free == LDKAccess_JCalls_free) {
16566                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16567                 LDKAccess_JCalls_cloned(&o_conv);
16568         }
16569         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
16570         *ret_copy = COption_AccessZ_some(o_conv);
16571         int64_t ret_ref = tag_ptr(ret_copy, true);
16572         return ret_ref;
16573 }
16574
16575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1none(JNIEnv *env, jclass clz) {
16576         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
16577         *ret_copy = COption_AccessZ_none();
16578         int64_t ret_ref = tag_ptr(ret_copy, true);
16579         return ret_ref;
16580 }
16581
16582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16583         if (!ptr_is_owned(_res)) return;
16584         void* _res_ptr = untag_ptr(_res);
16585         CHECK_ACCESS(_res_ptr);
16586         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
16587         FREE(untag_ptr(_res));
16588         COption_AccessZ_free(_res_conv);
16589 }
16590
16591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
16592         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16593         *ret_conv = CResult_boolLightningErrorZ_ok(o);
16594         return tag_ptr(ret_conv, true);
16595 }
16596
16597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16598         LDKLightningError e_conv;
16599         e_conv.inner = untag_ptr(e);
16600         e_conv.is_owned = ptr_is_owned(e);
16601         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16602         e_conv = LightningError_clone(&e_conv);
16603         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16604         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
16605         return tag_ptr(ret_conv, true);
16606 }
16607
16608 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16609         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(o);
16610         jboolean ret_conv = CResult_boolLightningErrorZ_is_ok(o_conv);
16611         return ret_conv;
16612 }
16613
16614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16615         if (!ptr_is_owned(_res)) return;
16616         void* _res_ptr = untag_ptr(_res);
16617         CHECK_ACCESS(_res_ptr);
16618         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
16619         FREE(untag_ptr(_res));
16620         CResult_boolLightningErrorZ_free(_res_conv);
16621 }
16622
16623 static inline uint64_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
16624         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16625         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
16626         return tag_ptr(ret_conv, true);
16627 }
16628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16629         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(arg);
16630         int64_t ret_conv = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
16631         return ret_conv;
16632 }
16633
16634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16635         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(orig);
16636         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16637         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
16638         return tag_ptr(ret_conv, true);
16639 }
16640
16641 static inline uint64_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
16642         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
16643         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
16644         return tag_ptr(ret_conv, true);
16645 }
16646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16647         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(arg);
16648         int64_t ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
16649         return ret_conv;
16650 }
16651
16652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16653         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(orig);
16654         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
16655         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
16656         return tag_ptr(ret_conv, true);
16657 }
16658
16659 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) {
16660         LDKChannelAnnouncement a_conv;
16661         a_conv.inner = untag_ptr(a);
16662         a_conv.is_owned = ptr_is_owned(a);
16663         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
16664         a_conv = ChannelAnnouncement_clone(&a_conv);
16665         LDKChannelUpdate b_conv;
16666         b_conv.inner = untag_ptr(b);
16667         b_conv.is_owned = ptr_is_owned(b);
16668         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
16669         b_conv = ChannelUpdate_clone(&b_conv);
16670         LDKChannelUpdate c_conv;
16671         c_conv.inner = untag_ptr(c);
16672         c_conv.is_owned = ptr_is_owned(c);
16673         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
16674         c_conv = ChannelUpdate_clone(&c_conv);
16675         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
16676         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
16677         return tag_ptr(ret_conv, true);
16678 }
16679
16680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16681         if (!ptr_is_owned(_res)) return;
16682         void* _res_ptr = untag_ptr(_res);
16683         CHECK_ACCESS(_res_ptr);
16684         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
16685         FREE(untag_ptr(_res));
16686         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
16687 }
16688
16689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16690         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
16691         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16692         if (_res_constr.datalen > 0)
16693                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
16694         else
16695                 _res_constr.data = NULL;
16696         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16697         for (size_t h = 0; h < _res_constr.datalen; h++) {
16698                 int64_t _res_conv_59 = _res_vals[h];
16699                 void* _res_conv_59_ptr = untag_ptr(_res_conv_59);
16700                 CHECK_ACCESS(_res_conv_59_ptr);
16701                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
16702                 FREE(untag_ptr(_res_conv_59));
16703                 _res_constr.data[h] = _res_conv_59_conv;
16704         }
16705         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16706         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
16707 }
16708
16709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16710         LDKCVec_NodeAnnouncementZ _res_constr;
16711         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16712         if (_res_constr.datalen > 0)
16713                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
16714         else
16715                 _res_constr.data = NULL;
16716         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16717         for (size_t s = 0; s < _res_constr.datalen; s++) {
16718                 int64_t _res_conv_18 = _res_vals[s];
16719                 LDKNodeAnnouncement _res_conv_18_conv;
16720                 _res_conv_18_conv.inner = untag_ptr(_res_conv_18);
16721                 _res_conv_18_conv.is_owned = ptr_is_owned(_res_conv_18);
16722                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
16723                 _res_constr.data[s] = _res_conv_18_conv;
16724         }
16725         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16726         CVec_NodeAnnouncementZ_free(_res_constr);
16727 }
16728
16729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
16730         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16731         *ret_conv = CResult_NoneLightningErrorZ_ok();
16732         return tag_ptr(ret_conv, true);
16733 }
16734
16735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16736         LDKLightningError e_conv;
16737         e_conv.inner = untag_ptr(e);
16738         e_conv.is_owned = ptr_is_owned(e);
16739         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16740         e_conv = LightningError_clone(&e_conv);
16741         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16742         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
16743         return tag_ptr(ret_conv, true);
16744 }
16745
16746 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16747         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(o);
16748         jboolean ret_conv = CResult_NoneLightningErrorZ_is_ok(o_conv);
16749         return ret_conv;
16750 }
16751
16752 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16753         if (!ptr_is_owned(_res)) return;
16754         void* _res_ptr = untag_ptr(_res);
16755         CHECK_ACCESS(_res_ptr);
16756         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
16757         FREE(untag_ptr(_res));
16758         CResult_NoneLightningErrorZ_free(_res_conv);
16759 }
16760
16761 static inline uint64_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
16762         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16763         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
16764         return tag_ptr(ret_conv, true);
16765 }
16766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16767         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(arg);
16768         int64_t ret_conv = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
16769         return ret_conv;
16770 }
16771
16772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16773         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(orig);
16774         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16775         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
16776         return tag_ptr(ret_conv, true);
16777 }
16778
16779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16780         LDKChannelUpdateInfo o_conv;
16781         o_conv.inner = untag_ptr(o);
16782         o_conv.is_owned = ptr_is_owned(o);
16783         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16784         o_conv = ChannelUpdateInfo_clone(&o_conv);
16785         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
16786         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
16787         return tag_ptr(ret_conv, true);
16788 }
16789
16790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16791         LDKDecodeError e_conv;
16792         e_conv.inner = untag_ptr(e);
16793         e_conv.is_owned = ptr_is_owned(e);
16794         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16795         e_conv = DecodeError_clone(&e_conv);
16796         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
16797         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
16798         return tag_ptr(ret_conv, true);
16799 }
16800
16801 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16802         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(o);
16803         jboolean ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
16804         return ret_conv;
16805 }
16806
16807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16808         if (!ptr_is_owned(_res)) return;
16809         void* _res_ptr = untag_ptr(_res);
16810         CHECK_ACCESS(_res_ptr);
16811         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
16812         FREE(untag_ptr(_res));
16813         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
16814 }
16815
16816 static inline uint64_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
16817         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
16818         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
16819         return tag_ptr(ret_conv, true);
16820 }
16821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16822         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(arg);
16823         int64_t ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
16824         return ret_conv;
16825 }
16826
16827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16828         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(orig);
16829         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
16830         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
16831         return tag_ptr(ret_conv, true);
16832 }
16833
16834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16835         LDKChannelInfo o_conv;
16836         o_conv.inner = untag_ptr(o);
16837         o_conv.is_owned = ptr_is_owned(o);
16838         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16839         o_conv = ChannelInfo_clone(&o_conv);
16840         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
16841         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
16842         return tag_ptr(ret_conv, true);
16843 }
16844
16845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16846         LDKDecodeError e_conv;
16847         e_conv.inner = untag_ptr(e);
16848         e_conv.is_owned = ptr_is_owned(e);
16849         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16850         e_conv = DecodeError_clone(&e_conv);
16851         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
16852         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
16853         return tag_ptr(ret_conv, true);
16854 }
16855
16856 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16857         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(o);
16858         jboolean ret_conv = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
16859         return ret_conv;
16860 }
16861
16862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16863         if (!ptr_is_owned(_res)) return;
16864         void* _res_ptr = untag_ptr(_res);
16865         CHECK_ACCESS(_res_ptr);
16866         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
16867         FREE(untag_ptr(_res));
16868         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
16869 }
16870
16871 static inline uint64_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
16872         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
16873         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
16874         return tag_ptr(ret_conv, true);
16875 }
16876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16877         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(arg);
16878         int64_t ret_conv = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
16879         return ret_conv;
16880 }
16881
16882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16883         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(orig);
16884         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
16885         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
16886         return tag_ptr(ret_conv, true);
16887 }
16888
16889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16890         LDKRoutingFees o_conv;
16891         o_conv.inner = untag_ptr(o);
16892         o_conv.is_owned = ptr_is_owned(o);
16893         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16894         o_conv = RoutingFees_clone(&o_conv);
16895         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
16896         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
16897         return tag_ptr(ret_conv, true);
16898 }
16899
16900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16901         LDKDecodeError e_conv;
16902         e_conv.inner = untag_ptr(e);
16903         e_conv.is_owned = ptr_is_owned(e);
16904         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16905         e_conv = DecodeError_clone(&e_conv);
16906         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
16907         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
16908         return tag_ptr(ret_conv, true);
16909 }
16910
16911 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16912         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(o);
16913         jboolean ret_conv = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
16914         return ret_conv;
16915 }
16916
16917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16918         if (!ptr_is_owned(_res)) return;
16919         void* _res_ptr = untag_ptr(_res);
16920         CHECK_ACCESS(_res_ptr);
16921         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
16922         FREE(untag_ptr(_res));
16923         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
16924 }
16925
16926 static inline uint64_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
16927         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
16928         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
16929         return tag_ptr(ret_conv, true);
16930 }
16931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16932         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(arg);
16933         int64_t ret_conv = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
16934         return ret_conv;
16935 }
16936
16937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16938         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(orig);
16939         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
16940         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
16941         return tag_ptr(ret_conv, true);
16942 }
16943
16944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16945         LDKCVec_NetAddressZ _res_constr;
16946         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16947         if (_res_constr.datalen > 0)
16948                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
16949         else
16950                 _res_constr.data = NULL;
16951         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16952         for (size_t m = 0; m < _res_constr.datalen; m++) {
16953                 int64_t _res_conv_12 = _res_vals[m];
16954                 void* _res_conv_12_ptr = untag_ptr(_res_conv_12);
16955                 CHECK_ACCESS(_res_conv_12_ptr);
16956                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
16957                 FREE(untag_ptr(_res_conv_12));
16958                 _res_constr.data[m] = _res_conv_12_conv;
16959         }
16960         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16961         CVec_NetAddressZ_free(_res_constr);
16962 }
16963
16964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16965         LDKNodeAnnouncementInfo o_conv;
16966         o_conv.inner = untag_ptr(o);
16967         o_conv.is_owned = ptr_is_owned(o);
16968         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16969         o_conv = NodeAnnouncementInfo_clone(&o_conv);
16970         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
16971         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
16972         return tag_ptr(ret_conv, true);
16973 }
16974
16975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16976         LDKDecodeError e_conv;
16977         e_conv.inner = untag_ptr(e);
16978         e_conv.is_owned = ptr_is_owned(e);
16979         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16980         e_conv = DecodeError_clone(&e_conv);
16981         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
16982         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
16983         return tag_ptr(ret_conv, true);
16984 }
16985
16986 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16987         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(o);
16988         jboolean ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
16989         return ret_conv;
16990 }
16991
16992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16993         if (!ptr_is_owned(_res)) return;
16994         void* _res_ptr = untag_ptr(_res);
16995         CHECK_ACCESS(_res_ptr);
16996         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
16997         FREE(untag_ptr(_res));
16998         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
16999 }
17000
17001 static inline uint64_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
17002         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17003         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
17004         return tag_ptr(ret_conv, true);
17005 }
17006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17007         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(arg);
17008         int64_t ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
17009         return ret_conv;
17010 }
17011
17012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17013         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(orig);
17014         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17015         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
17016         return tag_ptr(ret_conv, true);
17017 }
17018
17019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17020         LDKNodeAlias o_conv;
17021         o_conv.inner = untag_ptr(o);
17022         o_conv.is_owned = ptr_is_owned(o);
17023         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17024         o_conv = NodeAlias_clone(&o_conv);
17025         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
17026         *ret_conv = CResult_NodeAliasDecodeErrorZ_ok(o_conv);
17027         return tag_ptr(ret_conv, true);
17028 }
17029
17030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17031         LDKDecodeError e_conv;
17032         e_conv.inner = untag_ptr(e);
17033         e_conv.is_owned = ptr_is_owned(e);
17034         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17035         e_conv = DecodeError_clone(&e_conv);
17036         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
17037         *ret_conv = CResult_NodeAliasDecodeErrorZ_err(e_conv);
17038         return tag_ptr(ret_conv, true);
17039 }
17040
17041 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17042         LDKCResult_NodeAliasDecodeErrorZ* o_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(o);
17043         jboolean ret_conv = CResult_NodeAliasDecodeErrorZ_is_ok(o_conv);
17044         return ret_conv;
17045 }
17046
17047 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17048         if (!ptr_is_owned(_res)) return;
17049         void* _res_ptr = untag_ptr(_res);
17050         CHECK_ACCESS(_res_ptr);
17051         LDKCResult_NodeAliasDecodeErrorZ _res_conv = *(LDKCResult_NodeAliasDecodeErrorZ*)(_res_ptr);
17052         FREE(untag_ptr(_res));
17053         CResult_NodeAliasDecodeErrorZ_free(_res_conv);
17054 }
17055
17056 static inline uint64_t CResult_NodeAliasDecodeErrorZ_clone_ptr(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR arg) {
17057         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
17058         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(arg);
17059         return tag_ptr(ret_conv, true);
17060 }
17061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17062         LDKCResult_NodeAliasDecodeErrorZ* arg_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(arg);
17063         int64_t ret_conv = CResult_NodeAliasDecodeErrorZ_clone_ptr(arg_conv);
17064         return ret_conv;
17065 }
17066
17067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17068         LDKCResult_NodeAliasDecodeErrorZ* orig_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(orig);
17069         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
17070         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(orig_conv);
17071         return tag_ptr(ret_conv, true);
17072 }
17073
17074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17075         LDKNodeInfo o_conv;
17076         o_conv.inner = untag_ptr(o);
17077         o_conv.is_owned = ptr_is_owned(o);
17078         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17079         o_conv = NodeInfo_clone(&o_conv);
17080         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17081         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
17082         return tag_ptr(ret_conv, true);
17083 }
17084
17085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17086         LDKDecodeError e_conv;
17087         e_conv.inner = untag_ptr(e);
17088         e_conv.is_owned = ptr_is_owned(e);
17089         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17090         e_conv = DecodeError_clone(&e_conv);
17091         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17092         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
17093         return tag_ptr(ret_conv, true);
17094 }
17095
17096 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17097         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(o);
17098         jboolean ret_conv = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
17099         return ret_conv;
17100 }
17101
17102 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17103         if (!ptr_is_owned(_res)) return;
17104         void* _res_ptr = untag_ptr(_res);
17105         CHECK_ACCESS(_res_ptr);
17106         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
17107         FREE(untag_ptr(_res));
17108         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
17109 }
17110
17111 static inline uint64_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
17112         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17113         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
17114         return tag_ptr(ret_conv, true);
17115 }
17116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17117         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(arg);
17118         int64_t ret_conv = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
17119         return ret_conv;
17120 }
17121
17122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17123         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(orig);
17124         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17125         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
17126         return tag_ptr(ret_conv, true);
17127 }
17128
17129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17130         LDKNetworkGraph o_conv;
17131         o_conv.inner = untag_ptr(o);
17132         o_conv.is_owned = ptr_is_owned(o);
17133         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17134         // WARNING: we need a move here but no clone is available for LDKNetworkGraph
17135         
17136         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17137         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
17138         return tag_ptr(ret_conv, true);
17139 }
17140
17141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17142         LDKDecodeError e_conv;
17143         e_conv.inner = untag_ptr(e);
17144         e_conv.is_owned = ptr_is_owned(e);
17145         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17146         e_conv = DecodeError_clone(&e_conv);
17147         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17148         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
17149         return tag_ptr(ret_conv, true);
17150 }
17151
17152 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17153         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(o);
17154         jboolean ret_conv = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
17155         return ret_conv;
17156 }
17157
17158 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17159         if (!ptr_is_owned(_res)) return;
17160         void* _res_ptr = untag_ptr(_res);
17161         CHECK_ACCESS(_res_ptr);
17162         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
17163         FREE(untag_ptr(_res));
17164         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
17165 }
17166
17167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1some(JNIEnv *env, jclass clz, int64_tArray o) {
17168         LDKCVec_NetAddressZ o_constr;
17169         o_constr.datalen = (*env)->GetArrayLength(env, o);
17170         if (o_constr.datalen > 0)
17171                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
17172         else
17173                 o_constr.data = NULL;
17174         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
17175         for (size_t m = 0; m < o_constr.datalen; m++) {
17176                 int64_t o_conv_12 = o_vals[m];
17177                 void* o_conv_12_ptr = untag_ptr(o_conv_12);
17178                 CHECK_ACCESS(o_conv_12_ptr);
17179                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
17180                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o_conv_12));
17181                 o_constr.data[m] = o_conv_12_conv;
17182         }
17183         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
17184         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17185         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
17186         int64_t ret_ref = tag_ptr(ret_copy, true);
17187         return ret_ref;
17188 }
17189
17190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1none(JNIEnv *env, jclass clz) {
17191         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17192         *ret_copy = COption_CVec_NetAddressZZ_none();
17193         int64_t ret_ref = tag_ptr(ret_copy, true);
17194         return ret_ref;
17195 }
17196
17197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17198         if (!ptr_is_owned(_res)) return;
17199         void* _res_ptr = untag_ptr(_res);
17200         CHECK_ACCESS(_res_ptr);
17201         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
17202         FREE(untag_ptr(_res));
17203         COption_CVec_NetAddressZZ_free(_res_conv);
17204 }
17205
17206 static inline uint64_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
17207         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17208         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
17209         int64_t ret_ref = tag_ptr(ret_copy, true);
17210         return ret_ref;
17211 }
17212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17213         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)untag_ptr(arg);
17214         int64_t ret_conv = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
17215         return ret_conv;
17216 }
17217
17218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17219         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)untag_ptr(orig);
17220         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17221         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
17222         int64_t ret_ref = tag_ptr(ret_copy, true);
17223         return ret_ref;
17224 }
17225
17226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17227         LDKDelayedPaymentOutputDescriptor o_conv;
17228         o_conv.inner = untag_ptr(o);
17229         o_conv.is_owned = ptr_is_owned(o);
17230         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17231         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
17232         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
17233         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
17234         return tag_ptr(ret_conv, true);
17235 }
17236
17237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17238         LDKDecodeError e_conv;
17239         e_conv.inner = untag_ptr(e);
17240         e_conv.is_owned = ptr_is_owned(e);
17241         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17242         e_conv = DecodeError_clone(&e_conv);
17243         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
17244         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
17245         return tag_ptr(ret_conv, true);
17246 }
17247
17248 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17249         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(o);
17250         jboolean ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
17251         return ret_conv;
17252 }
17253
17254 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17255         if (!ptr_is_owned(_res)) return;
17256         void* _res_ptr = untag_ptr(_res);
17257         CHECK_ACCESS(_res_ptr);
17258         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
17259         FREE(untag_ptr(_res));
17260         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
17261 }
17262
17263 static inline uint64_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
17264         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
17265         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
17266         return tag_ptr(ret_conv, true);
17267 }
17268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17269         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
17270         int64_t ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
17271         return ret_conv;
17272 }
17273
17274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17275         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
17276         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
17277         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
17278         return tag_ptr(ret_conv, true);
17279 }
17280
17281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17282         LDKStaticPaymentOutputDescriptor o_conv;
17283         o_conv.inner = untag_ptr(o);
17284         o_conv.is_owned = ptr_is_owned(o);
17285         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17286         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
17287         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
17288         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
17289         return tag_ptr(ret_conv, true);
17290 }
17291
17292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17293         LDKDecodeError e_conv;
17294         e_conv.inner = untag_ptr(e);
17295         e_conv.is_owned = ptr_is_owned(e);
17296         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17297         e_conv = DecodeError_clone(&e_conv);
17298         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
17299         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
17300         return tag_ptr(ret_conv, true);
17301 }
17302
17303 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17304         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(o);
17305         jboolean ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
17306         return ret_conv;
17307 }
17308
17309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17310         if (!ptr_is_owned(_res)) return;
17311         void* _res_ptr = untag_ptr(_res);
17312         CHECK_ACCESS(_res_ptr);
17313         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
17314         FREE(untag_ptr(_res));
17315         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
17316 }
17317
17318 static inline uint64_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
17319         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
17320         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
17321         return tag_ptr(ret_conv, true);
17322 }
17323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17324         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
17325         int64_t ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
17326         return ret_conv;
17327 }
17328
17329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17330         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
17331         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
17332         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
17333         return tag_ptr(ret_conv, true);
17334 }
17335
17336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17337         void* o_ptr = untag_ptr(o);
17338         CHECK_ACCESS(o_ptr);
17339         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
17340         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(o));
17341         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
17342         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
17343         return tag_ptr(ret_conv, true);
17344 }
17345
17346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17347         LDKDecodeError e_conv;
17348         e_conv.inner = untag_ptr(e);
17349         e_conv.is_owned = ptr_is_owned(e);
17350         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17351         e_conv = DecodeError_clone(&e_conv);
17352         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
17353         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
17354         return tag_ptr(ret_conv, true);
17355 }
17356
17357 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17358         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(o);
17359         jboolean ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
17360         return ret_conv;
17361 }
17362
17363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17364         if (!ptr_is_owned(_res)) return;
17365         void* _res_ptr = untag_ptr(_res);
17366         CHECK_ACCESS(_res_ptr);
17367         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
17368         FREE(untag_ptr(_res));
17369         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
17370 }
17371
17372 static inline uint64_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
17373         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
17374         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
17375         return tag_ptr(ret_conv, true);
17376 }
17377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17378         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
17379         int64_t ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
17380         return ret_conv;
17381 }
17382
17383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17384         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
17385         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
17386         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
17387         return tag_ptr(ret_conv, true);
17388 }
17389
17390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PaymentPreimageZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
17391         LDKCVec_PaymentPreimageZ _res_constr;
17392         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17393         if (_res_constr.datalen > 0)
17394                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
17395         else
17396                 _res_constr.data = NULL;
17397         for (size_t i = 0; i < _res_constr.datalen; i++) {
17398                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
17399                 LDKThirtyTwoBytes _res_conv_8_ref;
17400                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
17401                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
17402                 _res_constr.data[i] = _res_conv_8_ref;
17403         }
17404         CVec_PaymentPreimageZ_free(_res_constr);
17405 }
17406
17407 static inline uint64_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
17408         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
17409         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
17410         return tag_ptr(ret_conv, true);
17411 }
17412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17413         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(arg);
17414         int64_t ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
17415         return ret_conv;
17416 }
17417
17418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17419         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(orig);
17420         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
17421         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
17422         return tag_ptr(ret_conv, true);
17423 }
17424
17425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
17426         LDKSignature a_ref;
17427         CHECK((*env)->GetArrayLength(env, a) == 64);
17428         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
17429         LDKCVec_SignatureZ b_constr;
17430         b_constr.datalen = (*env)->GetArrayLength(env, b);
17431         if (b_constr.datalen > 0)
17432                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
17433         else
17434                 b_constr.data = NULL;
17435         for (size_t i = 0; i < b_constr.datalen; i++) {
17436                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
17437                 LDKSignature b_conv_8_ref;
17438                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
17439                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
17440                 b_constr.data[i] = b_conv_8_ref;
17441         }
17442         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
17443         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
17444         return tag_ptr(ret_conv, true);
17445 }
17446
17447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17448         if (!ptr_is_owned(_res)) return;
17449         void* _res_ptr = untag_ptr(_res);
17450         CHECK_ACCESS(_res_ptr);
17451         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
17452         FREE(untag_ptr(_res));
17453         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
17454 }
17455
17456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17457         void* o_ptr = untag_ptr(o);
17458         CHECK_ACCESS(o_ptr);
17459         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
17460         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(o));
17461         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
17462         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
17463         return tag_ptr(ret_conv, true);
17464 }
17465
17466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
17467         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
17468         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
17469         return tag_ptr(ret_conv, true);
17470 }
17471
17472 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17473         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(o);
17474         jboolean ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
17475         return ret_conv;
17476 }
17477
17478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17479         if (!ptr_is_owned(_res)) return;
17480         void* _res_ptr = untag_ptr(_res);
17481         CHECK_ACCESS(_res_ptr);
17482         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
17483         FREE(untag_ptr(_res));
17484         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
17485 }
17486
17487 static inline uint64_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
17488         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
17489         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
17490         return tag_ptr(ret_conv, true);
17491 }
17492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17493         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(arg);
17494         int64_t ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
17495         return ret_conv;
17496 }
17497
17498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17499         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(orig);
17500         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
17501         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
17502         return tag_ptr(ret_conv, true);
17503 }
17504
17505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
17506         LDKSignature o_ref;
17507         CHECK((*env)->GetArrayLength(env, o) == 64);
17508         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
17509         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
17510         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
17511         return tag_ptr(ret_conv, true);
17512 }
17513
17514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
17515         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
17516         *ret_conv = CResult_SignatureNoneZ_err();
17517         return tag_ptr(ret_conv, true);
17518 }
17519
17520 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17521         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(o);
17522         jboolean ret_conv = CResult_SignatureNoneZ_is_ok(o_conv);
17523         return ret_conv;
17524 }
17525
17526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17527         if (!ptr_is_owned(_res)) return;
17528         void* _res_ptr = untag_ptr(_res);
17529         CHECK_ACCESS(_res_ptr);
17530         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
17531         FREE(untag_ptr(_res));
17532         CResult_SignatureNoneZ_free(_res_conv);
17533 }
17534
17535 static inline uint64_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
17536         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
17537         *ret_conv = CResult_SignatureNoneZ_clone(arg);
17538         return tag_ptr(ret_conv, true);
17539 }
17540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17541         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(arg);
17542         int64_t ret_conv = CResult_SignatureNoneZ_clone_ptr(arg_conv);
17543         return ret_conv;
17544 }
17545
17546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17547         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(orig);
17548         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
17549         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
17550         return tag_ptr(ret_conv, true);
17551 }
17552
17553 static inline uint64_t C2Tuple_SignatureSignatureZ_clone_ptr(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR arg) {
17554         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
17555         *ret_conv = C2Tuple_SignatureSignatureZ_clone(arg);
17556         return tag_ptr(ret_conv, true);
17557 }
17558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17559         LDKC2Tuple_SignatureSignatureZ* arg_conv = (LDKC2Tuple_SignatureSignatureZ*)untag_ptr(arg);
17560         int64_t ret_conv = C2Tuple_SignatureSignatureZ_clone_ptr(arg_conv);
17561         return ret_conv;
17562 }
17563
17564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17565         LDKC2Tuple_SignatureSignatureZ* orig_conv = (LDKC2Tuple_SignatureSignatureZ*)untag_ptr(orig);
17566         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
17567         *ret_conv = C2Tuple_SignatureSignatureZ_clone(orig_conv);
17568         return tag_ptr(ret_conv, true);
17569 }
17570
17571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
17572         LDKSignature a_ref;
17573         CHECK((*env)->GetArrayLength(env, a) == 64);
17574         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
17575         LDKSignature b_ref;
17576         CHECK((*env)->GetArrayLength(env, b) == 64);
17577         (*env)->GetByteArrayRegion(env, b, 0, 64, b_ref.compact_form);
17578         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
17579         *ret_conv = C2Tuple_SignatureSignatureZ_new(a_ref, b_ref);
17580         return tag_ptr(ret_conv, true);
17581 }
17582
17583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17584         if (!ptr_is_owned(_res)) return;
17585         void* _res_ptr = untag_ptr(_res);
17586         CHECK_ACCESS(_res_ptr);
17587         LDKC2Tuple_SignatureSignatureZ _res_conv = *(LDKC2Tuple_SignatureSignatureZ*)(_res_ptr);
17588         FREE(untag_ptr(_res));
17589         C2Tuple_SignatureSignatureZ_free(_res_conv);
17590 }
17591
17592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17593         void* o_ptr = untag_ptr(o);
17594         CHECK_ACCESS(o_ptr);
17595         LDKC2Tuple_SignatureSignatureZ o_conv = *(LDKC2Tuple_SignatureSignatureZ*)(o_ptr);
17596         o_conv = C2Tuple_SignatureSignatureZ_clone((LDKC2Tuple_SignatureSignatureZ*)untag_ptr(o));
17597         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
17598         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o_conv);
17599         return tag_ptr(ret_conv, true);
17600 }
17601
17602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
17603         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
17604         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_err();
17605         return tag_ptr(ret_conv, true);
17606 }
17607
17608 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17609         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(o);
17610         jboolean ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o_conv);
17611         return ret_conv;
17612 }
17613
17614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17615         if (!ptr_is_owned(_res)) return;
17616         void* _res_ptr = untag_ptr(_res);
17617         CHECK_ACCESS(_res_ptr);
17618         LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(_res_ptr);
17619         FREE(untag_ptr(_res));
17620         CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res_conv);
17621 }
17622
17623 static inline uint64_t CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR arg) {
17624         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
17625         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(arg);
17626         return tag_ptr(ret_conv, true);
17627 }
17628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17629         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(arg);
17630         int64_t ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(arg_conv);
17631         return ret_conv;
17632 }
17633
17634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17635         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(orig);
17636         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
17637         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig_conv);
17638         return tag_ptr(ret_conv, true);
17639 }
17640
17641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
17642         LDKSecretKey o_ref;
17643         CHECK((*env)->GetArrayLength(env, o) == 32);
17644         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
17645         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
17646         *ret_conv = CResult_SecretKeyNoneZ_ok(o_ref);
17647         return tag_ptr(ret_conv, true);
17648 }
17649
17650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1err(JNIEnv *env, jclass clz) {
17651         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
17652         *ret_conv = CResult_SecretKeyNoneZ_err();
17653         return tag_ptr(ret_conv, true);
17654 }
17655
17656 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17657         LDKCResult_SecretKeyNoneZ* o_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(o);
17658         jboolean ret_conv = CResult_SecretKeyNoneZ_is_ok(o_conv);
17659         return ret_conv;
17660 }
17661
17662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17663         if (!ptr_is_owned(_res)) return;
17664         void* _res_ptr = untag_ptr(_res);
17665         CHECK_ACCESS(_res_ptr);
17666         LDKCResult_SecretKeyNoneZ _res_conv = *(LDKCResult_SecretKeyNoneZ*)(_res_ptr);
17667         FREE(untag_ptr(_res));
17668         CResult_SecretKeyNoneZ_free(_res_conv);
17669 }
17670
17671 static inline uint64_t CResult_SecretKeyNoneZ_clone_ptr(LDKCResult_SecretKeyNoneZ *NONNULL_PTR arg) {
17672         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
17673         *ret_conv = CResult_SecretKeyNoneZ_clone(arg);
17674         return tag_ptr(ret_conv, true);
17675 }
17676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17677         LDKCResult_SecretKeyNoneZ* arg_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(arg);
17678         int64_t ret_conv = CResult_SecretKeyNoneZ_clone_ptr(arg_conv);
17679         return ret_conv;
17680 }
17681
17682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17683         LDKCResult_SecretKeyNoneZ* orig_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(orig);
17684         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
17685         *ret_conv = CResult_SecretKeyNoneZ_clone(orig_conv);
17686         return tag_ptr(ret_conv, true);
17687 }
17688
17689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17690         void* o_ptr = untag_ptr(o);
17691         CHECK_ACCESS(o_ptr);
17692         LDKSign o_conv = *(LDKSign*)(o_ptr);
17693         if (o_conv.free == LDKSign_JCalls_free) {
17694                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17695                 LDKSign_JCalls_cloned(&o_conv);
17696         }
17697         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
17698         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
17699         return tag_ptr(ret_conv, true);
17700 }
17701
17702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17703         LDKDecodeError e_conv;
17704         e_conv.inner = untag_ptr(e);
17705         e_conv.is_owned = ptr_is_owned(e);
17706         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17707         e_conv = DecodeError_clone(&e_conv);
17708         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
17709         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
17710         return tag_ptr(ret_conv, true);
17711 }
17712
17713 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17714         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(o);
17715         jboolean ret_conv = CResult_SignDecodeErrorZ_is_ok(o_conv);
17716         return ret_conv;
17717 }
17718
17719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17720         if (!ptr_is_owned(_res)) return;
17721         void* _res_ptr = untag_ptr(_res);
17722         CHECK_ACCESS(_res_ptr);
17723         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
17724         FREE(untag_ptr(_res));
17725         CResult_SignDecodeErrorZ_free(_res_conv);
17726 }
17727
17728 static inline uint64_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
17729         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
17730         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
17731         return tag_ptr(ret_conv, true);
17732 }
17733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17734         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(arg);
17735         int64_t ret_conv = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
17736         return ret_conv;
17737 }
17738
17739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17740         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(orig);
17741         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
17742         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
17743         return tag_ptr(ret_conv, true);
17744 }
17745
17746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u5Z_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
17747         LDKCVec_u5Z _res_constr;
17748         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17749         if (_res_constr.datalen > 0)
17750                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
17751         else
17752                 _res_constr.data = NULL;
17753         int8_t* _res_vals = (*env)->GetByteArrayElements (env, _res, NULL);
17754         for (size_t h = 0; h < _res_constr.datalen; h++) {
17755                 int8_t _res_conv_7 = _res_vals[h];
17756                 
17757                 _res_constr.data[h] = (LDKu5){ ._0 = _res_conv_7 };
17758         }
17759         (*env)->ReleaseByteArrayElements(env, _res, _res_vals, 0);
17760         CVec_u5Z_free(_res_constr);
17761 }
17762
17763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
17764         LDKRecoverableSignature o_ref;
17765         CHECK((*env)->GetArrayLength(env, o) == 68);
17766         (*env)->GetByteArrayRegion(env, o, 0, 68, o_ref.serialized_form);
17767         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
17768         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
17769         return tag_ptr(ret_conv, true);
17770 }
17771
17772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
17773         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
17774         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
17775         return tag_ptr(ret_conv, true);
17776 }
17777
17778 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17779         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(o);
17780         jboolean ret_conv = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
17781         return ret_conv;
17782 }
17783
17784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17785         if (!ptr_is_owned(_res)) return;
17786         void* _res_ptr = untag_ptr(_res);
17787         CHECK_ACCESS(_res_ptr);
17788         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
17789         FREE(untag_ptr(_res));
17790         CResult_RecoverableSignatureNoneZ_free(_res_conv);
17791 }
17792
17793 static inline uint64_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
17794         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
17795         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
17796         return tag_ptr(ret_conv, true);
17797 }
17798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17799         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(arg);
17800         int64_t ret_conv = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
17801         return ret_conv;
17802 }
17803
17804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17805         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(orig);
17806         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
17807         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
17808         return tag_ptr(ret_conv, true);
17809 }
17810
17811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
17812         LDKCVec_u8Z _res_ref;
17813         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
17814         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
17815         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
17816         CVec_u8Z_free(_res_ref);
17817 }
17818
17819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
17820         LDKCVec_CVec_u8ZZ _res_constr;
17821         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17822         if (_res_constr.datalen > 0)
17823                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
17824         else
17825                 _res_constr.data = NULL;
17826         for (size_t i = 0; i < _res_constr.datalen; i++) {
17827                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
17828                 LDKCVec_u8Z _res_conv_8_ref;
17829                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
17830                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
17831                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
17832                 _res_constr.data[i] = _res_conv_8_ref;
17833         }
17834         CVec_CVec_u8ZZ_free(_res_constr);
17835 }
17836
17837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
17838         LDKCVec_CVec_u8ZZ o_constr;
17839         o_constr.datalen = (*env)->GetArrayLength(env, o);
17840         if (o_constr.datalen > 0)
17841                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
17842         else
17843                 o_constr.data = NULL;
17844         for (size_t i = 0; i < o_constr.datalen; i++) {
17845                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
17846                 LDKCVec_u8Z o_conv_8_ref;
17847                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
17848                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
17849                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
17850                 o_constr.data[i] = o_conv_8_ref;
17851         }
17852         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
17853         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
17854         return tag_ptr(ret_conv, true);
17855 }
17856
17857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
17858         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
17859         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
17860         return tag_ptr(ret_conv, true);
17861 }
17862
17863 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17864         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(o);
17865         jboolean ret_conv = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
17866         return ret_conv;
17867 }
17868
17869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17870         if (!ptr_is_owned(_res)) return;
17871         void* _res_ptr = untag_ptr(_res);
17872         CHECK_ACCESS(_res_ptr);
17873         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
17874         FREE(untag_ptr(_res));
17875         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
17876 }
17877
17878 static inline uint64_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
17879         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
17880         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
17881         return tag_ptr(ret_conv, true);
17882 }
17883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17884         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(arg);
17885         int64_t ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
17886         return ret_conv;
17887 }
17888
17889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17890         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(orig);
17891         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
17892         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
17893         return tag_ptr(ret_conv, true);
17894 }
17895
17896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17897         LDKInMemorySigner o_conv;
17898         o_conv.inner = untag_ptr(o);
17899         o_conv.is_owned = ptr_is_owned(o);
17900         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17901         o_conv = InMemorySigner_clone(&o_conv);
17902         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
17903         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
17904         return tag_ptr(ret_conv, true);
17905 }
17906
17907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17908         LDKDecodeError e_conv;
17909         e_conv.inner = untag_ptr(e);
17910         e_conv.is_owned = ptr_is_owned(e);
17911         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17912         e_conv = DecodeError_clone(&e_conv);
17913         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
17914         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
17915         return tag_ptr(ret_conv, true);
17916 }
17917
17918 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17919         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(o);
17920         jboolean ret_conv = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
17921         return ret_conv;
17922 }
17923
17924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17925         if (!ptr_is_owned(_res)) return;
17926         void* _res_ptr = untag_ptr(_res);
17927         CHECK_ACCESS(_res_ptr);
17928         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
17929         FREE(untag_ptr(_res));
17930         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
17931 }
17932
17933 static inline uint64_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
17934         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
17935         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
17936         return tag_ptr(ret_conv, true);
17937 }
17938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17939         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(arg);
17940         int64_t ret_conv = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
17941         return ret_conv;
17942 }
17943
17944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17945         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(orig);
17946         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
17947         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
17948         return tag_ptr(ret_conv, true);
17949 }
17950
17951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17952         LDKCVec_TxOutZ _res_constr;
17953         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17954         if (_res_constr.datalen > 0)
17955                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
17956         else
17957                 _res_constr.data = NULL;
17958         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17959         for (size_t h = 0; h < _res_constr.datalen; h++) {
17960                 int64_t _res_conv_7 = _res_vals[h];
17961                 void* _res_conv_7_ptr = untag_ptr(_res_conv_7);
17962                 CHECK_ACCESS(_res_conv_7_ptr);
17963                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
17964                 FREE(untag_ptr(_res_conv_7));
17965                 _res_constr.data[h] = _res_conv_7_conv;
17966         }
17967         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17968         CVec_TxOutZ_free(_res_constr);
17969 }
17970
17971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
17972         LDKTransaction o_ref;
17973         o_ref.datalen = (*env)->GetArrayLength(env, o);
17974         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
17975         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
17976         o_ref.data_is_owned = true;
17977         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
17978         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
17979         return tag_ptr(ret_conv, true);
17980 }
17981
17982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
17983         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
17984         *ret_conv = CResult_TransactionNoneZ_err();
17985         return tag_ptr(ret_conv, true);
17986 }
17987
17988 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17989         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(o);
17990         jboolean ret_conv = CResult_TransactionNoneZ_is_ok(o_conv);
17991         return ret_conv;
17992 }
17993
17994 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17995         if (!ptr_is_owned(_res)) return;
17996         void* _res_ptr = untag_ptr(_res);
17997         CHECK_ACCESS(_res_ptr);
17998         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
17999         FREE(untag_ptr(_res));
18000         CResult_TransactionNoneZ_free(_res_conv);
18001 }
18002
18003 static inline uint64_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
18004         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
18005         *ret_conv = CResult_TransactionNoneZ_clone(arg);
18006         return tag_ptr(ret_conv, true);
18007 }
18008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18009         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(arg);
18010         int64_t ret_conv = CResult_TransactionNoneZ_clone_ptr(arg_conv);
18011         return ret_conv;
18012 }
18013
18014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18015         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(orig);
18016         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
18017         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
18018         return tag_ptr(ret_conv, true);
18019 }
18020
18021 static inline uint64_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
18022         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
18023         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
18024         return tag_ptr(ret_conv, true);
18025 }
18026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18027         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(arg);
18028         int64_t ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
18029         return ret_conv;
18030 }
18031
18032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18033         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(orig);
18034         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
18035         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
18036         return tag_ptr(ret_conv, true);
18037 }
18038
18039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
18040         LDKThirtyTwoBytes a_ref;
18041         CHECK((*env)->GetArrayLength(env, a) == 32);
18042         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
18043         LDKChannelMonitor b_conv;
18044         b_conv.inner = untag_ptr(b);
18045         b_conv.is_owned = ptr_is_owned(b);
18046         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
18047         b_conv = ChannelMonitor_clone(&b_conv);
18048         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
18049         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
18050         return tag_ptr(ret_conv, true);
18051 }
18052
18053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18054         if (!ptr_is_owned(_res)) return;
18055         void* _res_ptr = untag_ptr(_res);
18056         CHECK_ACCESS(_res_ptr);
18057         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
18058         FREE(untag_ptr(_res));
18059         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
18060 }
18061
18062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18063         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
18064         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18065         if (_res_constr.datalen > 0)
18066                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
18067         else
18068                 _res_constr.data = NULL;
18069         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18070         for (size_t j = 0; j < _res_constr.datalen; j++) {
18071                 int64_t _res_conv_35 = _res_vals[j];
18072                 void* _res_conv_35_ptr = untag_ptr(_res_conv_35);
18073                 CHECK_ACCESS(_res_conv_35_ptr);
18074                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
18075                 FREE(untag_ptr(_res_conv_35));
18076                 _res_constr.data[j] = _res_conv_35_conv;
18077         }
18078         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18079         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
18080 }
18081
18082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
18083         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
18084         o_constr.datalen = (*env)->GetArrayLength(env, o);
18085         if (o_constr.datalen > 0)
18086                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
18087         else
18088                 o_constr.data = NULL;
18089         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
18090         for (size_t j = 0; j < o_constr.datalen; j++) {
18091                 int64_t o_conv_35 = o_vals[j];
18092                 void* o_conv_35_ptr = untag_ptr(o_conv_35);
18093                 CHECK_ACCESS(o_conv_35_ptr);
18094                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
18095                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(o_conv_35));
18096                 o_constr.data[j] = o_conv_35_conv;
18097         }
18098         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
18099         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
18100         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
18101         return tag_ptr(ret_conv, true);
18102 }
18103
18104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
18105         LDKIOError e_conv = LDKIOError_from_java(env, e);
18106         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
18107         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
18108         return tag_ptr(ret_conv, true);
18109 }
18110
18111 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18112         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(o);
18113         jboolean ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o_conv);
18114         return ret_conv;
18115 }
18116
18117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18118         if (!ptr_is_owned(_res)) return;
18119         void* _res_ptr = untag_ptr(_res);
18120         CHECK_ACCESS(_res_ptr);
18121         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
18122         FREE(untag_ptr(_res));
18123         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
18124 }
18125
18126 static inline uint64_t CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR arg) {
18127         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
18128         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(arg);
18129         return tag_ptr(ret_conv, true);
18130 }
18131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18132         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(arg);
18133         int64_t ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(arg_conv);
18134         return ret_conv;
18135 }
18136
18137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18138         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(orig);
18139         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
18140         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
18141         return tag_ptr(ret_conv, true);
18142 }
18143
18144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
18145         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
18146         *ret_copy = COption_u16Z_some(o);
18147         int64_t ret_ref = tag_ptr(ret_copy, true);
18148         return ret_ref;
18149 }
18150
18151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
18152         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
18153         *ret_copy = COption_u16Z_none();
18154         int64_t ret_ref = tag_ptr(ret_copy, true);
18155         return ret_ref;
18156 }
18157
18158 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
18159         if (!ptr_is_owned(_res)) return;
18160         void* _res_ptr = untag_ptr(_res);
18161         CHECK_ACCESS(_res_ptr);
18162         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
18163         FREE(untag_ptr(_res));
18164         COption_u16Z_free(_res_conv);
18165 }
18166
18167 static inline uint64_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
18168         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
18169         *ret_copy = COption_u16Z_clone(arg);
18170         int64_t ret_ref = tag_ptr(ret_copy, true);
18171         return ret_ref;
18172 }
18173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18174         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)untag_ptr(arg);
18175         int64_t ret_conv = COption_u16Z_clone_ptr(arg_conv);
18176         return ret_conv;
18177 }
18178
18179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18180         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)untag_ptr(orig);
18181         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
18182         *ret_copy = COption_u16Z_clone(orig_conv);
18183         int64_t ret_ref = tag_ptr(ret_copy, true);
18184         return ret_ref;
18185 }
18186
18187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
18188         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
18189         *ret_conv = CResult_NoneAPIErrorZ_ok();
18190         return tag_ptr(ret_conv, true);
18191 }
18192
18193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18194         void* e_ptr = untag_ptr(e);
18195         CHECK_ACCESS(e_ptr);
18196         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
18197         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
18198         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
18199         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
18200         return tag_ptr(ret_conv, true);
18201 }
18202
18203 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18204         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(o);
18205         jboolean ret_conv = CResult_NoneAPIErrorZ_is_ok(o_conv);
18206         return ret_conv;
18207 }
18208
18209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18210         if (!ptr_is_owned(_res)) return;
18211         void* _res_ptr = untag_ptr(_res);
18212         CHECK_ACCESS(_res_ptr);
18213         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
18214         FREE(untag_ptr(_res));
18215         CResult_NoneAPIErrorZ_free(_res_conv);
18216 }
18217
18218 static inline uint64_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
18219         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
18220         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
18221         return tag_ptr(ret_conv, true);
18222 }
18223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18224         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(arg);
18225         int64_t ret_conv = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
18226         return ret_conv;
18227 }
18228
18229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18230         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(orig);
18231         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
18232         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
18233         return tag_ptr(ret_conv, true);
18234 }
18235
18236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18237         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
18238         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18239         if (_res_constr.datalen > 0)
18240                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
18241         else
18242                 _res_constr.data = NULL;
18243         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18244         for (size_t w = 0; w < _res_constr.datalen; w++) {
18245                 int64_t _res_conv_22 = _res_vals[w];
18246                 void* _res_conv_22_ptr = untag_ptr(_res_conv_22);
18247                 CHECK_ACCESS(_res_conv_22_ptr);
18248                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
18249                 FREE(untag_ptr(_res_conv_22));
18250                 _res_constr.data[w] = _res_conv_22_conv;
18251         }
18252         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18253         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
18254 }
18255
18256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18257         LDKCVec_APIErrorZ _res_constr;
18258         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18259         if (_res_constr.datalen > 0)
18260                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
18261         else
18262                 _res_constr.data = NULL;
18263         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18264         for (size_t k = 0; k < _res_constr.datalen; k++) {
18265                 int64_t _res_conv_10 = _res_vals[k];
18266                 void* _res_conv_10_ptr = untag_ptr(_res_conv_10);
18267                 CHECK_ACCESS(_res_conv_10_ptr);
18268                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
18269                 FREE(untag_ptr(_res_conv_10));
18270                 _res_constr.data[k] = _res_conv_10_conv;
18271         }
18272         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18273         CVec_APIErrorZ_free(_res_constr);
18274 }
18275
18276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18277         LDKThirtyTwoBytes o_ref;
18278         CHECK((*env)->GetArrayLength(env, o) == 32);
18279         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
18280         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
18281         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
18282         return tag_ptr(ret_conv, true);
18283 }
18284
18285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18286         void* e_ptr = untag_ptr(e);
18287         CHECK_ACCESS(e_ptr);
18288         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
18289         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
18290         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
18291         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
18292         return tag_ptr(ret_conv, true);
18293 }
18294
18295 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18296         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(o);
18297         jboolean ret_conv = CResult__u832APIErrorZ_is_ok(o_conv);
18298         return ret_conv;
18299 }
18300
18301 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18302         if (!ptr_is_owned(_res)) return;
18303         void* _res_ptr = untag_ptr(_res);
18304         CHECK_ACCESS(_res_ptr);
18305         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
18306         FREE(untag_ptr(_res));
18307         CResult__u832APIErrorZ_free(_res_conv);
18308 }
18309
18310 static inline uint64_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
18311         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
18312         *ret_conv = CResult__u832APIErrorZ_clone(arg);
18313         return tag_ptr(ret_conv, true);
18314 }
18315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18316         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(arg);
18317         int64_t ret_conv = CResult__u832APIErrorZ_clone_ptr(arg_conv);
18318         return ret_conv;
18319 }
18320
18321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18322         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(orig);
18323         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
18324         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
18325         return tag_ptr(ret_conv, true);
18326 }
18327
18328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18329         LDKThirtyTwoBytes o_ref;
18330         CHECK((*env)->GetArrayLength(env, o) == 32);
18331         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
18332         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
18333         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
18334         return tag_ptr(ret_conv, true);
18335 }
18336
18337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18338         void* e_ptr = untag_ptr(e);
18339         CHECK_ACCESS(e_ptr);
18340         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
18341         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
18342         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
18343         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
18344         return tag_ptr(ret_conv, true);
18345 }
18346
18347 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18348         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)untag_ptr(o);
18349         jboolean ret_conv = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
18350         return ret_conv;
18351 }
18352
18353 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18354         if (!ptr_is_owned(_res)) return;
18355         void* _res_ptr = untag_ptr(_res);
18356         CHECK_ACCESS(_res_ptr);
18357         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
18358         FREE(untag_ptr(_res));
18359         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
18360 }
18361
18362 static inline uint64_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
18363         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
18364         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
18365         return tag_ptr(ret_conv, true);
18366 }
18367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18368         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)untag_ptr(arg);
18369         int64_t ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
18370         return ret_conv;
18371 }
18372
18373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18374         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)untag_ptr(orig);
18375         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
18376         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
18377         return tag_ptr(ret_conv, true);
18378 }
18379
18380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
18381         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
18382         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
18383         return tag_ptr(ret_conv, true);
18384 }
18385
18386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18387         void* e_ptr = untag_ptr(e);
18388         CHECK_ACCESS(e_ptr);
18389         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
18390         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
18391         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
18392         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
18393         return tag_ptr(ret_conv, true);
18394 }
18395
18396 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18397         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(o);
18398         jboolean ret_conv = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
18399         return ret_conv;
18400 }
18401
18402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18403         if (!ptr_is_owned(_res)) return;
18404         void* _res_ptr = untag_ptr(_res);
18405         CHECK_ACCESS(_res_ptr);
18406         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
18407         FREE(untag_ptr(_res));
18408         CResult_NonePaymentSendFailureZ_free(_res_conv);
18409 }
18410
18411 static inline uint64_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
18412         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
18413         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
18414         return tag_ptr(ret_conv, true);
18415 }
18416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18417         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(arg);
18418         int64_t ret_conv = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
18419         return ret_conv;
18420 }
18421
18422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18423         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(orig);
18424         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
18425         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
18426         return tag_ptr(ret_conv, true);
18427 }
18428
18429 static inline uint64_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
18430         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
18431         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
18432         return tag_ptr(ret_conv, true);
18433 }
18434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18435         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(arg);
18436         int64_t ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
18437         return ret_conv;
18438 }
18439
18440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18441         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(orig);
18442         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
18443         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
18444         return tag_ptr(ret_conv, true);
18445 }
18446
18447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
18448         LDKThirtyTwoBytes a_ref;
18449         CHECK((*env)->GetArrayLength(env, a) == 32);
18450         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
18451         LDKThirtyTwoBytes b_ref;
18452         CHECK((*env)->GetArrayLength(env, b) == 32);
18453         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
18454         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
18455         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
18456         return tag_ptr(ret_conv, true);
18457 }
18458
18459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18460         if (!ptr_is_owned(_res)) return;
18461         void* _res_ptr = untag_ptr(_res);
18462         CHECK_ACCESS(_res_ptr);
18463         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
18464         FREE(untag_ptr(_res));
18465         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
18466 }
18467
18468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18469         void* o_ptr = untag_ptr(o);
18470         CHECK_ACCESS(o_ptr);
18471         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
18472         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(o));
18473         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
18474         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
18475         return tag_ptr(ret_conv, true);
18476 }
18477
18478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18479         void* e_ptr = untag_ptr(e);
18480         CHECK_ACCESS(e_ptr);
18481         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
18482         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
18483         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
18484         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
18485         return tag_ptr(ret_conv, true);
18486 }
18487
18488 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18489         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(o);
18490         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
18491         return ret_conv;
18492 }
18493
18494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18495         if (!ptr_is_owned(_res)) return;
18496         void* _res_ptr = untag_ptr(_res);
18497         CHECK_ACCESS(_res_ptr);
18498         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
18499         FREE(untag_ptr(_res));
18500         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
18501 }
18502
18503 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
18504         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
18505         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
18506         return tag_ptr(ret_conv, true);
18507 }
18508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18509         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(arg);
18510         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
18511         return ret_conv;
18512 }
18513
18514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18515         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(orig);
18516         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
18517         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
18518         return tag_ptr(ret_conv, true);
18519 }
18520
18521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ThirtyTwoBytesZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
18522         LDKCVec_ThirtyTwoBytesZ _res_constr;
18523         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18524         if (_res_constr.datalen > 0)
18525                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
18526         else
18527                 _res_constr.data = NULL;
18528         for (size_t i = 0; i < _res_constr.datalen; i++) {
18529                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
18530                 LDKThirtyTwoBytes _res_conv_8_ref;
18531                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
18532                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
18533                 _res_constr.data[i] = _res_conv_8_ref;
18534         }
18535         CVec_ThirtyTwoBytesZ_free(_res_constr);
18536 }
18537
18538 static inline uint64_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
18539         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
18540         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
18541         return tag_ptr(ret_conv, true);
18542 }
18543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18544         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(arg);
18545         int64_t ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
18546         return ret_conv;
18547 }
18548
18549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18550         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(orig);
18551         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
18552         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
18553         return tag_ptr(ret_conv, true);
18554 }
18555
18556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
18557         LDKThirtyTwoBytes a_ref;
18558         CHECK((*env)->GetArrayLength(env, a) == 32);
18559         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
18560         LDKThirtyTwoBytes b_ref;
18561         CHECK((*env)->GetArrayLength(env, b) == 32);
18562         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
18563         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
18564         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
18565         return tag_ptr(ret_conv, true);
18566 }
18567
18568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18569         if (!ptr_is_owned(_res)) return;
18570         void* _res_ptr = untag_ptr(_res);
18571         CHECK_ACCESS(_res_ptr);
18572         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
18573         FREE(untag_ptr(_res));
18574         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
18575 }
18576
18577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18578         void* o_ptr = untag_ptr(o);
18579         CHECK_ACCESS(o_ptr);
18580         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
18581         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(o));
18582         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
18583         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
18584         return tag_ptr(ret_conv, true);
18585 }
18586
18587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1err(JNIEnv *env, jclass clz) {
18588         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
18589         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
18590         return tag_ptr(ret_conv, true);
18591 }
18592
18593 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18594         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(o);
18595         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
18596         return ret_conv;
18597 }
18598
18599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18600         if (!ptr_is_owned(_res)) return;
18601         void* _res_ptr = untag_ptr(_res);
18602         CHECK_ACCESS(_res_ptr);
18603         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
18604         FREE(untag_ptr(_res));
18605         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
18606 }
18607
18608 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
18609         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
18610         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
18611         return tag_ptr(ret_conv, true);
18612 }
18613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18614         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(arg);
18615         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
18616         return ret_conv;
18617 }
18618
18619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18620         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(orig);
18621         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
18622         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
18623         return tag_ptr(ret_conv, true);
18624 }
18625
18626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18627         void* o_ptr = untag_ptr(o);
18628         CHECK_ACCESS(o_ptr);
18629         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
18630         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(o));
18631         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
18632         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
18633         return tag_ptr(ret_conv, true);
18634 }
18635
18636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18637         void* e_ptr = untag_ptr(e);
18638         CHECK_ACCESS(e_ptr);
18639         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
18640         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
18641         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
18642         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
18643         return tag_ptr(ret_conv, true);
18644 }
18645
18646 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18647         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(o);
18648         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
18649         return ret_conv;
18650 }
18651
18652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18653         if (!ptr_is_owned(_res)) return;
18654         void* _res_ptr = untag_ptr(_res);
18655         CHECK_ACCESS(_res_ptr);
18656         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
18657         FREE(untag_ptr(_res));
18658         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
18659 }
18660
18661 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
18662         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
18663         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
18664         return tag_ptr(ret_conv, true);
18665 }
18666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18667         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(arg);
18668         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
18669         return ret_conv;
18670 }
18671
18672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18673         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(orig);
18674         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
18675         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
18676         return tag_ptr(ret_conv, true);
18677 }
18678
18679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18680         LDKThirtyTwoBytes o_ref;
18681         CHECK((*env)->GetArrayLength(env, o) == 32);
18682         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
18683         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
18684         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
18685         return tag_ptr(ret_conv, true);
18686 }
18687
18688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1err(JNIEnv *env, jclass clz) {
18689         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
18690         *ret_conv = CResult_PaymentSecretNoneZ_err();
18691         return tag_ptr(ret_conv, true);
18692 }
18693
18694 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18695         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(o);
18696         jboolean ret_conv = CResult_PaymentSecretNoneZ_is_ok(o_conv);
18697         return ret_conv;
18698 }
18699
18700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18701         if (!ptr_is_owned(_res)) return;
18702         void* _res_ptr = untag_ptr(_res);
18703         CHECK_ACCESS(_res_ptr);
18704         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
18705         FREE(untag_ptr(_res));
18706         CResult_PaymentSecretNoneZ_free(_res_conv);
18707 }
18708
18709 static inline uint64_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
18710         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
18711         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
18712         return tag_ptr(ret_conv, true);
18713 }
18714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18715         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(arg);
18716         int64_t ret_conv = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
18717         return ret_conv;
18718 }
18719
18720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18721         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(orig);
18722         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
18723         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
18724         return tag_ptr(ret_conv, true);
18725 }
18726
18727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18728         LDKThirtyTwoBytes o_ref;
18729         CHECK((*env)->GetArrayLength(env, o) == 32);
18730         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
18731         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
18732         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
18733         return tag_ptr(ret_conv, true);
18734 }
18735
18736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18737         void* e_ptr = untag_ptr(e);
18738         CHECK_ACCESS(e_ptr);
18739         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
18740         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
18741         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
18742         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
18743         return tag_ptr(ret_conv, true);
18744 }
18745
18746 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18747         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(o);
18748         jboolean ret_conv = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
18749         return ret_conv;
18750 }
18751
18752 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18753         if (!ptr_is_owned(_res)) return;
18754         void* _res_ptr = untag_ptr(_res);
18755         CHECK_ACCESS(_res_ptr);
18756         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
18757         FREE(untag_ptr(_res));
18758         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
18759 }
18760
18761 static inline uint64_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
18762         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
18763         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
18764         return tag_ptr(ret_conv, true);
18765 }
18766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18767         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(arg);
18768         int64_t ret_conv = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
18769         return ret_conv;
18770 }
18771
18772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18773         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(orig);
18774         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
18775         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
18776         return tag_ptr(ret_conv, true);
18777 }
18778
18779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18780         LDKThirtyTwoBytes o_ref;
18781         CHECK((*env)->GetArrayLength(env, o) == 32);
18782         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
18783         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
18784         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
18785         return tag_ptr(ret_conv, true);
18786 }
18787
18788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18789         void* e_ptr = untag_ptr(e);
18790         CHECK_ACCESS(e_ptr);
18791         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
18792         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
18793         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
18794         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
18795         return tag_ptr(ret_conv, true);
18796 }
18797
18798 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18799         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(o);
18800         jboolean ret_conv = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
18801         return ret_conv;
18802 }
18803
18804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18805         if (!ptr_is_owned(_res)) return;
18806         void* _res_ptr = untag_ptr(_res);
18807         CHECK_ACCESS(_res_ptr);
18808         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
18809         FREE(untag_ptr(_res));
18810         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
18811 }
18812
18813 static inline uint64_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
18814         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
18815         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
18816         return tag_ptr(ret_conv, true);
18817 }
18818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18819         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(arg);
18820         int64_t ret_conv = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
18821         return ret_conv;
18822 }
18823
18824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18825         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(orig);
18826         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
18827         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
18828         return tag_ptr(ret_conv, true);
18829 }
18830
18831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18832         LDKCounterpartyForwardingInfo o_conv;
18833         o_conv.inner = untag_ptr(o);
18834         o_conv.is_owned = ptr_is_owned(o);
18835         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18836         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
18837         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
18838         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
18839         return tag_ptr(ret_conv, true);
18840 }
18841
18842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18843         LDKDecodeError e_conv;
18844         e_conv.inner = untag_ptr(e);
18845         e_conv.is_owned = ptr_is_owned(e);
18846         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18847         e_conv = DecodeError_clone(&e_conv);
18848         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
18849         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
18850         return tag_ptr(ret_conv, true);
18851 }
18852
18853 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18854         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(o);
18855         jboolean ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
18856         return ret_conv;
18857 }
18858
18859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18860         if (!ptr_is_owned(_res)) return;
18861         void* _res_ptr = untag_ptr(_res);
18862         CHECK_ACCESS(_res_ptr);
18863         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
18864         FREE(untag_ptr(_res));
18865         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
18866 }
18867
18868 static inline uint64_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
18869         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
18870         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
18871         return tag_ptr(ret_conv, true);
18872 }
18873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18874         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(arg);
18875         int64_t ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
18876         return ret_conv;
18877 }
18878
18879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18880         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(orig);
18881         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
18882         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
18883         return tag_ptr(ret_conv, true);
18884 }
18885
18886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18887         LDKChannelCounterparty o_conv;
18888         o_conv.inner = untag_ptr(o);
18889         o_conv.is_owned = ptr_is_owned(o);
18890         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18891         o_conv = ChannelCounterparty_clone(&o_conv);
18892         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
18893         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
18894         return tag_ptr(ret_conv, true);
18895 }
18896
18897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18898         LDKDecodeError e_conv;
18899         e_conv.inner = untag_ptr(e);
18900         e_conv.is_owned = ptr_is_owned(e);
18901         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18902         e_conv = DecodeError_clone(&e_conv);
18903         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
18904         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
18905         return tag_ptr(ret_conv, true);
18906 }
18907
18908 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18909         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(o);
18910         jboolean ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
18911         return ret_conv;
18912 }
18913
18914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18915         if (!ptr_is_owned(_res)) return;
18916         void* _res_ptr = untag_ptr(_res);
18917         CHECK_ACCESS(_res_ptr);
18918         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
18919         FREE(untag_ptr(_res));
18920         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
18921 }
18922
18923 static inline uint64_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
18924         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
18925         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
18926         return tag_ptr(ret_conv, true);
18927 }
18928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18929         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(arg);
18930         int64_t ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
18931         return ret_conv;
18932 }
18933
18934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18935         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(orig);
18936         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
18937         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
18938         return tag_ptr(ret_conv, true);
18939 }
18940
18941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18942         LDKChannelDetails o_conv;
18943         o_conv.inner = untag_ptr(o);
18944         o_conv.is_owned = ptr_is_owned(o);
18945         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18946         o_conv = ChannelDetails_clone(&o_conv);
18947         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
18948         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
18949         return tag_ptr(ret_conv, true);
18950 }
18951
18952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18953         LDKDecodeError e_conv;
18954         e_conv.inner = untag_ptr(e);
18955         e_conv.is_owned = ptr_is_owned(e);
18956         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18957         e_conv = DecodeError_clone(&e_conv);
18958         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
18959         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
18960         return tag_ptr(ret_conv, true);
18961 }
18962
18963 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18964         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(o);
18965         jboolean ret_conv = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
18966         return ret_conv;
18967 }
18968
18969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18970         if (!ptr_is_owned(_res)) return;
18971         void* _res_ptr = untag_ptr(_res);
18972         CHECK_ACCESS(_res_ptr);
18973         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
18974         FREE(untag_ptr(_res));
18975         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
18976 }
18977
18978 static inline uint64_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
18979         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
18980         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
18981         return tag_ptr(ret_conv, true);
18982 }
18983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18984         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(arg);
18985         int64_t ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
18986         return ret_conv;
18987 }
18988
18989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18990         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(orig);
18991         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
18992         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
18993         return tag_ptr(ret_conv, true);
18994 }
18995
18996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18997         LDKPhantomRouteHints o_conv;
18998         o_conv.inner = untag_ptr(o);
18999         o_conv.is_owned = ptr_is_owned(o);
19000         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19001         o_conv = PhantomRouteHints_clone(&o_conv);
19002         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
19003         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
19004         return tag_ptr(ret_conv, true);
19005 }
19006
19007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19008         LDKDecodeError e_conv;
19009         e_conv.inner = untag_ptr(e);
19010         e_conv.is_owned = ptr_is_owned(e);
19011         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19012         e_conv = DecodeError_clone(&e_conv);
19013         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
19014         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
19015         return tag_ptr(ret_conv, true);
19016 }
19017
19018 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19019         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(o);
19020         jboolean ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
19021         return ret_conv;
19022 }
19023
19024 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19025         if (!ptr_is_owned(_res)) return;
19026         void* _res_ptr = untag_ptr(_res);
19027         CHECK_ACCESS(_res_ptr);
19028         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
19029         FREE(untag_ptr(_res));
19030         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
19031 }
19032
19033 static inline uint64_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
19034         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
19035         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
19036         return tag_ptr(ret_conv, true);
19037 }
19038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19039         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(arg);
19040         int64_t ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
19041         return ret_conv;
19042 }
19043
19044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19045         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(orig);
19046         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
19047         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
19048         return tag_ptr(ret_conv, true);
19049 }
19050
19051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19052         LDKCVec_ChannelMonitorZ _res_constr;
19053         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19054         if (_res_constr.datalen > 0)
19055                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
19056         else
19057                 _res_constr.data = NULL;
19058         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19059         for (size_t q = 0; q < _res_constr.datalen; q++) {
19060                 int64_t _res_conv_16 = _res_vals[q];
19061                 LDKChannelMonitor _res_conv_16_conv;
19062                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
19063                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
19064                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
19065                 _res_constr.data[q] = _res_conv_16_conv;
19066         }
19067         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19068         CVec_ChannelMonitorZ_free(_res_constr);
19069 }
19070
19071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
19072         LDKThirtyTwoBytes a_ref;
19073         CHECK((*env)->GetArrayLength(env, a) == 32);
19074         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19075         LDKChannelManager b_conv;
19076         b_conv.inner = untag_ptr(b);
19077         b_conv.is_owned = ptr_is_owned(b);
19078         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
19079         // WARNING: we need a move here but no clone is available for LDKChannelManager
19080         
19081         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
19082         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
19083         return tag_ptr(ret_conv, true);
19084 }
19085
19086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19087         if (!ptr_is_owned(_res)) return;
19088         void* _res_ptr = untag_ptr(_res);
19089         CHECK_ACCESS(_res_ptr);
19090         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
19091         FREE(untag_ptr(_res));
19092         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
19093 }
19094
19095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19096         void* o_ptr = untag_ptr(o);
19097         CHECK_ACCESS(o_ptr);
19098         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
19099         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
19100         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
19101         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
19102         return tag_ptr(ret_conv, true);
19103 }
19104
19105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19106         LDKDecodeError e_conv;
19107         e_conv.inner = untag_ptr(e);
19108         e_conv.is_owned = ptr_is_owned(e);
19109         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19110         e_conv = DecodeError_clone(&e_conv);
19111         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
19112         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
19113         return tag_ptr(ret_conv, true);
19114 }
19115
19116 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19117         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(o);
19118         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
19119         return ret_conv;
19120 }
19121
19122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19123         if (!ptr_is_owned(_res)) return;
19124         void* _res_ptr = untag_ptr(_res);
19125         CHECK_ACCESS(_res_ptr);
19126         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
19127         FREE(untag_ptr(_res));
19128         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
19129 }
19130
19131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19132         LDKChannelConfig o_conv;
19133         o_conv.inner = untag_ptr(o);
19134         o_conv.is_owned = ptr_is_owned(o);
19135         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19136         o_conv = ChannelConfig_clone(&o_conv);
19137         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
19138         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
19139         return tag_ptr(ret_conv, true);
19140 }
19141
19142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19143         LDKDecodeError e_conv;
19144         e_conv.inner = untag_ptr(e);
19145         e_conv.is_owned = ptr_is_owned(e);
19146         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19147         e_conv = DecodeError_clone(&e_conv);
19148         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
19149         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
19150         return tag_ptr(ret_conv, true);
19151 }
19152
19153 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19154         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(o);
19155         jboolean ret_conv = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
19156         return ret_conv;
19157 }
19158
19159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19160         if (!ptr_is_owned(_res)) return;
19161         void* _res_ptr = untag_ptr(_res);
19162         CHECK_ACCESS(_res_ptr);
19163         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
19164         FREE(untag_ptr(_res));
19165         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
19166 }
19167
19168 static inline uint64_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
19169         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
19170         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
19171         return tag_ptr(ret_conv, true);
19172 }
19173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19174         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(arg);
19175         int64_t ret_conv = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
19176         return ret_conv;
19177 }
19178
19179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19180         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(orig);
19181         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
19182         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
19183         return tag_ptr(ret_conv, true);
19184 }
19185
19186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19187         LDKOutPoint o_conv;
19188         o_conv.inner = untag_ptr(o);
19189         o_conv.is_owned = ptr_is_owned(o);
19190         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19191         o_conv = OutPoint_clone(&o_conv);
19192         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
19193         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
19194         return tag_ptr(ret_conv, true);
19195 }
19196
19197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19198         LDKDecodeError e_conv;
19199         e_conv.inner = untag_ptr(e);
19200         e_conv.is_owned = ptr_is_owned(e);
19201         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19202         e_conv = DecodeError_clone(&e_conv);
19203         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
19204         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
19205         return tag_ptr(ret_conv, true);
19206 }
19207
19208 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19209         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(o);
19210         jboolean ret_conv = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
19211         return ret_conv;
19212 }
19213
19214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19215         if (!ptr_is_owned(_res)) return;
19216         void* _res_ptr = untag_ptr(_res);
19217         CHECK_ACCESS(_res_ptr);
19218         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
19219         FREE(untag_ptr(_res));
19220         CResult_OutPointDecodeErrorZ_free(_res_conv);
19221 }
19222
19223 static inline uint64_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
19224         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
19225         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
19226         return tag_ptr(ret_conv, true);
19227 }
19228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19229         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(arg);
19230         int64_t ret_conv = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
19231         return ret_conv;
19232 }
19233
19234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19235         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(orig);
19236         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
19237         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
19238         return tag_ptr(ret_conv, true);
19239 }
19240
19241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19242         void* o_ptr = untag_ptr(o);
19243         CHECK_ACCESS(o_ptr);
19244         LDKType o_conv = *(LDKType*)(o_ptr);
19245         if (o_conv.free == LDKType_JCalls_free) {
19246                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19247                 LDKType_JCalls_cloned(&o_conv);
19248         }
19249         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
19250         *ret_copy = COption_TypeZ_some(o_conv);
19251         int64_t ret_ref = tag_ptr(ret_copy, true);
19252         return ret_ref;
19253 }
19254
19255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) {
19256         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
19257         *ret_copy = COption_TypeZ_none();
19258         int64_t ret_ref = tag_ptr(ret_copy, true);
19259         return ret_ref;
19260 }
19261
19262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19263         if (!ptr_is_owned(_res)) return;
19264         void* _res_ptr = untag_ptr(_res);
19265         CHECK_ACCESS(_res_ptr);
19266         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
19267         FREE(untag_ptr(_res));
19268         COption_TypeZ_free(_res_conv);
19269 }
19270
19271 static inline uint64_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
19272         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
19273         *ret_copy = COption_TypeZ_clone(arg);
19274         int64_t ret_ref = tag_ptr(ret_copy, true);
19275         return ret_ref;
19276 }
19277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19278         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)untag_ptr(arg);
19279         int64_t ret_conv = COption_TypeZ_clone_ptr(arg_conv);
19280         return ret_conv;
19281 }
19282
19283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19284         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)untag_ptr(orig);
19285         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
19286         *ret_copy = COption_TypeZ_clone(orig_conv);
19287         int64_t ret_ref = tag_ptr(ret_copy, true);
19288         return ret_ref;
19289 }
19290
19291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19292         void* o_ptr = untag_ptr(o);
19293         CHECK_ACCESS(o_ptr);
19294         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
19295         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)untag_ptr(o));
19296         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
19297         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
19298         return tag_ptr(ret_conv, true);
19299 }
19300
19301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19302         LDKDecodeError e_conv;
19303         e_conv.inner = untag_ptr(e);
19304         e_conv.is_owned = ptr_is_owned(e);
19305         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19306         e_conv = DecodeError_clone(&e_conv);
19307         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
19308         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
19309         return tag_ptr(ret_conv, true);
19310 }
19311
19312 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19313         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(o);
19314         jboolean ret_conv = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
19315         return ret_conv;
19316 }
19317
19318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19319         if (!ptr_is_owned(_res)) return;
19320         void* _res_ptr = untag_ptr(_res);
19321         CHECK_ACCESS(_res_ptr);
19322         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
19323         FREE(untag_ptr(_res));
19324         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
19325 }
19326
19327 static inline uint64_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
19328         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
19329         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
19330         return tag_ptr(ret_conv, true);
19331 }
19332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19333         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(arg);
19334         int64_t ret_conv = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
19335         return ret_conv;
19336 }
19337
19338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19339         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(orig);
19340         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
19341         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
19342         return tag_ptr(ret_conv, true);
19343 }
19344
19345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19346         LDKThirtyTwoBytes o_ref;
19347         CHECK((*env)->GetArrayLength(env, o) == 32);
19348         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
19349         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
19350         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
19351         return tag_ptr(ret_conv, true);
19352 }
19353
19354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19355         void* e_ptr = untag_ptr(e);
19356         CHECK_ACCESS(e_ptr);
19357         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
19358         e_conv = PaymentError_clone((LDKPaymentError*)untag_ptr(e));
19359         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
19360         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
19361         return tag_ptr(ret_conv, true);
19362 }
19363
19364 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19365         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(o);
19366         jboolean ret_conv = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
19367         return ret_conv;
19368 }
19369
19370 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19371         if (!ptr_is_owned(_res)) return;
19372         void* _res_ptr = untag_ptr(_res);
19373         CHECK_ACCESS(_res_ptr);
19374         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
19375         FREE(untag_ptr(_res));
19376         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
19377 }
19378
19379 static inline uint64_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
19380         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
19381         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
19382         return tag_ptr(ret_conv, true);
19383 }
19384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19385         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(arg);
19386         int64_t ret_conv = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
19387         return ret_conv;
19388 }
19389
19390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19391         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(orig);
19392         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
19393         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
19394         return tag_ptr(ret_conv, true);
19395 }
19396
19397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1ok(JNIEnv *env, jclass clz, jclass o) {
19398         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
19399         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
19400         *ret_conv = CResult_SiPrefixParseErrorZ_ok(o_conv);
19401         return tag_ptr(ret_conv, true);
19402 }
19403
19404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19405         void* e_ptr = untag_ptr(e);
19406         CHECK_ACCESS(e_ptr);
19407         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
19408         e_conv = ParseError_clone((LDKParseError*)untag_ptr(e));
19409         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
19410         *ret_conv = CResult_SiPrefixParseErrorZ_err(e_conv);
19411         return tag_ptr(ret_conv, true);
19412 }
19413
19414 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19415         LDKCResult_SiPrefixParseErrorZ* o_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(o);
19416         jboolean ret_conv = CResult_SiPrefixParseErrorZ_is_ok(o_conv);
19417         return ret_conv;
19418 }
19419
19420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19421         if (!ptr_is_owned(_res)) return;
19422         void* _res_ptr = untag_ptr(_res);
19423         CHECK_ACCESS(_res_ptr);
19424         LDKCResult_SiPrefixParseErrorZ _res_conv = *(LDKCResult_SiPrefixParseErrorZ*)(_res_ptr);
19425         FREE(untag_ptr(_res));
19426         CResult_SiPrefixParseErrorZ_free(_res_conv);
19427 }
19428
19429 static inline uint64_t CResult_SiPrefixParseErrorZ_clone_ptr(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR arg) {
19430         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
19431         *ret_conv = CResult_SiPrefixParseErrorZ_clone(arg);
19432         return tag_ptr(ret_conv, true);
19433 }
19434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19435         LDKCResult_SiPrefixParseErrorZ* arg_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(arg);
19436         int64_t ret_conv = CResult_SiPrefixParseErrorZ_clone_ptr(arg_conv);
19437         return ret_conv;
19438 }
19439
19440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19441         LDKCResult_SiPrefixParseErrorZ* orig_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(orig);
19442         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
19443         *ret_conv = CResult_SiPrefixParseErrorZ_clone(orig_conv);
19444         return tag_ptr(ret_conv, true);
19445 }
19446
19447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19448         LDKInvoice o_conv;
19449         o_conv.inner = untag_ptr(o);
19450         o_conv.is_owned = ptr_is_owned(o);
19451         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19452         o_conv = Invoice_clone(&o_conv);
19453         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
19454         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_ok(o_conv);
19455         return tag_ptr(ret_conv, true);
19456 }
19457
19458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19459         void* e_ptr = untag_ptr(e);
19460         CHECK_ACCESS(e_ptr);
19461         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
19462         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)untag_ptr(e));
19463         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
19464         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_err(e_conv);
19465         return tag_ptr(ret_conv, true);
19466 }
19467
19468 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19469         LDKCResult_InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(o);
19470         jboolean ret_conv = CResult_InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
19471         return ret_conv;
19472 }
19473
19474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19475         if (!ptr_is_owned(_res)) return;
19476         void* _res_ptr = untag_ptr(_res);
19477         CHECK_ACCESS(_res_ptr);
19478         LDKCResult_InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_InvoiceParseOrSemanticErrorZ*)(_res_ptr);
19479         FREE(untag_ptr(_res));
19480         CResult_InvoiceParseOrSemanticErrorZ_free(_res_conv);
19481 }
19482
19483 static inline uint64_t CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
19484         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
19485         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(arg);
19486         return tag_ptr(ret_conv, true);
19487 }
19488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19489         LDKCResult_InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(arg);
19490         int64_t ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
19491         return ret_conv;
19492 }
19493
19494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19495         LDKCResult_InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(orig);
19496         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
19497         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(orig_conv);
19498         return tag_ptr(ret_conv, true);
19499 }
19500
19501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19502         LDKSignedRawInvoice o_conv;
19503         o_conv.inner = untag_ptr(o);
19504         o_conv.is_owned = ptr_is_owned(o);
19505         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19506         o_conv = SignedRawInvoice_clone(&o_conv);
19507         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
19508         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_ok(o_conv);
19509         return tag_ptr(ret_conv, true);
19510 }
19511
19512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19513         void* e_ptr = untag_ptr(e);
19514         CHECK_ACCESS(e_ptr);
19515         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
19516         e_conv = ParseError_clone((LDKParseError*)untag_ptr(e));
19517         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
19518         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_err(e_conv);
19519         return tag_ptr(ret_conv, true);
19520 }
19521
19522 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19523         LDKCResult_SignedRawInvoiceParseErrorZ* o_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(o);
19524         jboolean ret_conv = CResult_SignedRawInvoiceParseErrorZ_is_ok(o_conv);
19525         return ret_conv;
19526 }
19527
19528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19529         if (!ptr_is_owned(_res)) return;
19530         void* _res_ptr = untag_ptr(_res);
19531         CHECK_ACCESS(_res_ptr);
19532         LDKCResult_SignedRawInvoiceParseErrorZ _res_conv = *(LDKCResult_SignedRawInvoiceParseErrorZ*)(_res_ptr);
19533         FREE(untag_ptr(_res));
19534         CResult_SignedRawInvoiceParseErrorZ_free(_res_conv);
19535 }
19536
19537 static inline uint64_t CResult_SignedRawInvoiceParseErrorZ_clone_ptr(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR arg) {
19538         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
19539         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(arg);
19540         return tag_ptr(ret_conv, true);
19541 }
19542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19543         LDKCResult_SignedRawInvoiceParseErrorZ* arg_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(arg);
19544         int64_t ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone_ptr(arg_conv);
19545         return ret_conv;
19546 }
19547
19548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19549         LDKCResult_SignedRawInvoiceParseErrorZ* orig_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(orig);
19550         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
19551         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(orig_conv);
19552         return tag_ptr(ret_conv, true);
19553 }
19554
19555 static inline uint64_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
19556         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
19557         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
19558         return tag_ptr(ret_conv, true);
19559 }
19560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19561         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(arg);
19562         int64_t ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
19563         return ret_conv;
19564 }
19565
19566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19567         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(orig);
19568         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
19569         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
19570         return tag_ptr(ret_conv, true);
19571 }
19572
19573 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) {
19574         LDKRawInvoice a_conv;
19575         a_conv.inner = untag_ptr(a);
19576         a_conv.is_owned = ptr_is_owned(a);
19577         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
19578         a_conv = RawInvoice_clone(&a_conv);
19579         LDKThirtyTwoBytes b_ref;
19580         CHECK((*env)->GetArrayLength(env, b) == 32);
19581         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
19582         LDKInvoiceSignature c_conv;
19583         c_conv.inner = untag_ptr(c);
19584         c_conv.is_owned = ptr_is_owned(c);
19585         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
19586         c_conv = InvoiceSignature_clone(&c_conv);
19587         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
19588         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
19589         return tag_ptr(ret_conv, true);
19590 }
19591
19592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19593         if (!ptr_is_owned(_res)) return;
19594         void* _res_ptr = untag_ptr(_res);
19595         CHECK_ACCESS(_res_ptr);
19596         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
19597         FREE(untag_ptr(_res));
19598         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
19599 }
19600
19601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19602         LDKPayeePubKey o_conv;
19603         o_conv.inner = untag_ptr(o);
19604         o_conv.is_owned = ptr_is_owned(o);
19605         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19606         o_conv = PayeePubKey_clone(&o_conv);
19607         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
19608         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
19609         return tag_ptr(ret_conv, true);
19610 }
19611
19612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19613         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
19614         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
19615         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
19616         return tag_ptr(ret_conv, true);
19617 }
19618
19619 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19620         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(o);
19621         jboolean ret_conv = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
19622         return ret_conv;
19623 }
19624
19625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19626         if (!ptr_is_owned(_res)) return;
19627         void* _res_ptr = untag_ptr(_res);
19628         CHECK_ACCESS(_res_ptr);
19629         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
19630         FREE(untag_ptr(_res));
19631         CResult_PayeePubKeyErrorZ_free(_res_conv);
19632 }
19633
19634 static inline uint64_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
19635         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
19636         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
19637         return tag_ptr(ret_conv, true);
19638 }
19639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19640         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(arg);
19641         int64_t ret_conv = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
19642         return ret_conv;
19643 }
19644
19645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19646         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(orig);
19647         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
19648         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
19649         return tag_ptr(ret_conv, true);
19650 }
19651
19652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19653         LDKCVec_PrivateRouteZ _res_constr;
19654         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19655         if (_res_constr.datalen > 0)
19656                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
19657         else
19658                 _res_constr.data = NULL;
19659         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19660         for (size_t o = 0; o < _res_constr.datalen; o++) {
19661                 int64_t _res_conv_14 = _res_vals[o];
19662                 LDKPrivateRoute _res_conv_14_conv;
19663                 _res_conv_14_conv.inner = untag_ptr(_res_conv_14);
19664                 _res_conv_14_conv.is_owned = ptr_is_owned(_res_conv_14);
19665                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
19666                 _res_constr.data[o] = _res_conv_14_conv;
19667         }
19668         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19669         CVec_PrivateRouteZ_free(_res_constr);
19670 }
19671
19672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19673         LDKPositiveTimestamp o_conv;
19674         o_conv.inner = untag_ptr(o);
19675         o_conv.is_owned = ptr_is_owned(o);
19676         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19677         o_conv = PositiveTimestamp_clone(&o_conv);
19678         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
19679         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
19680         return tag_ptr(ret_conv, true);
19681 }
19682
19683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19684         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
19685         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
19686         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
19687         return tag_ptr(ret_conv, true);
19688 }
19689
19690 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19691         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(o);
19692         jboolean ret_conv = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
19693         return ret_conv;
19694 }
19695
19696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19697         if (!ptr_is_owned(_res)) return;
19698         void* _res_ptr = untag_ptr(_res);
19699         CHECK_ACCESS(_res_ptr);
19700         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
19701         FREE(untag_ptr(_res));
19702         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
19703 }
19704
19705 static inline uint64_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
19706         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
19707         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
19708         return tag_ptr(ret_conv, true);
19709 }
19710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19711         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(arg);
19712         int64_t ret_conv = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
19713         return ret_conv;
19714 }
19715
19716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19717         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(orig);
19718         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
19719         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
19720         return tag_ptr(ret_conv, true);
19721 }
19722
19723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
19724         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
19725         *ret_conv = CResult_NoneSemanticErrorZ_ok();
19726         return tag_ptr(ret_conv, true);
19727 }
19728
19729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19730         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
19731         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
19732         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
19733         return tag_ptr(ret_conv, true);
19734 }
19735
19736 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19737         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(o);
19738         jboolean ret_conv = CResult_NoneSemanticErrorZ_is_ok(o_conv);
19739         return ret_conv;
19740 }
19741
19742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19743         if (!ptr_is_owned(_res)) return;
19744         void* _res_ptr = untag_ptr(_res);
19745         CHECK_ACCESS(_res_ptr);
19746         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
19747         FREE(untag_ptr(_res));
19748         CResult_NoneSemanticErrorZ_free(_res_conv);
19749 }
19750
19751 static inline uint64_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
19752         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
19753         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
19754         return tag_ptr(ret_conv, true);
19755 }
19756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19757         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(arg);
19758         int64_t ret_conv = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
19759         return ret_conv;
19760 }
19761
19762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19763         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(orig);
19764         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
19765         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
19766         return tag_ptr(ret_conv, true);
19767 }
19768
19769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19770         LDKInvoice o_conv;
19771         o_conv.inner = untag_ptr(o);
19772         o_conv.is_owned = ptr_is_owned(o);
19773         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19774         o_conv = Invoice_clone(&o_conv);
19775         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
19776         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
19777         return tag_ptr(ret_conv, true);
19778 }
19779
19780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19781         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
19782         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
19783         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
19784         return tag_ptr(ret_conv, true);
19785 }
19786
19787 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19788         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(o);
19789         jboolean ret_conv = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
19790         return ret_conv;
19791 }
19792
19793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19794         if (!ptr_is_owned(_res)) return;
19795         void* _res_ptr = untag_ptr(_res);
19796         CHECK_ACCESS(_res_ptr);
19797         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
19798         FREE(untag_ptr(_res));
19799         CResult_InvoiceSemanticErrorZ_free(_res_conv);
19800 }
19801
19802 static inline uint64_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
19803         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
19804         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
19805         return tag_ptr(ret_conv, true);
19806 }
19807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19808         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(arg);
19809         int64_t ret_conv = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
19810         return ret_conv;
19811 }
19812
19813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19814         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(orig);
19815         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
19816         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
19817         return tag_ptr(ret_conv, true);
19818 }
19819
19820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19821         LDKDescription o_conv;
19822         o_conv.inner = untag_ptr(o);
19823         o_conv.is_owned = ptr_is_owned(o);
19824         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19825         o_conv = Description_clone(&o_conv);
19826         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
19827         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
19828         return tag_ptr(ret_conv, true);
19829 }
19830
19831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19832         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
19833         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
19834         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
19835         return tag_ptr(ret_conv, true);
19836 }
19837
19838 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19839         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(o);
19840         jboolean ret_conv = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
19841         return ret_conv;
19842 }
19843
19844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19845         if (!ptr_is_owned(_res)) return;
19846         void* _res_ptr = untag_ptr(_res);
19847         CHECK_ACCESS(_res_ptr);
19848         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
19849         FREE(untag_ptr(_res));
19850         CResult_DescriptionCreationErrorZ_free(_res_conv);
19851 }
19852
19853 static inline uint64_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
19854         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
19855         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
19856         return tag_ptr(ret_conv, true);
19857 }
19858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19859         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(arg);
19860         int64_t ret_conv = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
19861         return ret_conv;
19862 }
19863
19864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19865         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(orig);
19866         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
19867         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
19868         return tag_ptr(ret_conv, true);
19869 }
19870
19871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19872         LDKPrivateRoute o_conv;
19873         o_conv.inner = untag_ptr(o);
19874         o_conv.is_owned = ptr_is_owned(o);
19875         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19876         o_conv = PrivateRoute_clone(&o_conv);
19877         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
19878         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
19879         return tag_ptr(ret_conv, true);
19880 }
19881
19882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19883         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
19884         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
19885         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
19886         return tag_ptr(ret_conv, true);
19887 }
19888
19889 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19890         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(o);
19891         jboolean ret_conv = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
19892         return ret_conv;
19893 }
19894
19895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19896         if (!ptr_is_owned(_res)) return;
19897         void* _res_ptr = untag_ptr(_res);
19898         CHECK_ACCESS(_res_ptr);
19899         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
19900         FREE(untag_ptr(_res));
19901         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
19902 }
19903
19904 static inline uint64_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
19905         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
19906         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
19907         return tag_ptr(ret_conv, true);
19908 }
19909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19910         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(arg);
19911         int64_t ret_conv = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
19912         return ret_conv;
19913 }
19914
19915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19916         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(orig);
19917         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
19918         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
19919         return tag_ptr(ret_conv, true);
19920 }
19921
19922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
19923         LDKStr o_conv = java_to_owned_str(env, o);
19924         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
19925         *ret_conv = CResult_StringErrorZ_ok(o_conv);
19926         return tag_ptr(ret_conv, true);
19927 }
19928
19929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19930         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
19931         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
19932         *ret_conv = CResult_StringErrorZ_err(e_conv);
19933         return tag_ptr(ret_conv, true);
19934 }
19935
19936 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19937         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)untag_ptr(o);
19938         jboolean ret_conv = CResult_StringErrorZ_is_ok(o_conv);
19939         return ret_conv;
19940 }
19941
19942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19943         if (!ptr_is_owned(_res)) return;
19944         void* _res_ptr = untag_ptr(_res);
19945         CHECK_ACCESS(_res_ptr);
19946         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
19947         FREE(untag_ptr(_res));
19948         CResult_StringErrorZ_free(_res_conv);
19949 }
19950
19951 static inline uint64_t CResult_StringErrorZ_clone_ptr(LDKCResult_StringErrorZ *NONNULL_PTR arg) {
19952         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
19953         *ret_conv = CResult_StringErrorZ_clone(arg);
19954         return tag_ptr(ret_conv, true);
19955 }
19956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19957         LDKCResult_StringErrorZ* arg_conv = (LDKCResult_StringErrorZ*)untag_ptr(arg);
19958         int64_t ret_conv = CResult_StringErrorZ_clone_ptr(arg_conv);
19959         return ret_conv;
19960 }
19961
19962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19963         LDKCResult_StringErrorZ* orig_conv = (LDKCResult_StringErrorZ*)untag_ptr(orig);
19964         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
19965         *ret_conv = CResult_StringErrorZ_clone(orig_conv);
19966         return tag_ptr(ret_conv, true);
19967 }
19968
19969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19970         LDKChannelMonitorUpdate o_conv;
19971         o_conv.inner = untag_ptr(o);
19972         o_conv.is_owned = ptr_is_owned(o);
19973         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19974         o_conv = ChannelMonitorUpdate_clone(&o_conv);
19975         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
19976         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
19977         return tag_ptr(ret_conv, true);
19978 }
19979
19980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19981         LDKDecodeError e_conv;
19982         e_conv.inner = untag_ptr(e);
19983         e_conv.is_owned = ptr_is_owned(e);
19984         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19985         e_conv = DecodeError_clone(&e_conv);
19986         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
19987         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
19988         return tag_ptr(ret_conv, true);
19989 }
19990
19991 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19992         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(o);
19993         jboolean ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
19994         return ret_conv;
19995 }
19996
19997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_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_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
20002         FREE(untag_ptr(_res));
20003         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
20004 }
20005
20006 static inline uint64_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
20007         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
20008         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
20009         return tag_ptr(ret_conv, true);
20010 }
20011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20012         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(arg);
20013         int64_t ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
20014         return ret_conv;
20015 }
20016
20017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20018         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(orig);
20019         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
20020         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
20021         return tag_ptr(ret_conv, true);
20022 }
20023
20024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
20025         void* o_ptr = untag_ptr(o);
20026         CHECK_ACCESS(o_ptr);
20027         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
20028         o_conv = MonitorEvent_clone((LDKMonitorEvent*)untag_ptr(o));
20029         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
20030         *ret_copy = COption_MonitorEventZ_some(o_conv);
20031         int64_t ret_ref = tag_ptr(ret_copy, true);
20032         return ret_ref;
20033 }
20034
20035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1none(JNIEnv *env, jclass clz) {
20036         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
20037         *ret_copy = COption_MonitorEventZ_none();
20038         int64_t ret_ref = tag_ptr(ret_copy, true);
20039         return ret_ref;
20040 }
20041
20042 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20043         if (!ptr_is_owned(_res)) return;
20044         void* _res_ptr = untag_ptr(_res);
20045         CHECK_ACCESS(_res_ptr);
20046         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
20047         FREE(untag_ptr(_res));
20048         COption_MonitorEventZ_free(_res_conv);
20049 }
20050
20051 static inline uint64_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
20052         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
20053         *ret_copy = COption_MonitorEventZ_clone(arg);
20054         int64_t ret_ref = tag_ptr(ret_copy, true);
20055         return ret_ref;
20056 }
20057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20058         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)untag_ptr(arg);
20059         int64_t ret_conv = COption_MonitorEventZ_clone_ptr(arg_conv);
20060         return ret_conv;
20061 }
20062
20063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20064         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)untag_ptr(orig);
20065         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
20066         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
20067         int64_t ret_ref = tag_ptr(ret_copy, true);
20068         return ret_ref;
20069 }
20070
20071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20072         void* o_ptr = untag_ptr(o);
20073         CHECK_ACCESS(o_ptr);
20074         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
20075         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)untag_ptr(o));
20076         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
20077         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
20078         return tag_ptr(ret_conv, true);
20079 }
20080
20081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20082         LDKDecodeError e_conv;
20083         e_conv.inner = untag_ptr(e);
20084         e_conv.is_owned = ptr_is_owned(e);
20085         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20086         e_conv = DecodeError_clone(&e_conv);
20087         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
20088         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
20089         return tag_ptr(ret_conv, true);
20090 }
20091
20092 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20093         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(o);
20094         jboolean ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
20095         return ret_conv;
20096 }
20097
20098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_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_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
20103         FREE(untag_ptr(_res));
20104         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
20105 }
20106
20107 static inline uint64_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
20108         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
20109         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
20110         return tag_ptr(ret_conv, true);
20111 }
20112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20113         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(arg);
20114         int64_t ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
20115         return ret_conv;
20116 }
20117
20118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20119         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(orig);
20120         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
20121         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
20122         return tag_ptr(ret_conv, true);
20123 }
20124
20125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20126         LDKHTLCUpdate o_conv;
20127         o_conv.inner = untag_ptr(o);
20128         o_conv.is_owned = ptr_is_owned(o);
20129         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20130         o_conv = HTLCUpdate_clone(&o_conv);
20131         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
20132         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
20133         return tag_ptr(ret_conv, true);
20134 }
20135
20136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20137         LDKDecodeError e_conv;
20138         e_conv.inner = untag_ptr(e);
20139         e_conv.is_owned = ptr_is_owned(e);
20140         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20141         e_conv = DecodeError_clone(&e_conv);
20142         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
20143         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
20144         return tag_ptr(ret_conv, true);
20145 }
20146
20147 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20148         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(o);
20149         jboolean ret_conv = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
20150         return ret_conv;
20151 }
20152
20153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20154         if (!ptr_is_owned(_res)) return;
20155         void* _res_ptr = untag_ptr(_res);
20156         CHECK_ACCESS(_res_ptr);
20157         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
20158         FREE(untag_ptr(_res));
20159         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
20160 }
20161
20162 static inline uint64_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
20163         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
20164         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
20165         return tag_ptr(ret_conv, true);
20166 }
20167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20168         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(arg);
20169         int64_t ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
20170         return ret_conv;
20171 }
20172
20173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20174         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(orig);
20175         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
20176         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
20177         return tag_ptr(ret_conv, true);
20178 }
20179
20180 static inline uint64_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
20181         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
20182         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
20183         return tag_ptr(ret_conv, true);
20184 }
20185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20186         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(arg);
20187         int64_t ret_conv = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
20188         return ret_conv;
20189 }
20190
20191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20192         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(orig);
20193         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
20194         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
20195         return tag_ptr(ret_conv, true);
20196 }
20197
20198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
20199         LDKOutPoint a_conv;
20200         a_conv.inner = untag_ptr(a);
20201         a_conv.is_owned = ptr_is_owned(a);
20202         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
20203         a_conv = OutPoint_clone(&a_conv);
20204         LDKCVec_u8Z b_ref;
20205         b_ref.datalen = (*env)->GetArrayLength(env, b);
20206         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
20207         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
20208         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
20209         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
20210         return tag_ptr(ret_conv, true);
20211 }
20212
20213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20214         if (!ptr_is_owned(_res)) return;
20215         void* _res_ptr = untag_ptr(_res);
20216         CHECK_ACCESS(_res_ptr);
20217         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
20218         FREE(untag_ptr(_res));
20219         C2Tuple_OutPointScriptZ_free(_res_conv);
20220 }
20221
20222 static inline uint64_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
20223         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
20224         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
20225         return tag_ptr(ret_conv, true);
20226 }
20227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20228         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(arg);
20229         int64_t ret_conv = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
20230         return ret_conv;
20231 }
20232
20233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20234         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(orig);
20235         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
20236         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
20237         return tag_ptr(ret_conv, true);
20238 }
20239
20240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
20241         LDKCVec_u8Z b_ref;
20242         b_ref.datalen = (*env)->GetArrayLength(env, b);
20243         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
20244         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
20245         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
20246         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
20247         return tag_ptr(ret_conv, true);
20248 }
20249
20250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20251         if (!ptr_is_owned(_res)) return;
20252         void* _res_ptr = untag_ptr(_res);
20253         CHECK_ACCESS(_res_ptr);
20254         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
20255         FREE(untag_ptr(_res));
20256         C2Tuple_u32ScriptZ_free(_res_conv);
20257 }
20258
20259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20260         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
20261         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20262         if (_res_constr.datalen > 0)
20263                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
20264         else
20265                 _res_constr.data = NULL;
20266         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20267         for (size_t v = 0; v < _res_constr.datalen; v++) {
20268                 int64_t _res_conv_21 = _res_vals[v];
20269                 void* _res_conv_21_ptr = untag_ptr(_res_conv_21);
20270                 CHECK_ACCESS(_res_conv_21_ptr);
20271                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
20272                 FREE(untag_ptr(_res_conv_21));
20273                 _res_constr.data[v] = _res_conv_21_conv;
20274         }
20275         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20276         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
20277 }
20278
20279 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
20280         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
20281         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
20282         return tag_ptr(ret_conv, true);
20283 }
20284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20285         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(arg);
20286         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
20287         return ret_conv;
20288 }
20289
20290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20291         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(orig);
20292         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
20293         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
20294         return tag_ptr(ret_conv, true);
20295 }
20296
20297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
20298         LDKThirtyTwoBytes a_ref;
20299         CHECK((*env)->GetArrayLength(env, a) == 32);
20300         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
20301         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
20302         b_constr.datalen = (*env)->GetArrayLength(env, b);
20303         if (b_constr.datalen > 0)
20304                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
20305         else
20306                 b_constr.data = NULL;
20307         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
20308         for (size_t v = 0; v < b_constr.datalen; v++) {
20309                 int64_t b_conv_21 = b_vals[v];
20310                 void* b_conv_21_ptr = untag_ptr(b_conv_21);
20311                 CHECK_ACCESS(b_conv_21_ptr);
20312                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
20313                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)untag_ptr(b_conv_21));
20314                 b_constr.data[v] = b_conv_21_conv;
20315         }
20316         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
20317         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
20318         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
20319         return tag_ptr(ret_conv, true);
20320 }
20321
20322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20323         if (!ptr_is_owned(_res)) return;
20324         void* _res_ptr = untag_ptr(_res);
20325         CHECK_ACCESS(_res_ptr);
20326         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
20327         FREE(untag_ptr(_res));
20328         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
20329 }
20330
20331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20332         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
20333         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20334         if (_res_constr.datalen > 0)
20335                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
20336         else
20337                 _res_constr.data = NULL;
20338         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20339         for (size_t o = 0; o < _res_constr.datalen; o++) {
20340                 int64_t _res_conv_40 = _res_vals[o];
20341                 void* _res_conv_40_ptr = untag_ptr(_res_conv_40);
20342                 CHECK_ACCESS(_res_conv_40_ptr);
20343                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
20344                 FREE(untag_ptr(_res_conv_40));
20345                 _res_constr.data[o] = _res_conv_40_conv;
20346         }
20347         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20348         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
20349 }
20350
20351 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20352         LDKCVec_EventZ _res_constr;
20353         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20354         if (_res_constr.datalen > 0)
20355                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
20356         else
20357                 _res_constr.data = NULL;
20358         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20359         for (size_t h = 0; h < _res_constr.datalen; h++) {
20360                 int64_t _res_conv_7 = _res_vals[h];
20361                 void* _res_conv_7_ptr = untag_ptr(_res_conv_7);
20362                 CHECK_ACCESS(_res_conv_7_ptr);
20363                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
20364                 FREE(untag_ptr(_res_conv_7));
20365                 _res_constr.data[h] = _res_conv_7_conv;
20366         }
20367         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20368         CVec_EventZ_free(_res_constr);
20369 }
20370
20371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
20372         LDKCVec_TransactionZ _res_constr;
20373         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20374         if (_res_constr.datalen > 0)
20375                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
20376         else
20377                 _res_constr.data = NULL;
20378         for (size_t i = 0; i < _res_constr.datalen; i++) {
20379                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
20380                 LDKTransaction _res_conv_8_ref;
20381                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
20382                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
20383                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
20384                 _res_conv_8_ref.data_is_owned = true;
20385                 _res_constr.data[i] = _res_conv_8_ref;
20386         }
20387         CVec_TransactionZ_free(_res_constr);
20388 }
20389
20390 static inline uint64_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
20391         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
20392         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
20393         return tag_ptr(ret_conv, true);
20394 }
20395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20396         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(arg);
20397         int64_t ret_conv = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
20398         return ret_conv;
20399 }
20400
20401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20402         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(orig);
20403         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
20404         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
20405         return tag_ptr(ret_conv, true);
20406 }
20407
20408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
20409         void* b_ptr = untag_ptr(b);
20410         CHECK_ACCESS(b_ptr);
20411         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
20412         b_conv = TxOut_clone((LDKTxOut*)untag_ptr(b));
20413         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
20414         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
20415         return tag_ptr(ret_conv, true);
20416 }
20417
20418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20419         if (!ptr_is_owned(_res)) return;
20420         void* _res_ptr = untag_ptr(_res);
20421         CHECK_ACCESS(_res_ptr);
20422         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
20423         FREE(untag_ptr(_res));
20424         C2Tuple_u32TxOutZ_free(_res_conv);
20425 }
20426
20427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20428         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
20429         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20430         if (_res_constr.datalen > 0)
20431                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
20432         else
20433                 _res_constr.data = NULL;
20434         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20435         for (size_t u = 0; u < _res_constr.datalen; u++) {
20436                 int64_t _res_conv_20 = _res_vals[u];
20437                 void* _res_conv_20_ptr = untag_ptr(_res_conv_20);
20438                 CHECK_ACCESS(_res_conv_20_ptr);
20439                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
20440                 FREE(untag_ptr(_res_conv_20));
20441                 _res_constr.data[u] = _res_conv_20_conv;
20442         }
20443         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20444         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
20445 }
20446
20447 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
20448         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
20449         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
20450         return tag_ptr(ret_conv, true);
20451 }
20452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20453         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(arg);
20454         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
20455         return ret_conv;
20456 }
20457
20458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20459         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(orig);
20460         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
20461         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
20462         return tag_ptr(ret_conv, true);
20463 }
20464
20465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
20466         LDKThirtyTwoBytes a_ref;
20467         CHECK((*env)->GetArrayLength(env, a) == 32);
20468         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
20469         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
20470         b_constr.datalen = (*env)->GetArrayLength(env, b);
20471         if (b_constr.datalen > 0)
20472                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
20473         else
20474                 b_constr.data = NULL;
20475         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
20476         for (size_t u = 0; u < b_constr.datalen; u++) {
20477                 int64_t b_conv_20 = b_vals[u];
20478                 void* b_conv_20_ptr = untag_ptr(b_conv_20);
20479                 CHECK_ACCESS(b_conv_20_ptr);
20480                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
20481                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)untag_ptr(b_conv_20));
20482                 b_constr.data[u] = b_conv_20_conv;
20483         }
20484         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
20485         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
20486         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
20487         return tag_ptr(ret_conv, true);
20488 }
20489
20490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20491         if (!ptr_is_owned(_res)) return;
20492         void* _res_ptr = untag_ptr(_res);
20493         CHECK_ACCESS(_res_ptr);
20494         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
20495         FREE(untag_ptr(_res));
20496         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
20497 }
20498
20499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20500         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
20501         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20502         if (_res_constr.datalen > 0)
20503                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
20504         else
20505                 _res_constr.data = NULL;
20506         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20507         for (size_t n = 0; n < _res_constr.datalen; n++) {
20508                 int64_t _res_conv_39 = _res_vals[n];
20509                 void* _res_conv_39_ptr = untag_ptr(_res_conv_39);
20510                 CHECK_ACCESS(_res_conv_39_ptr);
20511                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
20512                 FREE(untag_ptr(_res_conv_39));
20513                 _res_constr.data[n] = _res_conv_39_conv;
20514         }
20515         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20516         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
20517 }
20518
20519 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20520         LDKCVec_BalanceZ _res_constr;
20521         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20522         if (_res_constr.datalen > 0)
20523                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
20524         else
20525                 _res_constr.data = NULL;
20526         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20527         for (size_t j = 0; j < _res_constr.datalen; j++) {
20528                 int64_t _res_conv_9 = _res_vals[j];
20529                 void* _res_conv_9_ptr = untag_ptr(_res_conv_9);
20530                 CHECK_ACCESS(_res_conv_9_ptr);
20531                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
20532                 FREE(untag_ptr(_res_conv_9));
20533                 _res_constr.data[j] = _res_conv_9_conv;
20534         }
20535         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20536         CVec_BalanceZ_free(_res_constr);
20537 }
20538
20539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20540         void* o_ptr = untag_ptr(o);
20541         CHECK_ACCESS(o_ptr);
20542         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
20543         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(o));
20544         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
20545         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
20546         return tag_ptr(ret_conv, true);
20547 }
20548
20549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20550         LDKDecodeError e_conv;
20551         e_conv.inner = untag_ptr(e);
20552         e_conv.is_owned = ptr_is_owned(e);
20553         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20554         e_conv = DecodeError_clone(&e_conv);
20555         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
20556         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
20557         return tag_ptr(ret_conv, true);
20558 }
20559
20560 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20561         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(o);
20562         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
20563         return ret_conv;
20564 }
20565
20566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20567         if (!ptr_is_owned(_res)) return;
20568         void* _res_ptr = untag_ptr(_res);
20569         CHECK_ACCESS(_res_ptr);
20570         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
20571         FREE(untag_ptr(_res));
20572         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
20573 }
20574
20575 static inline uint64_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
20576         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
20577         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
20578         return tag_ptr(ret_conv, true);
20579 }
20580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20581         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(arg);
20582         int64_t ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
20583         return ret_conv;
20584 }
20585
20586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20587         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(orig);
20588         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
20589         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
20590         return tag_ptr(ret_conv, true);
20591 }
20592
20593 static inline uint64_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
20594         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
20595         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
20596         return tag_ptr(ret_conv, true);
20597 }
20598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20599         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(arg);
20600         int64_t ret_conv = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
20601         return ret_conv;
20602 }
20603
20604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20605         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(orig);
20606         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
20607         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
20608         return tag_ptr(ret_conv, true);
20609 }
20610
20611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
20612         LDKPublicKey a_ref;
20613         CHECK((*env)->GetArrayLength(env, a) == 33);
20614         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
20615         void* b_ptr = untag_ptr(b);
20616         CHECK_ACCESS(b_ptr);
20617         LDKType b_conv = *(LDKType*)(b_ptr);
20618         if (b_conv.free == LDKType_JCalls_free) {
20619                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20620                 LDKType_JCalls_cloned(&b_conv);
20621         }
20622         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
20623         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
20624         return tag_ptr(ret_conv, true);
20625 }
20626
20627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20628         if (!ptr_is_owned(_res)) return;
20629         void* _res_ptr = untag_ptr(_res);
20630         CHECK_ACCESS(_res_ptr);
20631         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
20632         FREE(untag_ptr(_res));
20633         C2Tuple_PublicKeyTypeZ_free(_res_conv);
20634 }
20635
20636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20637         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
20638         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20639         if (_res_constr.datalen > 0)
20640                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
20641         else
20642                 _res_constr.data = NULL;
20643         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20644         for (size_t z = 0; z < _res_constr.datalen; z++) {
20645                 int64_t _res_conv_25 = _res_vals[z];
20646                 void* _res_conv_25_ptr = untag_ptr(_res_conv_25);
20647                 CHECK_ACCESS(_res_conv_25_ptr);
20648                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
20649                 FREE(untag_ptr(_res_conv_25));
20650                 _res_constr.data[z] = _res_conv_25_conv;
20651         }
20652         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20653         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
20654 }
20655
20656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1some(JNIEnv *env, jclass clz, int64_t o) {
20657         void* o_ptr = untag_ptr(o);
20658         CHECK_ACCESS(o_ptr);
20659         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
20660         o_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o));
20661         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
20662         *ret_copy = COption_NetAddressZ_some(o_conv);
20663         int64_t ret_ref = tag_ptr(ret_copy, true);
20664         return ret_ref;
20665 }
20666
20667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1none(JNIEnv *env, jclass clz) {
20668         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
20669         *ret_copy = COption_NetAddressZ_none();
20670         int64_t ret_ref = tag_ptr(ret_copy, true);
20671         return ret_ref;
20672 }
20673
20674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20675         if (!ptr_is_owned(_res)) return;
20676         void* _res_ptr = untag_ptr(_res);
20677         CHECK_ACCESS(_res_ptr);
20678         LDKCOption_NetAddressZ _res_conv = *(LDKCOption_NetAddressZ*)(_res_ptr);
20679         FREE(untag_ptr(_res));
20680         COption_NetAddressZ_free(_res_conv);
20681 }
20682
20683 static inline uint64_t COption_NetAddressZ_clone_ptr(LDKCOption_NetAddressZ *NONNULL_PTR arg) {
20684         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
20685         *ret_copy = COption_NetAddressZ_clone(arg);
20686         int64_t ret_ref = tag_ptr(ret_copy, true);
20687         return ret_ref;
20688 }
20689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20690         LDKCOption_NetAddressZ* arg_conv = (LDKCOption_NetAddressZ*)untag_ptr(arg);
20691         int64_t ret_conv = COption_NetAddressZ_clone_ptr(arg_conv);
20692         return ret_conv;
20693 }
20694
20695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20696         LDKCOption_NetAddressZ* orig_conv = (LDKCOption_NetAddressZ*)untag_ptr(orig);
20697         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
20698         *ret_copy = COption_NetAddressZ_clone(orig_conv);
20699         int64_t ret_ref = tag_ptr(ret_copy, true);
20700         return ret_ref;
20701 }
20702
20703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20704         LDKCVec_u8Z o_ref;
20705         o_ref.datalen = (*env)->GetArrayLength(env, o);
20706         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
20707         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
20708         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
20709         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
20710         return tag_ptr(ret_conv, true);
20711 }
20712
20713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20714         LDKPeerHandleError e_conv;
20715         e_conv.inner = untag_ptr(e);
20716         e_conv.is_owned = ptr_is_owned(e);
20717         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20718         e_conv = PeerHandleError_clone(&e_conv);
20719         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
20720         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
20721         return tag_ptr(ret_conv, true);
20722 }
20723
20724 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20725         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(o);
20726         jboolean ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
20727         return ret_conv;
20728 }
20729
20730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20731         if (!ptr_is_owned(_res)) return;
20732         void* _res_ptr = untag_ptr(_res);
20733         CHECK_ACCESS(_res_ptr);
20734         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
20735         FREE(untag_ptr(_res));
20736         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
20737 }
20738
20739 static inline uint64_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
20740         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
20741         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
20742         return tag_ptr(ret_conv, true);
20743 }
20744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20745         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(arg);
20746         int64_t ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
20747         return ret_conv;
20748 }
20749
20750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20751         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(orig);
20752         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
20753         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
20754         return tag_ptr(ret_conv, true);
20755 }
20756
20757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
20758         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
20759         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
20760         return tag_ptr(ret_conv, true);
20761 }
20762
20763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20764         LDKPeerHandleError e_conv;
20765         e_conv.inner = untag_ptr(e);
20766         e_conv.is_owned = ptr_is_owned(e);
20767         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20768         e_conv = PeerHandleError_clone(&e_conv);
20769         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
20770         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
20771         return tag_ptr(ret_conv, true);
20772 }
20773
20774 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20775         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(o);
20776         jboolean ret_conv = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
20777         return ret_conv;
20778 }
20779
20780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20781         if (!ptr_is_owned(_res)) return;
20782         void* _res_ptr = untag_ptr(_res);
20783         CHECK_ACCESS(_res_ptr);
20784         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
20785         FREE(untag_ptr(_res));
20786         CResult_NonePeerHandleErrorZ_free(_res_conv);
20787 }
20788
20789 static inline uint64_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
20790         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
20791         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
20792         return tag_ptr(ret_conv, true);
20793 }
20794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20795         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(arg);
20796         int64_t ret_conv = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
20797         return ret_conv;
20798 }
20799
20800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20801         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(orig);
20802         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
20803         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
20804         return tag_ptr(ret_conv, true);
20805 }
20806
20807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
20808         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
20809         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
20810         return tag_ptr(ret_conv, true);
20811 }
20812
20813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20814         LDKPeerHandleError e_conv;
20815         e_conv.inner = untag_ptr(e);
20816         e_conv.is_owned = ptr_is_owned(e);
20817         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20818         e_conv = PeerHandleError_clone(&e_conv);
20819         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
20820         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
20821         return tag_ptr(ret_conv, true);
20822 }
20823
20824 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20825         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(o);
20826         jboolean ret_conv = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
20827         return ret_conv;
20828 }
20829
20830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20831         if (!ptr_is_owned(_res)) return;
20832         void* _res_ptr = untag_ptr(_res);
20833         CHECK_ACCESS(_res_ptr);
20834         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
20835         FREE(untag_ptr(_res));
20836         CResult_boolPeerHandleErrorZ_free(_res_conv);
20837 }
20838
20839 static inline uint64_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
20840         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
20841         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
20842         return tag_ptr(ret_conv, true);
20843 }
20844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20845         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(arg);
20846         int64_t ret_conv = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
20847         return ret_conv;
20848 }
20849
20850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20851         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(orig);
20852         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
20853         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
20854         return tag_ptr(ret_conv, true);
20855 }
20856
20857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1ok(JNIEnv *env, jclass clz, int32_t o) {
20858         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
20859         *ret_conv = CResult_u32GraphSyncErrorZ_ok(o);
20860         return tag_ptr(ret_conv, true);
20861 }
20862
20863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20864         void* e_ptr = untag_ptr(e);
20865         CHECK_ACCESS(e_ptr);
20866         LDKGraphSyncError e_conv = *(LDKGraphSyncError*)(e_ptr);
20867         e_conv = GraphSyncError_clone((LDKGraphSyncError*)untag_ptr(e));
20868         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
20869         *ret_conv = CResult_u32GraphSyncErrorZ_err(e_conv);
20870         return tag_ptr(ret_conv, true);
20871 }
20872
20873 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20874         LDKCResult_u32GraphSyncErrorZ* o_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(o);
20875         jboolean ret_conv = CResult_u32GraphSyncErrorZ_is_ok(o_conv);
20876         return ret_conv;
20877 }
20878
20879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20880         if (!ptr_is_owned(_res)) return;
20881         void* _res_ptr = untag_ptr(_res);
20882         CHECK_ACCESS(_res_ptr);
20883         LDKCResult_u32GraphSyncErrorZ _res_conv = *(LDKCResult_u32GraphSyncErrorZ*)(_res_ptr);
20884         FREE(untag_ptr(_res));
20885         CResult_u32GraphSyncErrorZ_free(_res_conv);
20886 }
20887
20888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20889         void* o_ptr = untag_ptr(o);
20890         CHECK_ACCESS(o_ptr);
20891         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
20892         o_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o));
20893         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
20894         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
20895         return tag_ptr(ret_conv, true);
20896 }
20897
20898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20899         LDKDecodeError e_conv;
20900         e_conv.inner = untag_ptr(e);
20901         e_conv.is_owned = ptr_is_owned(e);
20902         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20903         e_conv = DecodeError_clone(&e_conv);
20904         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
20905         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
20906         return tag_ptr(ret_conv, true);
20907 }
20908
20909 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20910         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(o);
20911         jboolean ret_conv = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
20912         return ret_conv;
20913 }
20914
20915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20916         if (!ptr_is_owned(_res)) return;
20917         void* _res_ptr = untag_ptr(_res);
20918         CHECK_ACCESS(_res_ptr);
20919         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
20920         FREE(untag_ptr(_res));
20921         CResult_NetAddressDecodeErrorZ_free(_res_conv);
20922 }
20923
20924 static inline uint64_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
20925         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
20926         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
20927         return tag_ptr(ret_conv, true);
20928 }
20929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20930         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(arg);
20931         int64_t ret_conv = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
20932         return ret_conv;
20933 }
20934
20935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20936         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(orig);
20937         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
20938         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
20939         return tag_ptr(ret_conv, true);
20940 }
20941
20942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20943         LDKCVec_UpdateAddHTLCZ _res_constr;
20944         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20945         if (_res_constr.datalen > 0)
20946                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
20947         else
20948                 _res_constr.data = NULL;
20949         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20950         for (size_t p = 0; p < _res_constr.datalen; p++) {
20951                 int64_t _res_conv_15 = _res_vals[p];
20952                 LDKUpdateAddHTLC _res_conv_15_conv;
20953                 _res_conv_15_conv.inner = untag_ptr(_res_conv_15);
20954                 _res_conv_15_conv.is_owned = ptr_is_owned(_res_conv_15);
20955                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
20956                 _res_constr.data[p] = _res_conv_15_conv;
20957         }
20958         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20959         CVec_UpdateAddHTLCZ_free(_res_constr);
20960 }
20961
20962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20963         LDKCVec_UpdateFulfillHTLCZ _res_constr;
20964         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20965         if (_res_constr.datalen > 0)
20966                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
20967         else
20968                 _res_constr.data = NULL;
20969         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20970         for (size_t t = 0; t < _res_constr.datalen; t++) {
20971                 int64_t _res_conv_19 = _res_vals[t];
20972                 LDKUpdateFulfillHTLC _res_conv_19_conv;
20973                 _res_conv_19_conv.inner = untag_ptr(_res_conv_19);
20974                 _res_conv_19_conv.is_owned = ptr_is_owned(_res_conv_19);
20975                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
20976                 _res_constr.data[t] = _res_conv_19_conv;
20977         }
20978         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20979         CVec_UpdateFulfillHTLCZ_free(_res_constr);
20980 }
20981
20982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20983         LDKCVec_UpdateFailHTLCZ _res_constr;
20984         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20985         if (_res_constr.datalen > 0)
20986                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
20987         else
20988                 _res_constr.data = NULL;
20989         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20990         for (size_t q = 0; q < _res_constr.datalen; q++) {
20991                 int64_t _res_conv_16 = _res_vals[q];
20992                 LDKUpdateFailHTLC _res_conv_16_conv;
20993                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
20994                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
20995                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
20996                 _res_constr.data[q] = _res_conv_16_conv;
20997         }
20998         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20999         CVec_UpdateFailHTLCZ_free(_res_constr);
21000 }
21001
21002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21003         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
21004         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21005         if (_res_constr.datalen > 0)
21006                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
21007         else
21008                 _res_constr.data = NULL;
21009         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21010         for (size_t z = 0; z < _res_constr.datalen; z++) {
21011                 int64_t _res_conv_25 = _res_vals[z];
21012                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
21013                 _res_conv_25_conv.inner = untag_ptr(_res_conv_25);
21014                 _res_conv_25_conv.is_owned = ptr_is_owned(_res_conv_25);
21015                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
21016                 _res_constr.data[z] = _res_conv_25_conv;
21017         }
21018         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21019         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
21020 }
21021
21022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21023         LDKAcceptChannel o_conv;
21024         o_conv.inner = untag_ptr(o);
21025         o_conv.is_owned = ptr_is_owned(o);
21026         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21027         o_conv = AcceptChannel_clone(&o_conv);
21028         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21029         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
21030         return tag_ptr(ret_conv, true);
21031 }
21032
21033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21034         LDKDecodeError e_conv;
21035         e_conv.inner = untag_ptr(e);
21036         e_conv.is_owned = ptr_is_owned(e);
21037         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21038         e_conv = DecodeError_clone(&e_conv);
21039         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21040         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
21041         return tag_ptr(ret_conv, true);
21042 }
21043
21044 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21045         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(o);
21046         jboolean ret_conv = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
21047         return ret_conv;
21048 }
21049
21050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21051         if (!ptr_is_owned(_res)) return;
21052         void* _res_ptr = untag_ptr(_res);
21053         CHECK_ACCESS(_res_ptr);
21054         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
21055         FREE(untag_ptr(_res));
21056         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
21057 }
21058
21059 static inline uint64_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
21060         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21061         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
21062         return tag_ptr(ret_conv, true);
21063 }
21064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21065         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(arg);
21066         int64_t ret_conv = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
21067         return ret_conv;
21068 }
21069
21070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21071         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(orig);
21072         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21073         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
21074         return tag_ptr(ret_conv, true);
21075 }
21076
21077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21078         LDKAnnouncementSignatures o_conv;
21079         o_conv.inner = untag_ptr(o);
21080         o_conv.is_owned = ptr_is_owned(o);
21081         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21082         o_conv = AnnouncementSignatures_clone(&o_conv);
21083         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21084         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
21085         return tag_ptr(ret_conv, true);
21086 }
21087
21088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21089         LDKDecodeError e_conv;
21090         e_conv.inner = untag_ptr(e);
21091         e_conv.is_owned = ptr_is_owned(e);
21092         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21093         e_conv = DecodeError_clone(&e_conv);
21094         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21095         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
21096         return tag_ptr(ret_conv, true);
21097 }
21098
21099 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21100         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(o);
21101         jboolean ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
21102         return ret_conv;
21103 }
21104
21105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21106         if (!ptr_is_owned(_res)) return;
21107         void* _res_ptr = untag_ptr(_res);
21108         CHECK_ACCESS(_res_ptr);
21109         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
21110         FREE(untag_ptr(_res));
21111         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
21112 }
21113
21114 static inline uint64_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
21115         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21116         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
21117         return tag_ptr(ret_conv, true);
21118 }
21119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21120         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(arg);
21121         int64_t ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
21122         return ret_conv;
21123 }
21124
21125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21126         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(orig);
21127         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21128         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
21129         return tag_ptr(ret_conv, true);
21130 }
21131
21132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21133         LDKChannelReestablish o_conv;
21134         o_conv.inner = untag_ptr(o);
21135         o_conv.is_owned = ptr_is_owned(o);
21136         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21137         o_conv = ChannelReestablish_clone(&o_conv);
21138         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
21139         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
21140         return tag_ptr(ret_conv, true);
21141 }
21142
21143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21144         LDKDecodeError e_conv;
21145         e_conv.inner = untag_ptr(e);
21146         e_conv.is_owned = ptr_is_owned(e);
21147         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21148         e_conv = DecodeError_clone(&e_conv);
21149         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
21150         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
21151         return tag_ptr(ret_conv, true);
21152 }
21153
21154 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21155         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(o);
21156         jboolean ret_conv = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
21157         return ret_conv;
21158 }
21159
21160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21161         if (!ptr_is_owned(_res)) return;
21162         void* _res_ptr = untag_ptr(_res);
21163         CHECK_ACCESS(_res_ptr);
21164         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
21165         FREE(untag_ptr(_res));
21166         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
21167 }
21168
21169 static inline uint64_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
21170         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
21171         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
21172         return tag_ptr(ret_conv, true);
21173 }
21174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21175         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(arg);
21176         int64_t ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
21177         return ret_conv;
21178 }
21179
21180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21181         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(orig);
21182         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
21183         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
21184         return tag_ptr(ret_conv, true);
21185 }
21186
21187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21188         LDKClosingSigned o_conv;
21189         o_conv.inner = untag_ptr(o);
21190         o_conv.is_owned = ptr_is_owned(o);
21191         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21192         o_conv = ClosingSigned_clone(&o_conv);
21193         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
21194         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
21195         return tag_ptr(ret_conv, true);
21196 }
21197
21198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21199         LDKDecodeError e_conv;
21200         e_conv.inner = untag_ptr(e);
21201         e_conv.is_owned = ptr_is_owned(e);
21202         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21203         e_conv = DecodeError_clone(&e_conv);
21204         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
21205         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
21206         return tag_ptr(ret_conv, true);
21207 }
21208
21209 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21210         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(o);
21211         jboolean ret_conv = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
21212         return ret_conv;
21213 }
21214
21215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21216         if (!ptr_is_owned(_res)) return;
21217         void* _res_ptr = untag_ptr(_res);
21218         CHECK_ACCESS(_res_ptr);
21219         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
21220         FREE(untag_ptr(_res));
21221         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
21222 }
21223
21224 static inline uint64_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
21225         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
21226         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
21227         return tag_ptr(ret_conv, true);
21228 }
21229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21230         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(arg);
21231         int64_t ret_conv = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
21232         return ret_conv;
21233 }
21234
21235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21236         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(orig);
21237         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
21238         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
21239         return tag_ptr(ret_conv, true);
21240 }
21241
21242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21243         LDKClosingSignedFeeRange o_conv;
21244         o_conv.inner = untag_ptr(o);
21245         o_conv.is_owned = ptr_is_owned(o);
21246         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21247         o_conv = ClosingSignedFeeRange_clone(&o_conv);
21248         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
21249         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
21250         return tag_ptr(ret_conv, true);
21251 }
21252
21253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21254         LDKDecodeError e_conv;
21255         e_conv.inner = untag_ptr(e);
21256         e_conv.is_owned = ptr_is_owned(e);
21257         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21258         e_conv = DecodeError_clone(&e_conv);
21259         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
21260         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
21261         return tag_ptr(ret_conv, true);
21262 }
21263
21264 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21265         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(o);
21266         jboolean ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
21267         return ret_conv;
21268 }
21269
21270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21271         if (!ptr_is_owned(_res)) return;
21272         void* _res_ptr = untag_ptr(_res);
21273         CHECK_ACCESS(_res_ptr);
21274         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
21275         FREE(untag_ptr(_res));
21276         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
21277 }
21278
21279 static inline uint64_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
21280         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
21281         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
21282         return tag_ptr(ret_conv, true);
21283 }
21284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21285         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(arg);
21286         int64_t ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
21287         return ret_conv;
21288 }
21289
21290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21291         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(orig);
21292         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
21293         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
21294         return tag_ptr(ret_conv, true);
21295 }
21296
21297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21298         LDKCommitmentSigned o_conv;
21299         o_conv.inner = untag_ptr(o);
21300         o_conv.is_owned = ptr_is_owned(o);
21301         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21302         o_conv = CommitmentSigned_clone(&o_conv);
21303         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
21304         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
21305         return tag_ptr(ret_conv, true);
21306 }
21307
21308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21309         LDKDecodeError e_conv;
21310         e_conv.inner = untag_ptr(e);
21311         e_conv.is_owned = ptr_is_owned(e);
21312         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21313         e_conv = DecodeError_clone(&e_conv);
21314         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
21315         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
21316         return tag_ptr(ret_conv, true);
21317 }
21318
21319 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21320         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(o);
21321         jboolean ret_conv = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
21322         return ret_conv;
21323 }
21324
21325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21326         if (!ptr_is_owned(_res)) return;
21327         void* _res_ptr = untag_ptr(_res);
21328         CHECK_ACCESS(_res_ptr);
21329         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
21330         FREE(untag_ptr(_res));
21331         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
21332 }
21333
21334 static inline uint64_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
21335         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
21336         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
21337         return tag_ptr(ret_conv, true);
21338 }
21339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21340         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(arg);
21341         int64_t ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
21342         return ret_conv;
21343 }
21344
21345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21346         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(orig);
21347         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
21348         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
21349         return tag_ptr(ret_conv, true);
21350 }
21351
21352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21353         LDKFundingCreated o_conv;
21354         o_conv.inner = untag_ptr(o);
21355         o_conv.is_owned = ptr_is_owned(o);
21356         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21357         o_conv = FundingCreated_clone(&o_conv);
21358         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
21359         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
21360         return tag_ptr(ret_conv, true);
21361 }
21362
21363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21364         LDKDecodeError e_conv;
21365         e_conv.inner = untag_ptr(e);
21366         e_conv.is_owned = ptr_is_owned(e);
21367         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21368         e_conv = DecodeError_clone(&e_conv);
21369         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
21370         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
21371         return tag_ptr(ret_conv, true);
21372 }
21373
21374 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21375         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(o);
21376         jboolean ret_conv = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
21377         return ret_conv;
21378 }
21379
21380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21381         if (!ptr_is_owned(_res)) return;
21382         void* _res_ptr = untag_ptr(_res);
21383         CHECK_ACCESS(_res_ptr);
21384         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
21385         FREE(untag_ptr(_res));
21386         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
21387 }
21388
21389 static inline uint64_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
21390         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
21391         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
21392         return tag_ptr(ret_conv, true);
21393 }
21394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21395         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(arg);
21396         int64_t ret_conv = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
21397         return ret_conv;
21398 }
21399
21400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21401         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(orig);
21402         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
21403         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
21404         return tag_ptr(ret_conv, true);
21405 }
21406
21407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21408         LDKFundingSigned o_conv;
21409         o_conv.inner = untag_ptr(o);
21410         o_conv.is_owned = ptr_is_owned(o);
21411         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21412         o_conv = FundingSigned_clone(&o_conv);
21413         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
21414         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
21415         return tag_ptr(ret_conv, true);
21416 }
21417
21418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21419         LDKDecodeError e_conv;
21420         e_conv.inner = untag_ptr(e);
21421         e_conv.is_owned = ptr_is_owned(e);
21422         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21423         e_conv = DecodeError_clone(&e_conv);
21424         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
21425         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
21426         return tag_ptr(ret_conv, true);
21427 }
21428
21429 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21430         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(o);
21431         jboolean ret_conv = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
21432         return ret_conv;
21433 }
21434
21435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21436         if (!ptr_is_owned(_res)) return;
21437         void* _res_ptr = untag_ptr(_res);
21438         CHECK_ACCESS(_res_ptr);
21439         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
21440         FREE(untag_ptr(_res));
21441         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
21442 }
21443
21444 static inline uint64_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
21445         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
21446         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
21447         return tag_ptr(ret_conv, true);
21448 }
21449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21450         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(arg);
21451         int64_t ret_conv = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
21452         return ret_conv;
21453 }
21454
21455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21456         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(orig);
21457         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
21458         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
21459         return tag_ptr(ret_conv, true);
21460 }
21461
21462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21463         LDKChannelReady o_conv;
21464         o_conv.inner = untag_ptr(o);
21465         o_conv.is_owned = ptr_is_owned(o);
21466         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21467         o_conv = ChannelReady_clone(&o_conv);
21468         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
21469         *ret_conv = CResult_ChannelReadyDecodeErrorZ_ok(o_conv);
21470         return tag_ptr(ret_conv, true);
21471 }
21472
21473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21474         LDKDecodeError e_conv;
21475         e_conv.inner = untag_ptr(e);
21476         e_conv.is_owned = ptr_is_owned(e);
21477         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21478         e_conv = DecodeError_clone(&e_conv);
21479         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
21480         *ret_conv = CResult_ChannelReadyDecodeErrorZ_err(e_conv);
21481         return tag_ptr(ret_conv, true);
21482 }
21483
21484 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21485         LDKCResult_ChannelReadyDecodeErrorZ* o_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(o);
21486         jboolean ret_conv = CResult_ChannelReadyDecodeErrorZ_is_ok(o_conv);
21487         return ret_conv;
21488 }
21489
21490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21491         if (!ptr_is_owned(_res)) return;
21492         void* _res_ptr = untag_ptr(_res);
21493         CHECK_ACCESS(_res_ptr);
21494         LDKCResult_ChannelReadyDecodeErrorZ _res_conv = *(LDKCResult_ChannelReadyDecodeErrorZ*)(_res_ptr);
21495         FREE(untag_ptr(_res));
21496         CResult_ChannelReadyDecodeErrorZ_free(_res_conv);
21497 }
21498
21499 static inline uint64_t CResult_ChannelReadyDecodeErrorZ_clone_ptr(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR arg) {
21500         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
21501         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(arg);
21502         return tag_ptr(ret_conv, true);
21503 }
21504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21505         LDKCResult_ChannelReadyDecodeErrorZ* arg_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(arg);
21506         int64_t ret_conv = CResult_ChannelReadyDecodeErrorZ_clone_ptr(arg_conv);
21507         return ret_conv;
21508 }
21509
21510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21511         LDKCResult_ChannelReadyDecodeErrorZ* orig_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(orig);
21512         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
21513         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(orig_conv);
21514         return tag_ptr(ret_conv, true);
21515 }
21516
21517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21518         LDKInit o_conv;
21519         o_conv.inner = untag_ptr(o);
21520         o_conv.is_owned = ptr_is_owned(o);
21521         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21522         o_conv = Init_clone(&o_conv);
21523         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
21524         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
21525         return tag_ptr(ret_conv, true);
21526 }
21527
21528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21529         LDKDecodeError e_conv;
21530         e_conv.inner = untag_ptr(e);
21531         e_conv.is_owned = ptr_is_owned(e);
21532         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21533         e_conv = DecodeError_clone(&e_conv);
21534         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
21535         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
21536         return tag_ptr(ret_conv, true);
21537 }
21538
21539 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21540         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(o);
21541         jboolean ret_conv = CResult_InitDecodeErrorZ_is_ok(o_conv);
21542         return ret_conv;
21543 }
21544
21545 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21546         if (!ptr_is_owned(_res)) return;
21547         void* _res_ptr = untag_ptr(_res);
21548         CHECK_ACCESS(_res_ptr);
21549         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
21550         FREE(untag_ptr(_res));
21551         CResult_InitDecodeErrorZ_free(_res_conv);
21552 }
21553
21554 static inline uint64_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
21555         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
21556         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
21557         return tag_ptr(ret_conv, true);
21558 }
21559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21560         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(arg);
21561         int64_t ret_conv = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
21562         return ret_conv;
21563 }
21564
21565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21566         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(orig);
21567         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
21568         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
21569         return tag_ptr(ret_conv, true);
21570 }
21571
21572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21573         LDKOpenChannel o_conv;
21574         o_conv.inner = untag_ptr(o);
21575         o_conv.is_owned = ptr_is_owned(o);
21576         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21577         o_conv = OpenChannel_clone(&o_conv);
21578         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
21579         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
21580         return tag_ptr(ret_conv, true);
21581 }
21582
21583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21584         LDKDecodeError e_conv;
21585         e_conv.inner = untag_ptr(e);
21586         e_conv.is_owned = ptr_is_owned(e);
21587         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21588         e_conv = DecodeError_clone(&e_conv);
21589         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
21590         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
21591         return tag_ptr(ret_conv, true);
21592 }
21593
21594 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21595         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(o);
21596         jboolean ret_conv = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
21597         return ret_conv;
21598 }
21599
21600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21601         if (!ptr_is_owned(_res)) return;
21602         void* _res_ptr = untag_ptr(_res);
21603         CHECK_ACCESS(_res_ptr);
21604         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
21605         FREE(untag_ptr(_res));
21606         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
21607 }
21608
21609 static inline uint64_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
21610         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
21611         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
21612         return tag_ptr(ret_conv, true);
21613 }
21614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21615         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(arg);
21616         int64_t ret_conv = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
21617         return ret_conv;
21618 }
21619
21620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21621         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(orig);
21622         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
21623         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
21624         return tag_ptr(ret_conv, true);
21625 }
21626
21627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21628         LDKRevokeAndACK o_conv;
21629         o_conv.inner = untag_ptr(o);
21630         o_conv.is_owned = ptr_is_owned(o);
21631         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21632         o_conv = RevokeAndACK_clone(&o_conv);
21633         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
21634         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
21635         return tag_ptr(ret_conv, true);
21636 }
21637
21638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21639         LDKDecodeError e_conv;
21640         e_conv.inner = untag_ptr(e);
21641         e_conv.is_owned = ptr_is_owned(e);
21642         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21643         e_conv = DecodeError_clone(&e_conv);
21644         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
21645         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
21646         return tag_ptr(ret_conv, true);
21647 }
21648
21649 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21650         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(o);
21651         jboolean ret_conv = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
21652         return ret_conv;
21653 }
21654
21655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21656         if (!ptr_is_owned(_res)) return;
21657         void* _res_ptr = untag_ptr(_res);
21658         CHECK_ACCESS(_res_ptr);
21659         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
21660         FREE(untag_ptr(_res));
21661         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
21662 }
21663
21664 static inline uint64_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
21665         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
21666         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
21667         return tag_ptr(ret_conv, true);
21668 }
21669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21670         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(arg);
21671         int64_t ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
21672         return ret_conv;
21673 }
21674
21675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21676         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(orig);
21677         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
21678         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
21679         return tag_ptr(ret_conv, true);
21680 }
21681
21682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21683         LDKShutdown o_conv;
21684         o_conv.inner = untag_ptr(o);
21685         o_conv.is_owned = ptr_is_owned(o);
21686         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21687         o_conv = Shutdown_clone(&o_conv);
21688         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
21689         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
21690         return tag_ptr(ret_conv, true);
21691 }
21692
21693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21694         LDKDecodeError e_conv;
21695         e_conv.inner = untag_ptr(e);
21696         e_conv.is_owned = ptr_is_owned(e);
21697         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21698         e_conv = DecodeError_clone(&e_conv);
21699         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
21700         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
21701         return tag_ptr(ret_conv, true);
21702 }
21703
21704 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21705         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(o);
21706         jboolean ret_conv = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
21707         return ret_conv;
21708 }
21709
21710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21711         if (!ptr_is_owned(_res)) return;
21712         void* _res_ptr = untag_ptr(_res);
21713         CHECK_ACCESS(_res_ptr);
21714         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
21715         FREE(untag_ptr(_res));
21716         CResult_ShutdownDecodeErrorZ_free(_res_conv);
21717 }
21718
21719 static inline uint64_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
21720         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
21721         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
21722         return tag_ptr(ret_conv, true);
21723 }
21724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21725         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(arg);
21726         int64_t ret_conv = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
21727         return ret_conv;
21728 }
21729
21730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21731         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(orig);
21732         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
21733         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
21734         return tag_ptr(ret_conv, true);
21735 }
21736
21737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21738         LDKUpdateFailHTLC o_conv;
21739         o_conv.inner = untag_ptr(o);
21740         o_conv.is_owned = ptr_is_owned(o);
21741         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21742         o_conv = UpdateFailHTLC_clone(&o_conv);
21743         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
21744         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
21745         return tag_ptr(ret_conv, true);
21746 }
21747
21748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21749         LDKDecodeError e_conv;
21750         e_conv.inner = untag_ptr(e);
21751         e_conv.is_owned = ptr_is_owned(e);
21752         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21753         e_conv = DecodeError_clone(&e_conv);
21754         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
21755         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
21756         return tag_ptr(ret_conv, true);
21757 }
21758
21759 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21760         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(o);
21761         jboolean ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
21762         return ret_conv;
21763 }
21764
21765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21766         if (!ptr_is_owned(_res)) return;
21767         void* _res_ptr = untag_ptr(_res);
21768         CHECK_ACCESS(_res_ptr);
21769         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
21770         FREE(untag_ptr(_res));
21771         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
21772 }
21773
21774 static inline uint64_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
21775         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
21776         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
21777         return tag_ptr(ret_conv, true);
21778 }
21779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21780         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(arg);
21781         int64_t ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
21782         return ret_conv;
21783 }
21784
21785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21786         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(orig);
21787         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
21788         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
21789         return tag_ptr(ret_conv, true);
21790 }
21791
21792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21793         LDKUpdateFailMalformedHTLC o_conv;
21794         o_conv.inner = untag_ptr(o);
21795         o_conv.is_owned = ptr_is_owned(o);
21796         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21797         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
21798         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
21799         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
21800         return tag_ptr(ret_conv, true);
21801 }
21802
21803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21804         LDKDecodeError e_conv;
21805         e_conv.inner = untag_ptr(e);
21806         e_conv.is_owned = ptr_is_owned(e);
21807         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21808         e_conv = DecodeError_clone(&e_conv);
21809         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
21810         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
21811         return tag_ptr(ret_conv, true);
21812 }
21813
21814 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21815         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(o);
21816         jboolean ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
21817         return ret_conv;
21818 }
21819
21820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21821         if (!ptr_is_owned(_res)) return;
21822         void* _res_ptr = untag_ptr(_res);
21823         CHECK_ACCESS(_res_ptr);
21824         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
21825         FREE(untag_ptr(_res));
21826         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
21827 }
21828
21829 static inline uint64_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
21830         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
21831         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
21832         return tag_ptr(ret_conv, true);
21833 }
21834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21835         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(arg);
21836         int64_t ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
21837         return ret_conv;
21838 }
21839
21840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21841         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(orig);
21842         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
21843         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
21844         return tag_ptr(ret_conv, true);
21845 }
21846
21847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21848         LDKUpdateFee o_conv;
21849         o_conv.inner = untag_ptr(o);
21850         o_conv.is_owned = ptr_is_owned(o);
21851         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21852         o_conv = UpdateFee_clone(&o_conv);
21853         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
21854         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
21855         return tag_ptr(ret_conv, true);
21856 }
21857
21858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21859         LDKDecodeError e_conv;
21860         e_conv.inner = untag_ptr(e);
21861         e_conv.is_owned = ptr_is_owned(e);
21862         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21863         e_conv = DecodeError_clone(&e_conv);
21864         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
21865         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
21866         return tag_ptr(ret_conv, true);
21867 }
21868
21869 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21870         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(o);
21871         jboolean ret_conv = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
21872         return ret_conv;
21873 }
21874
21875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21876         if (!ptr_is_owned(_res)) return;
21877         void* _res_ptr = untag_ptr(_res);
21878         CHECK_ACCESS(_res_ptr);
21879         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
21880         FREE(untag_ptr(_res));
21881         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
21882 }
21883
21884 static inline uint64_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
21885         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
21886         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
21887         return tag_ptr(ret_conv, true);
21888 }
21889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21890         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(arg);
21891         int64_t ret_conv = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
21892         return ret_conv;
21893 }
21894
21895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21896         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(orig);
21897         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
21898         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
21899         return tag_ptr(ret_conv, true);
21900 }
21901
21902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21903         LDKUpdateFulfillHTLC o_conv;
21904         o_conv.inner = untag_ptr(o);
21905         o_conv.is_owned = ptr_is_owned(o);
21906         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21907         o_conv = UpdateFulfillHTLC_clone(&o_conv);
21908         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
21909         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
21910         return tag_ptr(ret_conv, true);
21911 }
21912
21913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21914         LDKDecodeError e_conv;
21915         e_conv.inner = untag_ptr(e);
21916         e_conv.is_owned = ptr_is_owned(e);
21917         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21918         e_conv = DecodeError_clone(&e_conv);
21919         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
21920         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
21921         return tag_ptr(ret_conv, true);
21922 }
21923
21924 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21925         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(o);
21926         jboolean ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
21927         return ret_conv;
21928 }
21929
21930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21931         if (!ptr_is_owned(_res)) return;
21932         void* _res_ptr = untag_ptr(_res);
21933         CHECK_ACCESS(_res_ptr);
21934         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
21935         FREE(untag_ptr(_res));
21936         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
21937 }
21938
21939 static inline uint64_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
21940         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
21941         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
21942         return tag_ptr(ret_conv, true);
21943 }
21944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21945         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(arg);
21946         int64_t ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
21947         return ret_conv;
21948 }
21949
21950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21951         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(orig);
21952         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
21953         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
21954         return tag_ptr(ret_conv, true);
21955 }
21956
21957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21958         LDKUpdateAddHTLC o_conv;
21959         o_conv.inner = untag_ptr(o);
21960         o_conv.is_owned = ptr_is_owned(o);
21961         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21962         o_conv = UpdateAddHTLC_clone(&o_conv);
21963         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
21964         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
21965         return tag_ptr(ret_conv, true);
21966 }
21967
21968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21969         LDKDecodeError e_conv;
21970         e_conv.inner = untag_ptr(e);
21971         e_conv.is_owned = ptr_is_owned(e);
21972         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21973         e_conv = DecodeError_clone(&e_conv);
21974         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
21975         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
21976         return tag_ptr(ret_conv, true);
21977 }
21978
21979 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21980         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(o);
21981         jboolean ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
21982         return ret_conv;
21983 }
21984
21985 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21986         if (!ptr_is_owned(_res)) return;
21987         void* _res_ptr = untag_ptr(_res);
21988         CHECK_ACCESS(_res_ptr);
21989         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
21990         FREE(untag_ptr(_res));
21991         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
21992 }
21993
21994 static inline uint64_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
21995         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
21996         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
21997         return tag_ptr(ret_conv, true);
21998 }
21999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22000         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(arg);
22001         int64_t ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
22002         return ret_conv;
22003 }
22004
22005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22006         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(orig);
22007         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
22008         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
22009         return tag_ptr(ret_conv, true);
22010 }
22011
22012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22013         LDKPing o_conv;
22014         o_conv.inner = untag_ptr(o);
22015         o_conv.is_owned = ptr_is_owned(o);
22016         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22017         o_conv = Ping_clone(&o_conv);
22018         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
22019         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
22020         return tag_ptr(ret_conv, true);
22021 }
22022
22023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22024         LDKDecodeError e_conv;
22025         e_conv.inner = untag_ptr(e);
22026         e_conv.is_owned = ptr_is_owned(e);
22027         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22028         e_conv = DecodeError_clone(&e_conv);
22029         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
22030         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
22031         return tag_ptr(ret_conv, true);
22032 }
22033
22034 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22035         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(o);
22036         jboolean ret_conv = CResult_PingDecodeErrorZ_is_ok(o_conv);
22037         return ret_conv;
22038 }
22039
22040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22041         if (!ptr_is_owned(_res)) return;
22042         void* _res_ptr = untag_ptr(_res);
22043         CHECK_ACCESS(_res_ptr);
22044         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
22045         FREE(untag_ptr(_res));
22046         CResult_PingDecodeErrorZ_free(_res_conv);
22047 }
22048
22049 static inline uint64_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
22050         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
22051         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
22052         return tag_ptr(ret_conv, true);
22053 }
22054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22055         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(arg);
22056         int64_t ret_conv = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
22057         return ret_conv;
22058 }
22059
22060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22061         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(orig);
22062         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
22063         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
22064         return tag_ptr(ret_conv, true);
22065 }
22066
22067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22068         LDKPong o_conv;
22069         o_conv.inner = untag_ptr(o);
22070         o_conv.is_owned = ptr_is_owned(o);
22071         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22072         o_conv = Pong_clone(&o_conv);
22073         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
22074         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
22075         return tag_ptr(ret_conv, true);
22076 }
22077
22078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22079         LDKDecodeError e_conv;
22080         e_conv.inner = untag_ptr(e);
22081         e_conv.is_owned = ptr_is_owned(e);
22082         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22083         e_conv = DecodeError_clone(&e_conv);
22084         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
22085         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
22086         return tag_ptr(ret_conv, true);
22087 }
22088
22089 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22090         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(o);
22091         jboolean ret_conv = CResult_PongDecodeErrorZ_is_ok(o_conv);
22092         return ret_conv;
22093 }
22094
22095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22096         if (!ptr_is_owned(_res)) return;
22097         void* _res_ptr = untag_ptr(_res);
22098         CHECK_ACCESS(_res_ptr);
22099         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
22100         FREE(untag_ptr(_res));
22101         CResult_PongDecodeErrorZ_free(_res_conv);
22102 }
22103
22104 static inline uint64_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
22105         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
22106         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
22107         return tag_ptr(ret_conv, true);
22108 }
22109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22110         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(arg);
22111         int64_t ret_conv = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
22112         return ret_conv;
22113 }
22114
22115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22116         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(orig);
22117         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
22118         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
22119         return tag_ptr(ret_conv, true);
22120 }
22121
22122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22123         LDKUnsignedChannelAnnouncement o_conv;
22124         o_conv.inner = untag_ptr(o);
22125         o_conv.is_owned = ptr_is_owned(o);
22126         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22127         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
22128         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
22129         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
22130         return tag_ptr(ret_conv, true);
22131 }
22132
22133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22134         LDKDecodeError e_conv;
22135         e_conv.inner = untag_ptr(e);
22136         e_conv.is_owned = ptr_is_owned(e);
22137         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22138         e_conv = DecodeError_clone(&e_conv);
22139         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
22140         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
22141         return tag_ptr(ret_conv, true);
22142 }
22143
22144 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22145         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(o);
22146         jboolean ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
22147         return ret_conv;
22148 }
22149
22150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22151         if (!ptr_is_owned(_res)) return;
22152         void* _res_ptr = untag_ptr(_res);
22153         CHECK_ACCESS(_res_ptr);
22154         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
22155         FREE(untag_ptr(_res));
22156         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
22157 }
22158
22159 static inline uint64_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
22160         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
22161         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
22162         return tag_ptr(ret_conv, true);
22163 }
22164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22165         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(arg);
22166         int64_t ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
22167         return ret_conv;
22168 }
22169
22170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22171         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(orig);
22172         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
22173         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
22174         return tag_ptr(ret_conv, true);
22175 }
22176
22177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22178         LDKChannelAnnouncement o_conv;
22179         o_conv.inner = untag_ptr(o);
22180         o_conv.is_owned = ptr_is_owned(o);
22181         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22182         o_conv = ChannelAnnouncement_clone(&o_conv);
22183         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
22184         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
22185         return tag_ptr(ret_conv, true);
22186 }
22187
22188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22189         LDKDecodeError e_conv;
22190         e_conv.inner = untag_ptr(e);
22191         e_conv.is_owned = ptr_is_owned(e);
22192         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22193         e_conv = DecodeError_clone(&e_conv);
22194         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
22195         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
22196         return tag_ptr(ret_conv, true);
22197 }
22198
22199 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22200         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(o);
22201         jboolean ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
22202         return ret_conv;
22203 }
22204
22205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22206         if (!ptr_is_owned(_res)) return;
22207         void* _res_ptr = untag_ptr(_res);
22208         CHECK_ACCESS(_res_ptr);
22209         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
22210         FREE(untag_ptr(_res));
22211         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
22212 }
22213
22214 static inline uint64_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
22215         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
22216         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
22217         return tag_ptr(ret_conv, true);
22218 }
22219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22220         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(arg);
22221         int64_t ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
22222         return ret_conv;
22223 }
22224
22225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22226         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(orig);
22227         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
22228         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
22229         return tag_ptr(ret_conv, true);
22230 }
22231
22232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22233         LDKUnsignedChannelUpdate o_conv;
22234         o_conv.inner = untag_ptr(o);
22235         o_conv.is_owned = ptr_is_owned(o);
22236         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22237         o_conv = UnsignedChannelUpdate_clone(&o_conv);
22238         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
22239         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
22240         return tag_ptr(ret_conv, true);
22241 }
22242
22243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22244         LDKDecodeError e_conv;
22245         e_conv.inner = untag_ptr(e);
22246         e_conv.is_owned = ptr_is_owned(e);
22247         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22248         e_conv = DecodeError_clone(&e_conv);
22249         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
22250         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
22251         return tag_ptr(ret_conv, true);
22252 }
22253
22254 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22255         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(o);
22256         jboolean ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
22257         return ret_conv;
22258 }
22259
22260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22261         if (!ptr_is_owned(_res)) return;
22262         void* _res_ptr = untag_ptr(_res);
22263         CHECK_ACCESS(_res_ptr);
22264         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
22265         FREE(untag_ptr(_res));
22266         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
22267 }
22268
22269 static inline uint64_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
22270         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
22271         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
22272         return tag_ptr(ret_conv, true);
22273 }
22274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22275         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(arg);
22276         int64_t ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
22277         return ret_conv;
22278 }
22279
22280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22281         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(orig);
22282         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
22283         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
22284         return tag_ptr(ret_conv, true);
22285 }
22286
22287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22288         LDKChannelUpdate o_conv;
22289         o_conv.inner = untag_ptr(o);
22290         o_conv.is_owned = ptr_is_owned(o);
22291         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22292         o_conv = ChannelUpdate_clone(&o_conv);
22293         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
22294         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
22295         return tag_ptr(ret_conv, true);
22296 }
22297
22298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22299         LDKDecodeError e_conv;
22300         e_conv.inner = untag_ptr(e);
22301         e_conv.is_owned = ptr_is_owned(e);
22302         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22303         e_conv = DecodeError_clone(&e_conv);
22304         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
22305         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
22306         return tag_ptr(ret_conv, true);
22307 }
22308
22309 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22310         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(o);
22311         jboolean ret_conv = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
22312         return ret_conv;
22313 }
22314
22315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22316         if (!ptr_is_owned(_res)) return;
22317         void* _res_ptr = untag_ptr(_res);
22318         CHECK_ACCESS(_res_ptr);
22319         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
22320         FREE(untag_ptr(_res));
22321         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
22322 }
22323
22324 static inline uint64_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
22325         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
22326         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
22327         return tag_ptr(ret_conv, true);
22328 }
22329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22330         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(arg);
22331         int64_t ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
22332         return ret_conv;
22333 }
22334
22335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22336         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(orig);
22337         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
22338         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
22339         return tag_ptr(ret_conv, true);
22340 }
22341
22342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22343         LDKErrorMessage o_conv;
22344         o_conv.inner = untag_ptr(o);
22345         o_conv.is_owned = ptr_is_owned(o);
22346         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22347         o_conv = ErrorMessage_clone(&o_conv);
22348         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
22349         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
22350         return tag_ptr(ret_conv, true);
22351 }
22352
22353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22354         LDKDecodeError e_conv;
22355         e_conv.inner = untag_ptr(e);
22356         e_conv.is_owned = ptr_is_owned(e);
22357         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22358         e_conv = DecodeError_clone(&e_conv);
22359         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
22360         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
22361         return tag_ptr(ret_conv, true);
22362 }
22363
22364 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22365         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(o);
22366         jboolean ret_conv = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
22367         return ret_conv;
22368 }
22369
22370 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22371         if (!ptr_is_owned(_res)) return;
22372         void* _res_ptr = untag_ptr(_res);
22373         CHECK_ACCESS(_res_ptr);
22374         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
22375         FREE(untag_ptr(_res));
22376         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
22377 }
22378
22379 static inline uint64_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
22380         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
22381         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
22382         return tag_ptr(ret_conv, true);
22383 }
22384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22385         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(arg);
22386         int64_t ret_conv = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
22387         return ret_conv;
22388 }
22389
22390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22391         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(orig);
22392         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
22393         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
22394         return tag_ptr(ret_conv, true);
22395 }
22396
22397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22398         LDKWarningMessage o_conv;
22399         o_conv.inner = untag_ptr(o);
22400         o_conv.is_owned = ptr_is_owned(o);
22401         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22402         o_conv = WarningMessage_clone(&o_conv);
22403         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
22404         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
22405         return tag_ptr(ret_conv, true);
22406 }
22407
22408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22409         LDKDecodeError e_conv;
22410         e_conv.inner = untag_ptr(e);
22411         e_conv.is_owned = ptr_is_owned(e);
22412         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22413         e_conv = DecodeError_clone(&e_conv);
22414         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
22415         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
22416         return tag_ptr(ret_conv, true);
22417 }
22418
22419 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22420         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(o);
22421         jboolean ret_conv = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
22422         return ret_conv;
22423 }
22424
22425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22426         if (!ptr_is_owned(_res)) return;
22427         void* _res_ptr = untag_ptr(_res);
22428         CHECK_ACCESS(_res_ptr);
22429         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
22430         FREE(untag_ptr(_res));
22431         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
22432 }
22433
22434 static inline uint64_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
22435         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
22436         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
22437         return tag_ptr(ret_conv, true);
22438 }
22439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22440         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(arg);
22441         int64_t ret_conv = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
22442         return ret_conv;
22443 }
22444
22445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22446         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(orig);
22447         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
22448         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
22449         return tag_ptr(ret_conv, true);
22450 }
22451
22452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22453         LDKUnsignedNodeAnnouncement o_conv;
22454         o_conv.inner = untag_ptr(o);
22455         o_conv.is_owned = ptr_is_owned(o);
22456         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22457         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
22458         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
22459         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
22460         return tag_ptr(ret_conv, true);
22461 }
22462
22463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22464         LDKDecodeError e_conv;
22465         e_conv.inner = untag_ptr(e);
22466         e_conv.is_owned = ptr_is_owned(e);
22467         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22468         e_conv = DecodeError_clone(&e_conv);
22469         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
22470         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
22471         return tag_ptr(ret_conv, true);
22472 }
22473
22474 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22475         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(o);
22476         jboolean ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
22477         return ret_conv;
22478 }
22479
22480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22481         if (!ptr_is_owned(_res)) return;
22482         void* _res_ptr = untag_ptr(_res);
22483         CHECK_ACCESS(_res_ptr);
22484         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
22485         FREE(untag_ptr(_res));
22486         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
22487 }
22488
22489 static inline uint64_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
22490         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
22491         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
22492         return tag_ptr(ret_conv, true);
22493 }
22494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22495         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(arg);
22496         int64_t ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
22497         return ret_conv;
22498 }
22499
22500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22501         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(orig);
22502         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
22503         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
22504         return tag_ptr(ret_conv, true);
22505 }
22506
22507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22508         LDKNodeAnnouncement o_conv;
22509         o_conv.inner = untag_ptr(o);
22510         o_conv.is_owned = ptr_is_owned(o);
22511         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22512         o_conv = NodeAnnouncement_clone(&o_conv);
22513         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
22514         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
22515         return tag_ptr(ret_conv, true);
22516 }
22517
22518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22519         LDKDecodeError e_conv;
22520         e_conv.inner = untag_ptr(e);
22521         e_conv.is_owned = ptr_is_owned(e);
22522         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22523         e_conv = DecodeError_clone(&e_conv);
22524         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
22525         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
22526         return tag_ptr(ret_conv, true);
22527 }
22528
22529 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22530         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(o);
22531         jboolean ret_conv = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
22532         return ret_conv;
22533 }
22534
22535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22536         if (!ptr_is_owned(_res)) return;
22537         void* _res_ptr = untag_ptr(_res);
22538         CHECK_ACCESS(_res_ptr);
22539         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
22540         FREE(untag_ptr(_res));
22541         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
22542 }
22543
22544 static inline uint64_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
22545         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
22546         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
22547         return tag_ptr(ret_conv, true);
22548 }
22549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22550         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(arg);
22551         int64_t ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
22552         return ret_conv;
22553 }
22554
22555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22556         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(orig);
22557         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
22558         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
22559         return tag_ptr(ret_conv, true);
22560 }
22561
22562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22563         LDKQueryShortChannelIds o_conv;
22564         o_conv.inner = untag_ptr(o);
22565         o_conv.is_owned = ptr_is_owned(o);
22566         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22567         o_conv = QueryShortChannelIds_clone(&o_conv);
22568         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
22569         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
22570         return tag_ptr(ret_conv, true);
22571 }
22572
22573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22574         LDKDecodeError e_conv;
22575         e_conv.inner = untag_ptr(e);
22576         e_conv.is_owned = ptr_is_owned(e);
22577         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22578         e_conv = DecodeError_clone(&e_conv);
22579         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
22580         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
22581         return tag_ptr(ret_conv, true);
22582 }
22583
22584 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22585         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(o);
22586         jboolean ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
22587         return ret_conv;
22588 }
22589
22590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22591         if (!ptr_is_owned(_res)) return;
22592         void* _res_ptr = untag_ptr(_res);
22593         CHECK_ACCESS(_res_ptr);
22594         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
22595         FREE(untag_ptr(_res));
22596         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
22597 }
22598
22599 static inline uint64_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
22600         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
22601         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
22602         return tag_ptr(ret_conv, true);
22603 }
22604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22605         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(arg);
22606         int64_t ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
22607         return ret_conv;
22608 }
22609
22610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22611         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(orig);
22612         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
22613         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
22614         return tag_ptr(ret_conv, true);
22615 }
22616
22617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22618         LDKReplyShortChannelIdsEnd o_conv;
22619         o_conv.inner = untag_ptr(o);
22620         o_conv.is_owned = ptr_is_owned(o);
22621         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22622         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
22623         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
22624         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
22625         return tag_ptr(ret_conv, true);
22626 }
22627
22628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22629         LDKDecodeError e_conv;
22630         e_conv.inner = untag_ptr(e);
22631         e_conv.is_owned = ptr_is_owned(e);
22632         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22633         e_conv = DecodeError_clone(&e_conv);
22634         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
22635         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
22636         return tag_ptr(ret_conv, true);
22637 }
22638
22639 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22640         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(o);
22641         jboolean ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
22642         return ret_conv;
22643 }
22644
22645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22646         if (!ptr_is_owned(_res)) return;
22647         void* _res_ptr = untag_ptr(_res);
22648         CHECK_ACCESS(_res_ptr);
22649         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
22650         FREE(untag_ptr(_res));
22651         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
22652 }
22653
22654 static inline uint64_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
22655         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
22656         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
22657         return tag_ptr(ret_conv, true);
22658 }
22659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22660         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(arg);
22661         int64_t ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
22662         return ret_conv;
22663 }
22664
22665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22666         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(orig);
22667         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
22668         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
22669         return tag_ptr(ret_conv, true);
22670 }
22671
22672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22673         LDKQueryChannelRange o_conv;
22674         o_conv.inner = untag_ptr(o);
22675         o_conv.is_owned = ptr_is_owned(o);
22676         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22677         o_conv = QueryChannelRange_clone(&o_conv);
22678         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
22679         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
22680         return tag_ptr(ret_conv, true);
22681 }
22682
22683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22684         LDKDecodeError e_conv;
22685         e_conv.inner = untag_ptr(e);
22686         e_conv.is_owned = ptr_is_owned(e);
22687         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22688         e_conv = DecodeError_clone(&e_conv);
22689         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
22690         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
22691         return tag_ptr(ret_conv, true);
22692 }
22693
22694 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22695         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(o);
22696         jboolean ret_conv = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
22697         return ret_conv;
22698 }
22699
22700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22701         if (!ptr_is_owned(_res)) return;
22702         void* _res_ptr = untag_ptr(_res);
22703         CHECK_ACCESS(_res_ptr);
22704         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
22705         FREE(untag_ptr(_res));
22706         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
22707 }
22708
22709 static inline uint64_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
22710         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
22711         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
22712         return tag_ptr(ret_conv, true);
22713 }
22714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22715         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(arg);
22716         int64_t ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
22717         return ret_conv;
22718 }
22719
22720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22721         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(orig);
22722         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
22723         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
22724         return tag_ptr(ret_conv, true);
22725 }
22726
22727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22728         LDKReplyChannelRange o_conv;
22729         o_conv.inner = untag_ptr(o);
22730         o_conv.is_owned = ptr_is_owned(o);
22731         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22732         o_conv = ReplyChannelRange_clone(&o_conv);
22733         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
22734         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
22735         return tag_ptr(ret_conv, true);
22736 }
22737
22738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22739         LDKDecodeError e_conv;
22740         e_conv.inner = untag_ptr(e);
22741         e_conv.is_owned = ptr_is_owned(e);
22742         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22743         e_conv = DecodeError_clone(&e_conv);
22744         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
22745         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
22746         return tag_ptr(ret_conv, true);
22747 }
22748
22749 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22750         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(o);
22751         jboolean ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
22752         return ret_conv;
22753 }
22754
22755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22756         if (!ptr_is_owned(_res)) return;
22757         void* _res_ptr = untag_ptr(_res);
22758         CHECK_ACCESS(_res_ptr);
22759         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
22760         FREE(untag_ptr(_res));
22761         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
22762 }
22763
22764 static inline uint64_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
22765         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
22766         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
22767         return tag_ptr(ret_conv, true);
22768 }
22769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22770         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(arg);
22771         int64_t ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
22772         return ret_conv;
22773 }
22774
22775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22776         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(orig);
22777         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
22778         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
22779         return tag_ptr(ret_conv, true);
22780 }
22781
22782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22783         LDKGossipTimestampFilter o_conv;
22784         o_conv.inner = untag_ptr(o);
22785         o_conv.is_owned = ptr_is_owned(o);
22786         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22787         o_conv = GossipTimestampFilter_clone(&o_conv);
22788         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
22789         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
22790         return tag_ptr(ret_conv, true);
22791 }
22792
22793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22794         LDKDecodeError e_conv;
22795         e_conv.inner = untag_ptr(e);
22796         e_conv.is_owned = ptr_is_owned(e);
22797         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22798         e_conv = DecodeError_clone(&e_conv);
22799         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
22800         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
22801         return tag_ptr(ret_conv, true);
22802 }
22803
22804 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22805         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(o);
22806         jboolean ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
22807         return ret_conv;
22808 }
22809
22810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22811         if (!ptr_is_owned(_res)) return;
22812         void* _res_ptr = untag_ptr(_res);
22813         CHECK_ACCESS(_res_ptr);
22814         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
22815         FREE(untag_ptr(_res));
22816         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
22817 }
22818
22819 static inline uint64_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
22820         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
22821         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
22822         return tag_ptr(ret_conv, true);
22823 }
22824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22825         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(arg);
22826         int64_t ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
22827         return ret_conv;
22828 }
22829
22830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22831         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(orig);
22832         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
22833         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
22834         return tag_ptr(ret_conv, true);
22835 }
22836
22837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PhantomRouteHintsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22838         LDKCVec_PhantomRouteHintsZ _res_constr;
22839         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22840         if (_res_constr.datalen > 0)
22841                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
22842         else
22843                 _res_constr.data = NULL;
22844         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22845         for (size_t t = 0; t < _res_constr.datalen; t++) {
22846                 int64_t _res_conv_19 = _res_vals[t];
22847                 LDKPhantomRouteHints _res_conv_19_conv;
22848                 _res_conv_19_conv.inner = untag_ptr(_res_conv_19);
22849                 _res_conv_19_conv.is_owned = ptr_is_owned(_res_conv_19);
22850                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
22851                 _res_constr.data[t] = _res_conv_19_conv;
22852         }
22853         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22854         CVec_PhantomRouteHintsZ_free(_res_constr);
22855 }
22856
22857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22858         LDKInvoice o_conv;
22859         o_conv.inner = untag_ptr(o);
22860         o_conv.is_owned = ptr_is_owned(o);
22861         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22862         o_conv = Invoice_clone(&o_conv);
22863         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
22864         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
22865         return tag_ptr(ret_conv, true);
22866 }
22867
22868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22869         void* e_ptr = untag_ptr(e);
22870         CHECK_ACCESS(e_ptr);
22871         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
22872         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)untag_ptr(e));
22873         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
22874         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
22875         return tag_ptr(ret_conv, true);
22876 }
22877
22878 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22879         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(o);
22880         jboolean ret_conv = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
22881         return ret_conv;
22882 }
22883
22884 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22885         if (!ptr_is_owned(_res)) return;
22886         void* _res_ptr = untag_ptr(_res);
22887         CHECK_ACCESS(_res_ptr);
22888         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
22889         FREE(untag_ptr(_res));
22890         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
22891 }
22892
22893 static inline uint64_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
22894         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
22895         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
22896         return tag_ptr(ret_conv, true);
22897 }
22898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22899         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(arg);
22900         int64_t ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
22901         return ret_conv;
22902 }
22903
22904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22905         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(orig);
22906         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
22907         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
22908         return tag_ptr(ret_conv, true);
22909 }
22910
22911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) {
22912         void* o_ptr = untag_ptr(o);
22913         CHECK_ACCESS(o_ptr);
22914         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
22915         if (o_conv.free == LDKFilter_JCalls_free) {
22916                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22917                 LDKFilter_JCalls_cloned(&o_conv);
22918         }
22919         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
22920         *ret_copy = COption_FilterZ_some(o_conv);
22921         int64_t ret_ref = tag_ptr(ret_copy, true);
22922         return ret_ref;
22923 }
22924
22925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) {
22926         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
22927         *ret_copy = COption_FilterZ_none();
22928         int64_t ret_ref = tag_ptr(ret_copy, true);
22929         return ret_ref;
22930 }
22931
22932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22933         if (!ptr_is_owned(_res)) return;
22934         void* _res_ptr = untag_ptr(_res);
22935         CHECK_ACCESS(_res_ptr);
22936         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
22937         FREE(untag_ptr(_res));
22938         COption_FilterZ_free(_res_conv);
22939 }
22940
22941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22942         LDKLockedChannelMonitor o_conv;
22943         o_conv.inner = untag_ptr(o);
22944         o_conv.is_owned = ptr_is_owned(o);
22945         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22946         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
22947         
22948         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
22949         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
22950         return tag_ptr(ret_conv, true);
22951 }
22952
22953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1err(JNIEnv *env, jclass clz) {
22954         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
22955         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
22956         return tag_ptr(ret_conv, true);
22957 }
22958
22959 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22960         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(o);
22961         jboolean ret_conv = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
22962         return ret_conv;
22963 }
22964
22965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22966         if (!ptr_is_owned(_res)) return;
22967         void* _res_ptr = untag_ptr(_res);
22968         CHECK_ACCESS(_res_ptr);
22969         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
22970         FREE(untag_ptr(_res));
22971         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
22972 }
22973
22974 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1OutPointZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22975         LDKCVec_OutPointZ _res_constr;
22976         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22977         if (_res_constr.datalen > 0)
22978                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
22979         else
22980                 _res_constr.data = NULL;
22981         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22982         for (size_t k = 0; k < _res_constr.datalen; k++) {
22983                 int64_t _res_conv_10 = _res_vals[k];
22984                 LDKOutPoint _res_conv_10_conv;
22985                 _res_conv_10_conv.inner = untag_ptr(_res_conv_10);
22986                 _res_conv_10_conv.is_owned = ptr_is_owned(_res_conv_10);
22987                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
22988                 _res_constr.data[k] = _res_conv_10_conv;
22989         }
22990         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22991         CVec_OutPointZ_free(_res_constr);
22992 }
22993
22994 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
22995         if (!ptr_is_owned(this_ptr)) return;
22996         void* this_ptr_ptr = untag_ptr(this_ptr);
22997         CHECK_ACCESS(this_ptr_ptr);
22998         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
22999         FREE(untag_ptr(this_ptr));
23000         PaymentPurpose_free(this_ptr_conv);
23001 }
23002
23003 static inline uint64_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
23004         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
23005         *ret_copy = PaymentPurpose_clone(arg);
23006         int64_t ret_ref = tag_ptr(ret_copy, true);
23007         return ret_ref;
23008 }
23009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23010         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)untag_ptr(arg);
23011         int64_t ret_conv = PaymentPurpose_clone_ptr(arg_conv);
23012         return ret_conv;
23013 }
23014
23015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23016         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)untag_ptr(orig);
23017         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
23018         *ret_copy = PaymentPurpose_clone(orig_conv);
23019         int64_t ret_ref = tag_ptr(ret_copy, true);
23020         return ret_ref;
23021 }
23022
23023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1invoice_1payment(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_secret) {
23024         LDKThirtyTwoBytes payment_preimage_ref;
23025         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
23026         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
23027         LDKThirtyTwoBytes payment_secret_ref;
23028         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
23029         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
23030         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
23031         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
23032         int64_t ret_ref = tag_ptr(ret_copy, true);
23033         return ret_ref;
23034 }
23035
23036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
23037         LDKThirtyTwoBytes a_ref;
23038         CHECK((*env)->GetArrayLength(env, a) == 32);
23039         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
23040         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
23041         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
23042         int64_t ret_ref = tag_ptr(ret_copy, true);
23043         return ret_ref;
23044 }
23045
23046 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1write(JNIEnv *env, jclass clz, int64_t obj) {
23047         LDKPaymentPurpose* obj_conv = (LDKPaymentPurpose*)untag_ptr(obj);
23048         LDKCVec_u8Z ret_var = PaymentPurpose_write(obj_conv);
23049         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23050         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23051         CVec_u8Z_free(ret_var);
23052         return ret_arr;
23053 }
23054
23055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23056         LDKu8slice ser_ref;
23057         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23058         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23059         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
23060         *ret_conv = PaymentPurpose_read(ser_ref);
23061         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23062         return tag_ptr(ret_conv, true);
23063 }
23064
23065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23066         if (!ptr_is_owned(this_ptr)) return;
23067         void* this_ptr_ptr = untag_ptr(this_ptr);
23068         CHECK_ACCESS(this_ptr_ptr);
23069         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
23070         FREE(untag_ptr(this_ptr));
23071         ClosureReason_free(this_ptr_conv);
23072 }
23073
23074 static inline uint64_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
23075         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23076         *ret_copy = ClosureReason_clone(arg);
23077         int64_t ret_ref = tag_ptr(ret_copy, true);
23078         return ret_ref;
23079 }
23080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23081         LDKClosureReason* arg_conv = (LDKClosureReason*)untag_ptr(arg);
23082         int64_t ret_conv = ClosureReason_clone_ptr(arg_conv);
23083         return ret_conv;
23084 }
23085
23086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23087         LDKClosureReason* orig_conv = (LDKClosureReason*)untag_ptr(orig);
23088         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23089         *ret_copy = ClosureReason_clone(orig_conv);
23090         int64_t ret_ref = tag_ptr(ret_copy, true);
23091         return ret_ref;
23092 }
23093
23094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, jstring peer_msg) {
23095         LDKStr peer_msg_conv = java_to_owned_str(env, peer_msg);
23096         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23097         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
23098         int64_t ret_ref = tag_ptr(ret_copy, true);
23099         return ret_ref;
23100 }
23101
23102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) {
23103         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23104         *ret_copy = ClosureReason_holder_force_closed();
23105         int64_t ret_ref = tag_ptr(ret_copy, true);
23106         return ret_ref;
23107 }
23108
23109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) {
23110         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23111         *ret_copy = ClosureReason_cooperative_closure();
23112         int64_t ret_ref = tag_ptr(ret_copy, true);
23113         return ret_ref;
23114 }
23115
23116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) {
23117         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23118         *ret_copy = ClosureReason_commitment_tx_confirmed();
23119         int64_t ret_ref = tag_ptr(ret_copy, true);
23120         return ret_ref;
23121 }
23122
23123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1funding_1timed_1out(JNIEnv *env, jclass clz) {
23124         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23125         *ret_copy = ClosureReason_funding_timed_out();
23126         int64_t ret_ref = tag_ptr(ret_copy, true);
23127         return ret_ref;
23128 }
23129
23130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) {
23131         LDKStr err_conv = java_to_owned_str(env, err);
23132         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23133         *ret_copy = ClosureReason_processing_error(err_conv);
23134         int64_t ret_ref = tag_ptr(ret_copy, true);
23135         return ret_ref;
23136 }
23137
23138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) {
23139         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23140         *ret_copy = ClosureReason_disconnected_peer();
23141         int64_t ret_ref = tag_ptr(ret_copy, true);
23142         return ret_ref;
23143 }
23144
23145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) {
23146         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23147         *ret_copy = ClosureReason_outdated_channel_manager();
23148         int64_t ret_ref = tag_ptr(ret_copy, true);
23149         return ret_ref;
23150 }
23151
23152 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
23153         LDKClosureReason* obj_conv = (LDKClosureReason*)untag_ptr(obj);
23154         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
23155         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23156         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23157         CVec_u8Z_free(ret_var);
23158         return ret_arr;
23159 }
23160
23161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23162         LDKu8slice ser_ref;
23163         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23164         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23165         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
23166         *ret_conv = ClosureReason_read(ser_ref);
23167         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23168         return tag_ptr(ret_conv, true);
23169 }
23170
23171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23172         if (!ptr_is_owned(this_ptr)) return;
23173         void* this_ptr_ptr = untag_ptr(this_ptr);
23174         CHECK_ACCESS(this_ptr_ptr);
23175         LDKHTLCDestination this_ptr_conv = *(LDKHTLCDestination*)(this_ptr_ptr);
23176         FREE(untag_ptr(this_ptr));
23177         HTLCDestination_free(this_ptr_conv);
23178 }
23179
23180 static inline uint64_t HTLCDestination_clone_ptr(LDKHTLCDestination *NONNULL_PTR arg) {
23181         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
23182         *ret_copy = HTLCDestination_clone(arg);
23183         int64_t ret_ref = tag_ptr(ret_copy, true);
23184         return ret_ref;
23185 }
23186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23187         LDKHTLCDestination* arg_conv = (LDKHTLCDestination*)untag_ptr(arg);
23188         int64_t ret_conv = HTLCDestination_clone_ptr(arg_conv);
23189         return ret_conv;
23190 }
23191
23192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23193         LDKHTLCDestination* orig_conv = (LDKHTLCDestination*)untag_ptr(orig);
23194         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
23195         *ret_copy = HTLCDestination_clone(orig_conv);
23196         int64_t ret_ref = tag_ptr(ret_copy, true);
23197         return ret_ref;
23198 }
23199
23200 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) {
23201         LDKPublicKey node_id_ref;
23202         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23203         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23204         LDKThirtyTwoBytes channel_id_ref;
23205         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
23206         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
23207         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
23208         *ret_copy = HTLCDestination_next_hop_channel(node_id_ref, channel_id_ref);
23209         int64_t ret_ref = tag_ptr(ret_copy, true);
23210         return ret_ref;
23211 }
23212
23213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1unknown_1next_1hop(JNIEnv *env, jclass clz, int64_t requested_forward_scid) {
23214         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
23215         *ret_copy = HTLCDestination_unknown_next_hop(requested_forward_scid);
23216         int64_t ret_ref = tag_ptr(ret_copy, true);
23217         return ret_ref;
23218 }
23219
23220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1failed_1payment(JNIEnv *env, jclass clz, int8_tArray payment_hash) {
23221         LDKThirtyTwoBytes payment_hash_ref;
23222         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
23223         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23224         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
23225         *ret_copy = HTLCDestination_failed_payment(payment_hash_ref);
23226         int64_t ret_ref = tag_ptr(ret_copy, true);
23227         return ret_ref;
23228 }
23229
23230 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1write(JNIEnv *env, jclass clz, int64_t obj) {
23231         LDKHTLCDestination* obj_conv = (LDKHTLCDestination*)untag_ptr(obj);
23232         LDKCVec_u8Z ret_var = HTLCDestination_write(obj_conv);
23233         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23234         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23235         CVec_u8Z_free(ret_var);
23236         return ret_arr;
23237 }
23238
23239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23240         LDKu8slice ser_ref;
23241         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23242         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23243         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
23244         *ret_conv = HTLCDestination_read(ser_ref);
23245         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23246         return tag_ptr(ret_conv, true);
23247 }
23248
23249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23250         if (!ptr_is_owned(this_ptr)) return;
23251         void* this_ptr_ptr = untag_ptr(this_ptr);
23252         CHECK_ACCESS(this_ptr_ptr);
23253         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
23254         FREE(untag_ptr(this_ptr));
23255         Event_free(this_ptr_conv);
23256 }
23257
23258 static inline uint64_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
23259         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23260         *ret_copy = Event_clone(arg);
23261         int64_t ret_ref = tag_ptr(ret_copy, true);
23262         return ret_ref;
23263 }
23264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23265         LDKEvent* arg_conv = (LDKEvent*)untag_ptr(arg);
23266         int64_t ret_conv = Event_clone_ptr(arg_conv);
23267         return ret_conv;
23268 }
23269
23270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23271         LDKEvent* orig_conv = (LDKEvent*)untag_ptr(orig);
23272         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23273         *ret_copy = Event_clone(orig_conv);
23274         int64_t ret_ref = tag_ptr(ret_copy, true);
23275         return ret_ref;
23276 }
23277
23278 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) {
23279         LDKThirtyTwoBytes temporary_channel_id_ref;
23280         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
23281         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
23282         LDKPublicKey counterparty_node_id_ref;
23283         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
23284         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
23285         LDKCVec_u8Z output_script_ref;
23286         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
23287         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
23288         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
23289         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23290         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, counterparty_node_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
23291         int64_t ret_ref = tag_ptr(ret_copy, true);
23292         return ret_ref;
23293 }
23294
23295 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) {
23296         LDKThirtyTwoBytes payment_hash_ref;
23297         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
23298         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23299         void* purpose_ptr = untag_ptr(purpose);
23300         CHECK_ACCESS(purpose_ptr);
23301         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
23302         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(purpose));
23303         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23304         *ret_copy = Event_payment_received(payment_hash_ref, amount_msat, purpose_conv);
23305         int64_t ret_ref = tag_ptr(ret_copy, true);
23306         return ret_ref;
23307 }
23308
23309 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) {
23310         LDKThirtyTwoBytes payment_hash_ref;
23311         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
23312         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23313         void* purpose_ptr = untag_ptr(purpose);
23314         CHECK_ACCESS(purpose_ptr);
23315         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
23316         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(purpose));
23317         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23318         *ret_copy = Event_payment_claimed(payment_hash_ref, amount_msat, purpose_conv);
23319         int64_t ret_ref = tag_ptr(ret_copy, true);
23320         return ret_ref;
23321 }
23322
23323 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) {
23324         LDKThirtyTwoBytes payment_id_ref;
23325         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
23326         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
23327         LDKThirtyTwoBytes payment_preimage_ref;
23328         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
23329         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
23330         LDKThirtyTwoBytes payment_hash_ref;
23331         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
23332         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23333         void* fee_paid_msat_ptr = untag_ptr(fee_paid_msat);
23334         CHECK_ACCESS(fee_paid_msat_ptr);
23335         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
23336         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(fee_paid_msat));
23337         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23338         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
23339         int64_t ret_ref = tag_ptr(ret_copy, true);
23340         return ret_ref;
23341 }
23342
23343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash) {
23344         LDKThirtyTwoBytes payment_id_ref;
23345         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
23346         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
23347         LDKThirtyTwoBytes payment_hash_ref;
23348         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
23349         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23350         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23351         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
23352         int64_t ret_ref = tag_ptr(ret_copy, true);
23353         return ret_ref;
23354 }
23355
23356 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) {
23357         LDKThirtyTwoBytes payment_id_ref;
23358         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
23359         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
23360         LDKThirtyTwoBytes payment_hash_ref;
23361         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
23362         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23363         LDKCVec_RouteHopZ path_constr;
23364         path_constr.datalen = (*env)->GetArrayLength(env, path);
23365         if (path_constr.datalen > 0)
23366                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
23367         else
23368                 path_constr.data = NULL;
23369         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
23370         for (size_t k = 0; k < path_constr.datalen; k++) {
23371                 int64_t path_conv_10 = path_vals[k];
23372                 LDKRouteHop path_conv_10_conv;
23373                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
23374                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
23375                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
23376                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
23377                 path_constr.data[k] = path_conv_10_conv;
23378         }
23379         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
23380         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23381         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
23382         int64_t ret_ref = tag_ptr(ret_copy, true);
23383         return ret_ref;
23384 }
23385
23386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1path_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash, jboolean rejected_by_dest, int64_t network_update, jboolean all_paths_failed, int64_tArray path, int64_t short_channel_id, int64_t retry) {
23387         LDKThirtyTwoBytes payment_id_ref;
23388         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
23389         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
23390         LDKThirtyTwoBytes payment_hash_ref;
23391         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
23392         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23393         void* network_update_ptr = untag_ptr(network_update);
23394         CHECK_ACCESS(network_update_ptr);
23395         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
23396         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)untag_ptr(network_update));
23397         LDKCVec_RouteHopZ path_constr;
23398         path_constr.datalen = (*env)->GetArrayLength(env, path);
23399         if (path_constr.datalen > 0)
23400                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
23401         else
23402                 path_constr.data = NULL;
23403         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
23404         for (size_t k = 0; k < path_constr.datalen; k++) {
23405                 int64_t path_conv_10 = path_vals[k];
23406                 LDKRouteHop path_conv_10_conv;
23407                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
23408                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
23409                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
23410                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
23411                 path_constr.data[k] = path_conv_10_conv;
23412         }
23413         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
23414         void* short_channel_id_ptr = untag_ptr(short_channel_id);
23415         CHECK_ACCESS(short_channel_id_ptr);
23416         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
23417         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id));
23418         LDKRouteParameters retry_conv;
23419         retry_conv.inner = untag_ptr(retry);
23420         retry_conv.is_owned = ptr_is_owned(retry);
23421         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
23422         retry_conv = RouteParameters_clone(&retry_conv);
23423         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23424         *ret_copy = Event_payment_path_failed(payment_id_ref, payment_hash_ref, rejected_by_dest, network_update_conv, all_paths_failed, path_constr, short_channel_id_conv, retry_conv);
23425         int64_t ret_ref = tag_ptr(ret_copy, true);
23426         return ret_ref;
23427 }
23428
23429 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) {
23430         LDKThirtyTwoBytes payment_id_ref;
23431         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
23432         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
23433         LDKThirtyTwoBytes payment_hash_ref;
23434         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
23435         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23436         LDKCVec_RouteHopZ path_constr;
23437         path_constr.datalen = (*env)->GetArrayLength(env, path);
23438         if (path_constr.datalen > 0)
23439                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
23440         else
23441                 path_constr.data = NULL;
23442         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
23443         for (size_t k = 0; k < path_constr.datalen; k++) {
23444                 int64_t path_conv_10 = path_vals[k];
23445                 LDKRouteHop path_conv_10_conv;
23446                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
23447                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
23448                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
23449                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
23450                 path_constr.data[k] = path_conv_10_conv;
23451         }
23452         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
23453         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23454         *ret_copy = Event_probe_successful(payment_id_ref, payment_hash_ref, path_constr);
23455         int64_t ret_ref = tag_ptr(ret_copy, true);
23456         return ret_ref;
23457 }
23458
23459 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) {
23460         LDKThirtyTwoBytes payment_id_ref;
23461         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
23462         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
23463         LDKThirtyTwoBytes payment_hash_ref;
23464         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
23465         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23466         LDKCVec_RouteHopZ path_constr;
23467         path_constr.datalen = (*env)->GetArrayLength(env, path);
23468         if (path_constr.datalen > 0)
23469                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
23470         else
23471                 path_constr.data = NULL;
23472         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
23473         for (size_t k = 0; k < path_constr.datalen; k++) {
23474                 int64_t path_conv_10 = path_vals[k];
23475                 LDKRouteHop path_conv_10_conv;
23476                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
23477                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
23478                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
23479                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
23480                 path_constr.data[k] = path_conv_10_conv;
23481         }
23482         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
23483         void* short_channel_id_ptr = untag_ptr(short_channel_id);
23484         CHECK_ACCESS(short_channel_id_ptr);
23485         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
23486         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id));
23487         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23488         *ret_copy = Event_probe_failed(payment_id_ref, payment_hash_ref, path_constr, short_channel_id_conv);
23489         int64_t ret_ref = tag_ptr(ret_copy, true);
23490         return ret_ref;
23491 }
23492
23493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
23494         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23495         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
23496         int64_t ret_ref = tag_ptr(ret_copy, true);
23497         return ret_ref;
23498 }
23499
23500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
23501         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
23502         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
23503         if (outputs_constr.datalen > 0)
23504                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
23505         else
23506                 outputs_constr.data = NULL;
23507         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
23508         for (size_t b = 0; b < outputs_constr.datalen; b++) {
23509                 int64_t outputs_conv_27 = outputs_vals[b];
23510                 void* outputs_conv_27_ptr = untag_ptr(outputs_conv_27);
23511                 CHECK_ACCESS(outputs_conv_27_ptr);
23512                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
23513                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(outputs_conv_27));
23514                 outputs_constr.data[b] = outputs_conv_27_conv;
23515         }
23516         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
23517         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23518         *ret_copy = Event_spendable_outputs(outputs_constr);
23519         int64_t ret_ref = tag_ptr(ret_copy, true);
23520         return ret_ref;
23521 }
23522
23523 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) {
23524         LDKThirtyTwoBytes prev_channel_id_ref;
23525         CHECK((*env)->GetArrayLength(env, prev_channel_id) == 32);
23526         (*env)->GetByteArrayRegion(env, prev_channel_id, 0, 32, prev_channel_id_ref.data);
23527         LDKThirtyTwoBytes next_channel_id_ref;
23528         CHECK((*env)->GetArrayLength(env, next_channel_id) == 32);
23529         (*env)->GetByteArrayRegion(env, next_channel_id, 0, 32, next_channel_id_ref.data);
23530         void* fee_earned_msat_ptr = untag_ptr(fee_earned_msat);
23531         CHECK_ACCESS(fee_earned_msat_ptr);
23532         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
23533         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(fee_earned_msat));
23534         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23535         *ret_copy = Event_payment_forwarded(prev_channel_id_ref, next_channel_id_ref, fee_earned_msat_conv, claim_from_onchain_tx);
23536         int64_t ret_ref = tag_ptr(ret_copy, true);
23537         return ret_ref;
23538 }
23539
23540 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) {
23541         LDKThirtyTwoBytes channel_id_ref;
23542         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
23543         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
23544         void* reason_ptr = untag_ptr(reason);
23545         CHECK_ACCESS(reason_ptr);
23546         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
23547         reason_conv = ClosureReason_clone((LDKClosureReason*)untag_ptr(reason));
23548         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23549         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
23550         int64_t ret_ref = tag_ptr(ret_copy, true);
23551         return ret_ref;
23552 }
23553
23554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1discard_1funding(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray transaction) {
23555         LDKThirtyTwoBytes channel_id_ref;
23556         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
23557         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
23558         LDKTransaction transaction_ref;
23559         transaction_ref.datalen = (*env)->GetArrayLength(env, transaction);
23560         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
23561         (*env)->GetByteArrayRegion(env, transaction, 0, transaction_ref.datalen, transaction_ref.data);
23562         transaction_ref.data_is_owned = true;
23563         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23564         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
23565         int64_t ret_ref = tag_ptr(ret_copy, true);
23566         return ret_ref;
23567 }
23568
23569 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) {
23570         LDKThirtyTwoBytes temporary_channel_id_ref;
23571         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
23572         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
23573         LDKPublicKey counterparty_node_id_ref;
23574         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
23575         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
23576         LDKChannelTypeFeatures channel_type_conv;
23577         channel_type_conv.inner = untag_ptr(channel_type);
23578         channel_type_conv.is_owned = ptr_is_owned(channel_type);
23579         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
23580         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
23581         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23582         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
23583         int64_t ret_ref = tag_ptr(ret_copy, true);
23584         return ret_ref;
23585 }
23586
23587 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) {
23588         LDKThirtyTwoBytes prev_channel_id_ref;
23589         CHECK((*env)->GetArrayLength(env, prev_channel_id) == 32);
23590         (*env)->GetByteArrayRegion(env, prev_channel_id, 0, 32, prev_channel_id_ref.data);
23591         void* failed_next_destination_ptr = untag_ptr(failed_next_destination);
23592         CHECK_ACCESS(failed_next_destination_ptr);
23593         LDKHTLCDestination failed_next_destination_conv = *(LDKHTLCDestination*)(failed_next_destination_ptr);
23594         failed_next_destination_conv = HTLCDestination_clone((LDKHTLCDestination*)untag_ptr(failed_next_destination));
23595         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23596         *ret_copy = Event_htlchandling_failed(prev_channel_id_ref, failed_next_destination_conv);
23597         int64_t ret_ref = tag_ptr(ret_copy, true);
23598         return ret_ref;
23599 }
23600
23601 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
23602         LDKEvent* obj_conv = (LDKEvent*)untag_ptr(obj);
23603         LDKCVec_u8Z ret_var = Event_write(obj_conv);
23604         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23605         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23606         CVec_u8Z_free(ret_var);
23607         return ret_arr;
23608 }
23609
23610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23611         LDKu8slice ser_ref;
23612         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23613         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23614         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
23615         *ret_conv = Event_read(ser_ref);
23616         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23617         return tag_ptr(ret_conv, true);
23618 }
23619
23620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23621         if (!ptr_is_owned(this_ptr)) return;
23622         void* this_ptr_ptr = untag_ptr(this_ptr);
23623         CHECK_ACCESS(this_ptr_ptr);
23624         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
23625         FREE(untag_ptr(this_ptr));
23626         MessageSendEvent_free(this_ptr_conv);
23627 }
23628
23629 static inline uint64_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
23630         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23631         *ret_copy = MessageSendEvent_clone(arg);
23632         int64_t ret_ref = tag_ptr(ret_copy, true);
23633         return ret_ref;
23634 }
23635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23636         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)untag_ptr(arg);
23637         int64_t ret_conv = MessageSendEvent_clone_ptr(arg_conv);
23638         return ret_conv;
23639 }
23640
23641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23642         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)untag_ptr(orig);
23643         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23644         *ret_copy = MessageSendEvent_clone(orig_conv);
23645         int64_t ret_ref = tag_ptr(ret_copy, true);
23646         return ret_ref;
23647 }
23648
23649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23650         LDKPublicKey node_id_ref;
23651         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23652         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23653         LDKAcceptChannel msg_conv;
23654         msg_conv.inner = untag_ptr(msg);
23655         msg_conv.is_owned = ptr_is_owned(msg);
23656         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23657         msg_conv = AcceptChannel_clone(&msg_conv);
23658         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23659         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
23660         int64_t ret_ref = tag_ptr(ret_copy, true);
23661         return ret_ref;
23662 }
23663
23664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23665         LDKPublicKey node_id_ref;
23666         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23667         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23668         LDKOpenChannel msg_conv;
23669         msg_conv.inner = untag_ptr(msg);
23670         msg_conv.is_owned = ptr_is_owned(msg);
23671         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23672         msg_conv = OpenChannel_clone(&msg_conv);
23673         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23674         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
23675         int64_t ret_ref = tag_ptr(ret_copy, true);
23676         return ret_ref;
23677 }
23678
23679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23680         LDKPublicKey node_id_ref;
23681         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23682         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23683         LDKFundingCreated msg_conv;
23684         msg_conv.inner = untag_ptr(msg);
23685         msg_conv.is_owned = ptr_is_owned(msg);
23686         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23687         msg_conv = FundingCreated_clone(&msg_conv);
23688         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23689         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
23690         int64_t ret_ref = tag_ptr(ret_copy, true);
23691         return ret_ref;
23692 }
23693
23694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23695         LDKPublicKey node_id_ref;
23696         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23697         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23698         LDKFundingSigned msg_conv;
23699         msg_conv.inner = untag_ptr(msg);
23700         msg_conv.is_owned = ptr_is_owned(msg);
23701         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23702         msg_conv = FundingSigned_clone(&msg_conv);
23703         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23704         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
23705         int64_t ret_ref = tag_ptr(ret_copy, true);
23706         return ret_ref;
23707 }
23708
23709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1ready(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23710         LDKPublicKey node_id_ref;
23711         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23712         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23713         LDKChannelReady msg_conv;
23714         msg_conv.inner = untag_ptr(msg);
23715         msg_conv.is_owned = ptr_is_owned(msg);
23716         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23717         msg_conv = ChannelReady_clone(&msg_conv);
23718         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23719         *ret_copy = MessageSendEvent_send_channel_ready(node_id_ref, msg_conv);
23720         int64_t ret_ref = tag_ptr(ret_copy, true);
23721         return ret_ref;
23722 }
23723
23724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23725         LDKPublicKey node_id_ref;
23726         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23727         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23728         LDKAnnouncementSignatures msg_conv;
23729         msg_conv.inner = untag_ptr(msg);
23730         msg_conv.is_owned = ptr_is_owned(msg);
23731         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23732         msg_conv = AnnouncementSignatures_clone(&msg_conv);
23733         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23734         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
23735         int64_t ret_ref = tag_ptr(ret_copy, true);
23736         return ret_ref;
23737 }
23738
23739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
23740         LDKPublicKey node_id_ref;
23741         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23742         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23743         LDKCommitmentUpdate updates_conv;
23744         updates_conv.inner = untag_ptr(updates);
23745         updates_conv.is_owned = ptr_is_owned(updates);
23746         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
23747         updates_conv = CommitmentUpdate_clone(&updates_conv);
23748         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23749         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
23750         int64_t ret_ref = tag_ptr(ret_copy, true);
23751         return ret_ref;
23752 }
23753
23754 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) {
23755         LDKPublicKey node_id_ref;
23756         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23757         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23758         LDKRevokeAndACK msg_conv;
23759         msg_conv.inner = untag_ptr(msg);
23760         msg_conv.is_owned = ptr_is_owned(msg);
23761         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23762         msg_conv = RevokeAndACK_clone(&msg_conv);
23763         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23764         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
23765         int64_t ret_ref = tag_ptr(ret_copy, true);
23766         return ret_ref;
23767 }
23768
23769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23770         LDKPublicKey node_id_ref;
23771         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23772         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23773         LDKClosingSigned msg_conv;
23774         msg_conv.inner = untag_ptr(msg);
23775         msg_conv.is_owned = ptr_is_owned(msg);
23776         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23777         msg_conv = ClosingSigned_clone(&msg_conv);
23778         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23779         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
23780         int64_t ret_ref = tag_ptr(ret_copy, true);
23781         return ret_ref;
23782 }
23783
23784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23785         LDKPublicKey node_id_ref;
23786         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23787         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23788         LDKShutdown msg_conv;
23789         msg_conv.inner = untag_ptr(msg);
23790         msg_conv.is_owned = ptr_is_owned(msg);
23791         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23792         msg_conv = Shutdown_clone(&msg_conv);
23793         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23794         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
23795         int64_t ret_ref = tag_ptr(ret_copy, true);
23796         return ret_ref;
23797 }
23798
23799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23800         LDKPublicKey node_id_ref;
23801         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23802         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23803         LDKChannelReestablish msg_conv;
23804         msg_conv.inner = untag_ptr(msg);
23805         msg_conv.is_owned = ptr_is_owned(msg);
23806         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23807         msg_conv = ChannelReestablish_clone(&msg_conv);
23808         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23809         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
23810         int64_t ret_ref = tag_ptr(ret_copy, true);
23811         return ret_ref;
23812 }
23813
23814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
23815         LDKChannelAnnouncement msg_conv;
23816         msg_conv.inner = untag_ptr(msg);
23817         msg_conv.is_owned = ptr_is_owned(msg);
23818         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23819         msg_conv = ChannelAnnouncement_clone(&msg_conv);
23820         LDKChannelUpdate update_msg_conv;
23821         update_msg_conv.inner = untag_ptr(update_msg);
23822         update_msg_conv.is_owned = ptr_is_owned(update_msg);
23823         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
23824         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
23825         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23826         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
23827         int64_t ret_ref = tag_ptr(ret_copy, true);
23828         return ret_ref;
23829 }
23830
23831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t msg) {
23832         LDKNodeAnnouncement msg_conv;
23833         msg_conv.inner = untag_ptr(msg);
23834         msg_conv.is_owned = ptr_is_owned(msg);
23835         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23836         msg_conv = NodeAnnouncement_clone(&msg_conv);
23837         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23838         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
23839         int64_t ret_ref = tag_ptr(ret_copy, true);
23840         return ret_ref;
23841 }
23842
23843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
23844         LDKChannelUpdate msg_conv;
23845         msg_conv.inner = untag_ptr(msg);
23846         msg_conv.is_owned = ptr_is_owned(msg);
23847         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23848         msg_conv = ChannelUpdate_clone(&msg_conv);
23849         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23850         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
23851         int64_t ret_ref = tag_ptr(ret_copy, true);
23852         return ret_ref;
23853 }
23854
23855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23856         LDKPublicKey node_id_ref;
23857         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23858         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23859         LDKChannelUpdate msg_conv;
23860         msg_conv.inner = untag_ptr(msg);
23861         msg_conv.is_owned = ptr_is_owned(msg);
23862         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23863         msg_conv = ChannelUpdate_clone(&msg_conv);
23864         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23865         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
23866         int64_t ret_ref = tag_ptr(ret_copy, true);
23867         return ret_ref;
23868 }
23869
23870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
23871         LDKPublicKey node_id_ref;
23872         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23873         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23874         void* action_ptr = untag_ptr(action);
23875         CHECK_ACCESS(action_ptr);
23876         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
23877         action_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(action));
23878         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23879         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
23880         int64_t ret_ref = tag_ptr(ret_copy, true);
23881         return ret_ref;
23882 }
23883
23884 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) {
23885         LDKPublicKey node_id_ref;
23886         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23887         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23888         LDKQueryChannelRange msg_conv;
23889         msg_conv.inner = untag_ptr(msg);
23890         msg_conv.is_owned = ptr_is_owned(msg);
23891         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23892         msg_conv = QueryChannelRange_clone(&msg_conv);
23893         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23894         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
23895         int64_t ret_ref = tag_ptr(ret_copy, true);
23896         return ret_ref;
23897 }
23898
23899 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) {
23900         LDKPublicKey node_id_ref;
23901         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23902         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23903         LDKQueryShortChannelIds msg_conv;
23904         msg_conv.inner = untag_ptr(msg);
23905         msg_conv.is_owned = ptr_is_owned(msg);
23906         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23907         msg_conv = QueryShortChannelIds_clone(&msg_conv);
23908         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23909         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
23910         int64_t ret_ref = tag_ptr(ret_copy, true);
23911         return ret_ref;
23912 }
23913
23914 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) {
23915         LDKPublicKey node_id_ref;
23916         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23917         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23918         LDKReplyChannelRange msg_conv;
23919         msg_conv.inner = untag_ptr(msg);
23920         msg_conv.is_owned = ptr_is_owned(msg);
23921         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23922         msg_conv = ReplyChannelRange_clone(&msg_conv);
23923         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23924         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
23925         int64_t ret_ref = tag_ptr(ret_copy, true);
23926         return ret_ref;
23927 }
23928
23929 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) {
23930         LDKPublicKey node_id_ref;
23931         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23932         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23933         LDKGossipTimestampFilter msg_conv;
23934         msg_conv.inner = untag_ptr(msg);
23935         msg_conv.is_owned = ptr_is_owned(msg);
23936         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23937         msg_conv = GossipTimestampFilter_clone(&msg_conv);
23938         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23939         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
23940         int64_t ret_ref = tag_ptr(ret_copy, true);
23941         return ret_ref;
23942 }
23943
23944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23945         if (!ptr_is_owned(this_ptr)) return;
23946         void* this_ptr_ptr = untag_ptr(this_ptr);
23947         CHECK_ACCESS(this_ptr_ptr);
23948         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
23949         FREE(untag_ptr(this_ptr));
23950         MessageSendEventsProvider_free(this_ptr_conv);
23951 }
23952
23953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23954         if (!ptr_is_owned(this_ptr)) return;
23955         void* this_ptr_ptr = untag_ptr(this_ptr);
23956         CHECK_ACCESS(this_ptr_ptr);
23957         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
23958         FREE(untag_ptr(this_ptr));
23959         EventsProvider_free(this_ptr_conv);
23960 }
23961
23962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23963         if (!ptr_is_owned(this_ptr)) return;
23964         void* this_ptr_ptr = untag_ptr(this_ptr);
23965         CHECK_ACCESS(this_ptr_ptr);
23966         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
23967         FREE(untag_ptr(this_ptr));
23968         EventHandler_free(this_ptr_conv);
23969 }
23970
23971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23972         if (!ptr_is_owned(this_ptr)) return;
23973         void* this_ptr_ptr = untag_ptr(this_ptr);
23974         CHECK_ACCESS(this_ptr_ptr);
23975         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
23976         FREE(untag_ptr(this_ptr));
23977         APIError_free(this_ptr_conv);
23978 }
23979
23980 static inline uint64_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
23981         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23982         *ret_copy = APIError_clone(arg);
23983         int64_t ret_ref = tag_ptr(ret_copy, true);
23984         return ret_ref;
23985 }
23986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23987         LDKAPIError* arg_conv = (LDKAPIError*)untag_ptr(arg);
23988         int64_t ret_conv = APIError_clone_ptr(arg_conv);
23989         return ret_conv;
23990 }
23991
23992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23993         LDKAPIError* orig_conv = (LDKAPIError*)untag_ptr(orig);
23994         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23995         *ret_copy = APIError_clone(orig_conv);
23996         int64_t ret_ref = tag_ptr(ret_copy, true);
23997         return ret_ref;
23998 }
23999
24000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
24001         LDKStr err_conv = java_to_owned_str(env, err);
24002         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
24003         *ret_copy = APIError_apimisuse_error(err_conv);
24004         int64_t ret_ref = tag_ptr(ret_copy, true);
24005         return ret_ref;
24006 }
24007
24008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
24009         LDKStr err_conv = java_to_owned_str(env, err);
24010         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
24011         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
24012         int64_t ret_ref = tag_ptr(ret_copy, true);
24013         return ret_ref;
24014 }
24015
24016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1route_1error(JNIEnv *env, jclass clz, jstring err) {
24017         LDKStr err_conv = java_to_owned_str(env, err);
24018         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
24019         *ret_copy = APIError_route_error(err_conv);
24020         int64_t ret_ref = tag_ptr(ret_copy, true);
24021         return ret_ref;
24022 }
24023
24024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
24025         LDKStr err_conv = java_to_owned_str(env, err);
24026         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
24027         *ret_copy = APIError_channel_unavailable(err_conv);
24028         int64_t ret_ref = tag_ptr(ret_copy, true);
24029         return ret_ref;
24030 }
24031
24032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1failed(JNIEnv *env, jclass clz) {
24033         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
24034         *ret_copy = APIError_monitor_update_failed();
24035         int64_t ret_ref = tag_ptr(ret_copy, true);
24036         return ret_ref;
24037 }
24038
24039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
24040         LDKShutdownScript script_conv;
24041         script_conv.inner = untag_ptr(script);
24042         script_conv.is_owned = ptr_is_owned(script);
24043         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
24044         script_conv = ShutdownScript_clone(&script_conv);
24045         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
24046         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
24047         int64_t ret_ref = tag_ptr(ret_copy, true);
24048         return ret_ref;
24049 }
24050
24051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24052         LDKBigSize this_obj_conv;
24053         this_obj_conv.inner = untag_ptr(this_obj);
24054         this_obj_conv.is_owned = ptr_is_owned(this_obj);
24055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24056         BigSize_free(this_obj_conv);
24057 }
24058
24059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
24060         LDKBigSize this_ptr_conv;
24061         this_ptr_conv.inner = untag_ptr(this_ptr);
24062         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24064         this_ptr_conv.is_owned = false;
24065         int64_t ret_conv = BigSize_get_a(&this_ptr_conv);
24066         return ret_conv;
24067 }
24068
24069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24070         LDKBigSize this_ptr_conv;
24071         this_ptr_conv.inner = untag_ptr(this_ptr);
24072         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24074         this_ptr_conv.is_owned = false;
24075         BigSize_set_a(&this_ptr_conv, val);
24076 }
24077
24078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
24079         LDKBigSize ret_var = BigSize_new(a_arg);
24080         int64_t ret_ref = 0;
24081         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24082         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
24083         return ret_ref;
24084 }
24085
24086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Hostname_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24087         LDKHostname this_obj_conv;
24088         this_obj_conv.inner = untag_ptr(this_obj);
24089         this_obj_conv.is_owned = ptr_is_owned(this_obj);
24090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24091         Hostname_free(this_obj_conv);
24092 }
24093
24094 static inline uint64_t Hostname_clone_ptr(LDKHostname *NONNULL_PTR arg) {
24095         LDKHostname ret_var = Hostname_clone(arg);
24096         int64_t ret_ref = 0;
24097         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24098         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
24099         return ret_ref;
24100 }
24101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hostname_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24102         LDKHostname arg_conv;
24103         arg_conv.inner = untag_ptr(arg);
24104         arg_conv.is_owned = ptr_is_owned(arg);
24105         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24106         arg_conv.is_owned = false;
24107         int64_t ret_conv = Hostname_clone_ptr(&arg_conv);
24108         return ret_conv;
24109 }
24110
24111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hostname_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24112         LDKHostname orig_conv;
24113         orig_conv.inner = untag_ptr(orig);
24114         orig_conv.is_owned = ptr_is_owned(orig);
24115         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24116         orig_conv.is_owned = false;
24117         LDKHostname ret_var = Hostname_clone(&orig_conv);
24118         int64_t ret_ref = 0;
24119         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24120         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
24121         return ret_ref;
24122 }
24123
24124 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_Hostname_1len(JNIEnv *env, jclass clz, int64_t this_arg) {
24125         LDKHostname this_arg_conv;
24126         this_arg_conv.inner = untag_ptr(this_arg);
24127         this_arg_conv.is_owned = ptr_is_owned(this_arg);
24128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24129         this_arg_conv.is_owned = false;
24130         int8_t ret_conv = Hostname_len(&this_arg_conv);
24131         return ret_conv;
24132 }
24133
24134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
24135         LDKu8slice msg_ref;
24136         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
24137         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
24138         unsigned char sk_arr[32];
24139         CHECK((*env)->GetArrayLength(env, sk) == 32);
24140         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
24141         unsigned char (*sk_ref)[32] = &sk_arr;
24142         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
24143         *ret_conv = sign(msg_ref, sk_ref);
24144         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
24145         return tag_ptr(ret_conv, true);
24146 }
24147
24148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
24149         LDKu8slice msg_ref;
24150         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
24151         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
24152         LDKStr sig_conv = java_to_owned_str(env, sig);
24153         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
24154         *ret_conv = recover_pk(msg_ref, sig_conv);
24155         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
24156         return tag_ptr(ret_conv, true);
24157 }
24158
24159 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
24160         LDKu8slice msg_ref;
24161         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
24162         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
24163         LDKStr sig_conv = java_to_owned_str(env, sig);
24164         LDKPublicKey pk_ref;
24165         CHECK((*env)->GetArrayLength(env, pk) == 33);
24166         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
24167         jboolean ret_conv = verify(msg_ref, sig_conv, pk_ref);
24168         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
24169         return ret_conv;
24170 }
24171
24172 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_construct_1invoice_1preimage(JNIEnv *env, jclass clz, int8_tArray hrp_bytes, jobjectArray data_without_signature) {
24173         LDKu8slice hrp_bytes_ref;
24174         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
24175         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
24176         LDKCVec_u5Z data_without_signature_constr;
24177         data_without_signature_constr.datalen = (*env)->GetArrayLength(env, data_without_signature);
24178         if (data_without_signature_constr.datalen > 0)
24179                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
24180         else
24181                 data_without_signature_constr.data = NULL;
24182         int8_t* data_without_signature_vals = (*env)->GetByteArrayElements (env, data_without_signature, NULL);
24183         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
24184                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
24185                 
24186                 data_without_signature_constr.data[h] = (LDKu5){ ._0 = data_without_signature_conv_7 };
24187         }
24188         (*env)->ReleaseByteArrayElements(env, data_without_signature, data_without_signature_vals, 0);
24189         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
24190         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24191         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24192         CVec_u8Z_free(ret_var);
24193         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
24194         return ret_arr;
24195 }
24196
24197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24198         if (!ptr_is_owned(this_ptr)) return;
24199         void* this_ptr_ptr = untag_ptr(this_ptr);
24200         CHECK_ACCESS(this_ptr_ptr);
24201         LDKPersister this_ptr_conv = *(LDKPersister*)(this_ptr_ptr);
24202         FREE(untag_ptr(this_ptr));
24203         Persister_free(this_ptr_conv);
24204 }
24205
24206 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24207         LDKLevel* orig_conv = (LDKLevel*)untag_ptr(orig);
24208         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
24209         return ret_conv;
24210 }
24211
24212 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1gossip(JNIEnv *env, jclass clz) {
24213         jclass ret_conv = LDKLevel_to_java(env, Level_gossip());
24214         return ret_conv;
24215 }
24216
24217 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
24218         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
24219         return ret_conv;
24220 }
24221
24222 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
24223         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
24224         return ret_conv;
24225 }
24226
24227 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
24228         jclass ret_conv = LDKLevel_to_java(env, Level_info());
24229         return ret_conv;
24230 }
24231
24232 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
24233         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
24234         return ret_conv;
24235 }
24236
24237 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
24238         jclass ret_conv = LDKLevel_to_java(env, Level_error());
24239         return ret_conv;
24240 }
24241
24242 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24243         LDKLevel* a_conv = (LDKLevel*)untag_ptr(a);
24244         LDKLevel* b_conv = (LDKLevel*)untag_ptr(b);
24245         jboolean ret_conv = Level_eq(a_conv, b_conv);
24246         return ret_conv;
24247 }
24248
24249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
24250         LDKLevel* o_conv = (LDKLevel*)untag_ptr(o);
24251         int64_t ret_conv = Level_hash(o_conv);
24252         return ret_conv;
24253 }
24254
24255 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
24256         jclass ret_conv = LDKLevel_to_java(env, Level_max());
24257         return ret_conv;
24258 }
24259
24260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24261         LDKRecord this_obj_conv;
24262         this_obj_conv.inner = untag_ptr(this_obj);
24263         this_obj_conv.is_owned = ptr_is_owned(this_obj);
24264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24265         Record_free(this_obj_conv);
24266 }
24267
24268 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Record_1get_1level(JNIEnv *env, jclass clz, int64_t this_ptr) {
24269         LDKRecord this_ptr_conv;
24270         this_ptr_conv.inner = untag_ptr(this_ptr);
24271         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24273         this_ptr_conv.is_owned = false;
24274         jclass ret_conv = LDKLevel_to_java(env, Record_get_level(&this_ptr_conv));
24275         return ret_conv;
24276 }
24277
24278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1level(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
24279         LDKRecord this_ptr_conv;
24280         this_ptr_conv.inner = untag_ptr(this_ptr);
24281         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24283         this_ptr_conv.is_owned = false;
24284         LDKLevel val_conv = LDKLevel_from_java(env, val);
24285         Record_set_level(&this_ptr_conv, val_conv);
24286 }
24287
24288 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1args(JNIEnv *env, jclass clz, int64_t this_ptr) {
24289         LDKRecord this_ptr_conv;
24290         this_ptr_conv.inner = untag_ptr(this_ptr);
24291         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24293         this_ptr_conv.is_owned = false;
24294         LDKStr ret_str = Record_get_args(&this_ptr_conv);
24295         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
24296         Str_free(ret_str);
24297         return ret_conv;
24298 }
24299
24300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1args(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
24301         LDKRecord this_ptr_conv;
24302         this_ptr_conv.inner = untag_ptr(this_ptr);
24303         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24305         this_ptr_conv.is_owned = false;
24306         LDKStr val_conv = java_to_owned_str(env, val);
24307         Record_set_args(&this_ptr_conv, val_conv);
24308 }
24309
24310 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr) {
24311         LDKRecord this_ptr_conv;
24312         this_ptr_conv.inner = untag_ptr(this_ptr);
24313         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24315         this_ptr_conv.is_owned = false;
24316         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
24317         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
24318         Str_free(ret_str);
24319         return ret_conv;
24320 }
24321
24322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
24323         LDKRecord this_ptr_conv;
24324         this_ptr_conv.inner = untag_ptr(this_ptr);
24325         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24327         this_ptr_conv.is_owned = false;
24328         LDKStr val_conv = java_to_owned_str(env, val);
24329         Record_set_module_path(&this_ptr_conv, val_conv);
24330 }
24331
24332 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1file(JNIEnv *env, jclass clz, int64_t this_ptr) {
24333         LDKRecord this_ptr_conv;
24334         this_ptr_conv.inner = untag_ptr(this_ptr);
24335         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24337         this_ptr_conv.is_owned = false;
24338         LDKStr ret_str = Record_get_file(&this_ptr_conv);
24339         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
24340         Str_free(ret_str);
24341         return ret_conv;
24342 }
24343
24344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1file(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
24345         LDKRecord this_ptr_conv;
24346         this_ptr_conv.inner = untag_ptr(this_ptr);
24347         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24349         this_ptr_conv.is_owned = false;
24350         LDKStr val_conv = java_to_owned_str(env, val);
24351         Record_set_file(&this_ptr_conv, val_conv);
24352 }
24353
24354 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_Record_1get_1line(JNIEnv *env, jclass clz, int64_t this_ptr) {
24355         LDKRecord this_ptr_conv;
24356         this_ptr_conv.inner = untag_ptr(this_ptr);
24357         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24359         this_ptr_conv.is_owned = false;
24360         int32_t ret_conv = Record_get_line(&this_ptr_conv);
24361         return ret_conv;
24362 }
24363
24364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1line(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24365         LDKRecord this_ptr_conv;
24366         this_ptr_conv.inner = untag_ptr(this_ptr);
24367         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24369         this_ptr_conv.is_owned = false;
24370         Record_set_line(&this_ptr_conv, val);
24371 }
24372
24373 static inline uint64_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
24374         LDKRecord ret_var = Record_clone(arg);
24375         int64_t ret_ref = 0;
24376         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24377         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
24378         return ret_ref;
24379 }
24380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24381         LDKRecord arg_conv;
24382         arg_conv.inner = untag_ptr(arg);
24383         arg_conv.is_owned = ptr_is_owned(arg);
24384         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24385         arg_conv.is_owned = false;
24386         int64_t ret_conv = Record_clone_ptr(&arg_conv);
24387         return ret_conv;
24388 }
24389
24390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24391         LDKRecord orig_conv;
24392         orig_conv.inner = untag_ptr(orig);
24393         orig_conv.is_owned = ptr_is_owned(orig);
24394         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24395         orig_conv.is_owned = false;
24396         LDKRecord ret_var = Record_clone(&orig_conv);
24397         int64_t ret_ref = 0;
24398         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24399         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
24400         return ret_ref;
24401 }
24402
24403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24404         if (!ptr_is_owned(this_ptr)) return;
24405         void* this_ptr_ptr = untag_ptr(this_ptr);
24406         CHECK_ACCESS(this_ptr_ptr);
24407         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
24408         FREE(untag_ptr(this_ptr));
24409         Logger_free(this_ptr_conv);
24410 }
24411
24412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24413         LDKChannelHandshakeConfig this_obj_conv;
24414         this_obj_conv.inner = untag_ptr(this_obj);
24415         this_obj_conv.is_owned = ptr_is_owned(this_obj);
24416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24417         ChannelHandshakeConfig_free(this_obj_conv);
24418 }
24419
24420 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
24421         LDKChannelHandshakeConfig this_ptr_conv;
24422         this_ptr_conv.inner = untag_ptr(this_ptr);
24423         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24425         this_ptr_conv.is_owned = false;
24426         int32_t ret_conv = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
24427         return ret_conv;
24428 }
24429
24430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24431         LDKChannelHandshakeConfig this_ptr_conv;
24432         this_ptr_conv.inner = untag_ptr(this_ptr);
24433         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24435         this_ptr_conv.is_owned = false;
24436         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
24437 }
24438
24439 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
24440         LDKChannelHandshakeConfig this_ptr_conv;
24441         this_ptr_conv.inner = untag_ptr(this_ptr);
24442         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24444         this_ptr_conv.is_owned = false;
24445         int16_t ret_conv = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
24446         return ret_conv;
24447 }
24448
24449 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) {
24450         LDKChannelHandshakeConfig this_ptr_conv;
24451         this_ptr_conv.inner = untag_ptr(this_ptr);
24452         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24454         this_ptr_conv.is_owned = false;
24455         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
24456 }
24457
24458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24459         LDKChannelHandshakeConfig this_ptr_conv;
24460         this_ptr_conv.inner = untag_ptr(this_ptr);
24461         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24463         this_ptr_conv.is_owned = false;
24464         int64_t ret_conv = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
24465         return ret_conv;
24466 }
24467
24468 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) {
24469         LDKChannelHandshakeConfig this_ptr_conv;
24470         this_ptr_conv.inner = untag_ptr(this_ptr);
24471         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24473         this_ptr_conv.is_owned = false;
24474         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
24475 }
24476
24477 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) {
24478         LDKChannelHandshakeConfig this_ptr_conv;
24479         this_ptr_conv.inner = untag_ptr(this_ptr);
24480         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24482         this_ptr_conv.is_owned = false;
24483         int8_t ret_conv = ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv);
24484         return ret_conv;
24485 }
24486
24487 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) {
24488         LDKChannelHandshakeConfig this_ptr_conv;
24489         this_ptr_conv.inner = untag_ptr(this_ptr);
24490         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24492         this_ptr_conv.is_owned = false;
24493         ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv, val);
24494 }
24495
24496 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr) {
24497         LDKChannelHandshakeConfig this_ptr_conv;
24498         this_ptr_conv.inner = untag_ptr(this_ptr);
24499         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24501         this_ptr_conv.is_owned = false;
24502         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
24503         return ret_conv;
24504 }
24505
24506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24507         LDKChannelHandshakeConfig this_ptr_conv;
24508         this_ptr_conv.inner = untag_ptr(this_ptr);
24509         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24511         this_ptr_conv.is_owned = false;
24512         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
24513 }
24514
24515 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
24516         LDKChannelHandshakeConfig this_ptr_conv;
24517         this_ptr_conv.inner = untag_ptr(this_ptr);
24518         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24520         this_ptr_conv.is_owned = false;
24521         jboolean ret_conv = ChannelHandshakeConfig_get_announced_channel(&this_ptr_conv);
24522         return ret_conv;
24523 }
24524
24525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24526         LDKChannelHandshakeConfig this_ptr_conv;
24527         this_ptr_conv.inner = untag_ptr(this_ptr);
24528         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24530         this_ptr_conv.is_owned = false;
24531         ChannelHandshakeConfig_set_announced_channel(&this_ptr_conv, val);
24532 }
24533
24534 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
24535         LDKChannelHandshakeConfig this_ptr_conv;
24536         this_ptr_conv.inner = untag_ptr(this_ptr);
24537         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24539         this_ptr_conv.is_owned = false;
24540         jboolean ret_conv = ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
24541         return ret_conv;
24542 }
24543
24544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24545         LDKChannelHandshakeConfig this_ptr_conv;
24546         this_ptr_conv.inner = untag_ptr(this_ptr);
24547         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24549         this_ptr_conv.is_owned = false;
24550         ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
24551 }
24552
24553 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) {
24554         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);
24555         int64_t ret_ref = 0;
24556         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24557         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
24558         return ret_ref;
24559 }
24560
24561 static inline uint64_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
24562         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
24563         int64_t ret_ref = 0;
24564         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24565         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
24566         return ret_ref;
24567 }
24568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24569         LDKChannelHandshakeConfig arg_conv;
24570         arg_conv.inner = untag_ptr(arg);
24571         arg_conv.is_owned = ptr_is_owned(arg);
24572         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24573         arg_conv.is_owned = false;
24574         int64_t ret_conv = ChannelHandshakeConfig_clone_ptr(&arg_conv);
24575         return ret_conv;
24576 }
24577
24578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24579         LDKChannelHandshakeConfig orig_conv;
24580         orig_conv.inner = untag_ptr(orig);
24581         orig_conv.is_owned = ptr_is_owned(orig);
24582         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24583         orig_conv.is_owned = false;
24584         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
24585         int64_t ret_ref = 0;
24586         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24587         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
24588         return ret_ref;
24589 }
24590
24591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
24592         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
24593         int64_t ret_ref = 0;
24594         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24595         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
24596         return ret_ref;
24597 }
24598
24599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24600         LDKChannelHandshakeLimits this_obj_conv;
24601         this_obj_conv.inner = untag_ptr(this_obj);
24602         this_obj_conv.is_owned = ptr_is_owned(this_obj);
24603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24604         ChannelHandshakeLimits_free(this_obj_conv);
24605 }
24606
24607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
24608         LDKChannelHandshakeLimits this_ptr_conv;
24609         this_ptr_conv.inner = untag_ptr(this_ptr);
24610         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24612         this_ptr_conv.is_owned = false;
24613         int64_t ret_conv = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
24614         return ret_conv;
24615 }
24616
24617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24618         LDKChannelHandshakeLimits this_ptr_conv;
24619         this_ptr_conv.inner = untag_ptr(this_ptr);
24620         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24622         this_ptr_conv.is_owned = false;
24623         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
24624 }
24625
24626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
24627         LDKChannelHandshakeLimits this_ptr_conv;
24628         this_ptr_conv.inner = untag_ptr(this_ptr);
24629         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24631         this_ptr_conv.is_owned = false;
24632         int64_t ret_conv = ChannelHandshakeLimits_get_max_funding_satoshis(&this_ptr_conv);
24633         return ret_conv;
24634 }
24635
24636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24637         LDKChannelHandshakeLimits this_ptr_conv;
24638         this_ptr_conv.inner = untag_ptr(this_ptr);
24639         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24641         this_ptr_conv.is_owned = false;
24642         ChannelHandshakeLimits_set_max_funding_satoshis(&this_ptr_conv, val);
24643 }
24644
24645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24646         LDKChannelHandshakeLimits this_ptr_conv;
24647         this_ptr_conv.inner = untag_ptr(this_ptr);
24648         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24650         this_ptr_conv.is_owned = false;
24651         int64_t ret_conv = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
24652         return ret_conv;
24653 }
24654
24655 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) {
24656         LDKChannelHandshakeLimits this_ptr_conv;
24657         this_ptr_conv.inner = untag_ptr(this_ptr);
24658         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24660         this_ptr_conv.is_owned = false;
24661         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
24662 }
24663
24664 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) {
24665         LDKChannelHandshakeLimits this_ptr_conv;
24666         this_ptr_conv.inner = untag_ptr(this_ptr);
24667         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24669         this_ptr_conv.is_owned = false;
24670         int64_t ret_conv = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
24671         return ret_conv;
24672 }
24673
24674 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) {
24675         LDKChannelHandshakeLimits this_ptr_conv;
24676         this_ptr_conv.inner = untag_ptr(this_ptr);
24677         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24679         this_ptr_conv.is_owned = false;
24680         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
24681 }
24682
24683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
24684         LDKChannelHandshakeLimits this_ptr_conv;
24685         this_ptr_conv.inner = untag_ptr(this_ptr);
24686         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24688         this_ptr_conv.is_owned = false;
24689         int64_t ret_conv = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
24690         return ret_conv;
24691 }
24692
24693 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) {
24694         LDKChannelHandshakeLimits this_ptr_conv;
24695         this_ptr_conv.inner = untag_ptr(this_ptr);
24696         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24698         this_ptr_conv.is_owned = false;
24699         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
24700 }
24701
24702 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
24703         LDKChannelHandshakeLimits this_ptr_conv;
24704         this_ptr_conv.inner = untag_ptr(this_ptr);
24705         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24707         this_ptr_conv.is_owned = false;
24708         int16_t ret_conv = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
24709         return ret_conv;
24710 }
24711
24712 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) {
24713         LDKChannelHandshakeLimits this_ptr_conv;
24714         this_ptr_conv.inner = untag_ptr(this_ptr);
24715         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24717         this_ptr_conv.is_owned = false;
24718         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
24719 }
24720
24721 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
24722         LDKChannelHandshakeLimits this_ptr_conv;
24723         this_ptr_conv.inner = untag_ptr(this_ptr);
24724         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24726         this_ptr_conv.is_owned = false;
24727         int32_t ret_conv = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
24728         return ret_conv;
24729 }
24730
24731 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24732         LDKChannelHandshakeLimits this_ptr_conv;
24733         this_ptr_conv.inner = untag_ptr(this_ptr);
24734         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24736         this_ptr_conv.is_owned = false;
24737         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
24738 }
24739
24740 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr) {
24741         LDKChannelHandshakeLimits this_ptr_conv;
24742         this_ptr_conv.inner = untag_ptr(this_ptr);
24743         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24745         this_ptr_conv.is_owned = false;
24746         jboolean ret_conv = ChannelHandshakeLimits_get_trust_own_funding_0conf(&this_ptr_conv);
24747         return ret_conv;
24748 }
24749
24750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24751         LDKChannelHandshakeLimits this_ptr_conv;
24752         this_ptr_conv.inner = untag_ptr(this_ptr);
24753         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24755         this_ptr_conv.is_owned = false;
24756         ChannelHandshakeLimits_set_trust_own_funding_0conf(&this_ptr_conv, val);
24757 }
24758
24759 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
24760         LDKChannelHandshakeLimits this_ptr_conv;
24761         this_ptr_conv.inner = untag_ptr(this_ptr);
24762         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24764         this_ptr_conv.is_owned = false;
24765         jboolean ret_conv = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
24766         return ret_conv;
24767 }
24768
24769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24770         LDKChannelHandshakeLimits this_ptr_conv;
24771         this_ptr_conv.inner = untag_ptr(this_ptr);
24772         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24774         this_ptr_conv.is_owned = false;
24775         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
24776 }
24777
24778 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
24779         LDKChannelHandshakeLimits this_ptr_conv;
24780         this_ptr_conv.inner = untag_ptr(this_ptr);
24781         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24783         this_ptr_conv.is_owned = false;
24784         int16_t ret_conv = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
24785         return ret_conv;
24786 }
24787
24788 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) {
24789         LDKChannelHandshakeLimits this_ptr_conv;
24790         this_ptr_conv.inner = untag_ptr(this_ptr);
24791         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24793         this_ptr_conv.is_owned = false;
24794         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
24795 }
24796
24797 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) {
24798         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);
24799         int64_t ret_ref = 0;
24800         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24801         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
24802         return ret_ref;
24803 }
24804
24805 static inline uint64_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
24806         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
24807         int64_t ret_ref = 0;
24808         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24809         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
24810         return ret_ref;
24811 }
24812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24813         LDKChannelHandshakeLimits arg_conv;
24814         arg_conv.inner = untag_ptr(arg);
24815         arg_conv.is_owned = ptr_is_owned(arg);
24816         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24817         arg_conv.is_owned = false;
24818         int64_t ret_conv = ChannelHandshakeLimits_clone_ptr(&arg_conv);
24819         return ret_conv;
24820 }
24821
24822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24823         LDKChannelHandshakeLimits orig_conv;
24824         orig_conv.inner = untag_ptr(orig);
24825         orig_conv.is_owned = ptr_is_owned(orig);
24826         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24827         orig_conv.is_owned = false;
24828         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
24829         int64_t ret_ref = 0;
24830         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24831         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
24832         return ret_ref;
24833 }
24834
24835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
24836         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
24837         int64_t ret_ref = 0;
24838         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24839         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
24840         return ret_ref;
24841 }
24842
24843 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24844         LDKChannelConfig this_obj_conv;
24845         this_obj_conv.inner = untag_ptr(this_obj);
24846         this_obj_conv.is_owned = ptr_is_owned(this_obj);
24847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24848         ChannelConfig_free(this_obj_conv);
24849 }
24850
24851 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
24852         LDKChannelConfig this_ptr_conv;
24853         this_ptr_conv.inner = untag_ptr(this_ptr);
24854         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24856         this_ptr_conv.is_owned = false;
24857         int32_t ret_conv = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
24858         return ret_conv;
24859 }
24860
24861 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) {
24862         LDKChannelConfig this_ptr_conv;
24863         this_ptr_conv.inner = untag_ptr(this_ptr);
24864         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24866         this_ptr_conv.is_owned = false;
24867         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
24868 }
24869
24870 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24871         LDKChannelConfig this_ptr_conv;
24872         this_ptr_conv.inner = untag_ptr(this_ptr);
24873         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24875         this_ptr_conv.is_owned = false;
24876         int32_t ret_conv = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
24877         return ret_conv;
24878 }
24879
24880 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) {
24881         LDKChannelConfig this_ptr_conv;
24882         this_ptr_conv.inner = untag_ptr(this_ptr);
24883         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24885         this_ptr_conv.is_owned = false;
24886         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
24887 }
24888
24889 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
24890         LDKChannelConfig this_ptr_conv;
24891         this_ptr_conv.inner = untag_ptr(this_ptr);
24892         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24894         this_ptr_conv.is_owned = false;
24895         int16_t ret_conv = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
24896         return ret_conv;
24897 }
24898
24899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
24900         LDKChannelConfig this_ptr_conv;
24901         this_ptr_conv.inner = untag_ptr(this_ptr);
24902         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24904         this_ptr_conv.is_owned = false;
24905         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
24906 }
24907
24908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24909         LDKChannelConfig this_ptr_conv;
24910         this_ptr_conv.inner = untag_ptr(this_ptr);
24911         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24913         this_ptr_conv.is_owned = false;
24914         int64_t ret_conv = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
24915         return ret_conv;
24916 }
24917
24918 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) {
24919         LDKChannelConfig this_ptr_conv;
24920         this_ptr_conv.inner = untag_ptr(this_ptr);
24921         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24923         this_ptr_conv.is_owned = false;
24924         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
24925 }
24926
24927 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) {
24928         LDKChannelConfig this_ptr_conv;
24929         this_ptr_conv.inner = untag_ptr(this_ptr);
24930         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24932         this_ptr_conv.is_owned = false;
24933         int64_t ret_conv = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
24934         return ret_conv;
24935 }
24936
24937 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) {
24938         LDKChannelConfig this_ptr_conv;
24939         this_ptr_conv.inner = untag_ptr(this_ptr);
24940         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24942         this_ptr_conv.is_owned = false;
24943         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
24944 }
24945
24946 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) {
24947         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);
24948         int64_t ret_ref = 0;
24949         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24950         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
24951         return ret_ref;
24952 }
24953
24954 static inline uint64_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
24955         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
24956         int64_t ret_ref = 0;
24957         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24958         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
24959         return ret_ref;
24960 }
24961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24962         LDKChannelConfig arg_conv;
24963         arg_conv.inner = untag_ptr(arg);
24964         arg_conv.is_owned = ptr_is_owned(arg);
24965         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24966         arg_conv.is_owned = false;
24967         int64_t ret_conv = ChannelConfig_clone_ptr(&arg_conv);
24968         return ret_conv;
24969 }
24970
24971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24972         LDKChannelConfig orig_conv;
24973         orig_conv.inner = untag_ptr(orig);
24974         orig_conv.is_owned = ptr_is_owned(orig);
24975         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24976         orig_conv.is_owned = false;
24977         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
24978         int64_t ret_ref = 0;
24979         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24980         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
24981         return ret_ref;
24982 }
24983
24984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
24985         LDKChannelConfig ret_var = ChannelConfig_default();
24986         int64_t ret_ref = 0;
24987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24988         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
24989         return ret_ref;
24990 }
24991
24992 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
24993         LDKChannelConfig obj_conv;
24994         obj_conv.inner = untag_ptr(obj);
24995         obj_conv.is_owned = ptr_is_owned(obj);
24996         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
24997         obj_conv.is_owned = false;
24998         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
24999         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25000         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25001         CVec_u8Z_free(ret_var);
25002         return ret_arr;
25003 }
25004
25005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25006         LDKu8slice ser_ref;
25007         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25008         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25009         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
25010         *ret_conv = ChannelConfig_read(ser_ref);
25011         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25012         return tag_ptr(ret_conv, true);
25013 }
25014
25015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25016         LDKUserConfig this_obj_conv;
25017         this_obj_conv.inner = untag_ptr(this_obj);
25018         this_obj_conv.is_owned = ptr_is_owned(this_obj);
25019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25020         UserConfig_free(this_obj_conv);
25021 }
25022
25023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
25024         LDKUserConfig this_ptr_conv;
25025         this_ptr_conv.inner = untag_ptr(this_ptr);
25026         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25028         this_ptr_conv.is_owned = false;
25029         LDKChannelHandshakeConfig ret_var = UserConfig_get_channel_handshake_config(&this_ptr_conv);
25030         int64_t ret_ref = 0;
25031         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25032         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25033         return ret_ref;
25034 }
25035
25036 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25037         LDKUserConfig this_ptr_conv;
25038         this_ptr_conv.inner = untag_ptr(this_ptr);
25039         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25041         this_ptr_conv.is_owned = false;
25042         LDKChannelHandshakeConfig val_conv;
25043         val_conv.inner = untag_ptr(val);
25044         val_conv.is_owned = ptr_is_owned(val);
25045         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25046         val_conv = ChannelHandshakeConfig_clone(&val_conv);
25047         UserConfig_set_channel_handshake_config(&this_ptr_conv, val_conv);
25048 }
25049
25050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
25051         LDKUserConfig this_ptr_conv;
25052         this_ptr_conv.inner = untag_ptr(this_ptr);
25053         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25055         this_ptr_conv.is_owned = false;
25056         LDKChannelHandshakeLimits ret_var = UserConfig_get_channel_handshake_limits(&this_ptr_conv);
25057         int64_t ret_ref = 0;
25058         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25059         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25060         return ret_ref;
25061 }
25062
25063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25064         LDKUserConfig this_ptr_conv;
25065         this_ptr_conv.inner = untag_ptr(this_ptr);
25066         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25068         this_ptr_conv.is_owned = false;
25069         LDKChannelHandshakeLimits val_conv;
25070         val_conv.inner = untag_ptr(val);
25071         val_conv.is_owned = ptr_is_owned(val);
25072         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25073         val_conv = ChannelHandshakeLimits_clone(&val_conv);
25074         UserConfig_set_channel_handshake_limits(&this_ptr_conv, val_conv);
25075 }
25076
25077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
25078         LDKUserConfig this_ptr_conv;
25079         this_ptr_conv.inner = untag_ptr(this_ptr);
25080         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25082         this_ptr_conv.is_owned = false;
25083         LDKChannelConfig ret_var = UserConfig_get_channel_config(&this_ptr_conv);
25084         int64_t ret_ref = 0;
25085         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25086         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25087         return ret_ref;
25088 }
25089
25090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25091         LDKUserConfig this_ptr_conv;
25092         this_ptr_conv.inner = untag_ptr(this_ptr);
25093         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25095         this_ptr_conv.is_owned = false;
25096         LDKChannelConfig val_conv;
25097         val_conv.inner = untag_ptr(val);
25098         val_conv.is_owned = ptr_is_owned(val);
25099         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25100         val_conv = ChannelConfig_clone(&val_conv);
25101         UserConfig_set_channel_config(&this_ptr_conv, val_conv);
25102 }
25103
25104 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
25105         LDKUserConfig this_ptr_conv;
25106         this_ptr_conv.inner = untag_ptr(this_ptr);
25107         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25109         this_ptr_conv.is_owned = false;
25110         jboolean ret_conv = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
25111         return ret_conv;
25112 }
25113
25114 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) {
25115         LDKUserConfig this_ptr_conv;
25116         this_ptr_conv.inner = untag_ptr(this_ptr);
25117         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25119         this_ptr_conv.is_owned = false;
25120         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
25121 }
25122
25123 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
25124         LDKUserConfig this_ptr_conv;
25125         this_ptr_conv.inner = untag_ptr(this_ptr);
25126         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25128         this_ptr_conv.is_owned = false;
25129         jboolean ret_conv = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
25130         return ret_conv;
25131 }
25132
25133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25134         LDKUserConfig this_ptr_conv;
25135         this_ptr_conv.inner = untag_ptr(this_ptr);
25136         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25138         this_ptr_conv.is_owned = false;
25139         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
25140 }
25141
25142 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
25143         LDKUserConfig this_ptr_conv;
25144         this_ptr_conv.inner = untag_ptr(this_ptr);
25145         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25147         this_ptr_conv.is_owned = false;
25148         jboolean ret_conv = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
25149         return ret_conv;
25150 }
25151
25152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25153         LDKUserConfig this_ptr_conv;
25154         this_ptr_conv.inner = untag_ptr(this_ptr);
25155         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25157         this_ptr_conv.is_owned = false;
25158         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
25159 }
25160
25161 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) {
25162         LDKChannelHandshakeConfig channel_handshake_config_arg_conv;
25163         channel_handshake_config_arg_conv.inner = untag_ptr(channel_handshake_config_arg);
25164         channel_handshake_config_arg_conv.is_owned = ptr_is_owned(channel_handshake_config_arg);
25165         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_config_arg_conv);
25166         channel_handshake_config_arg_conv = ChannelHandshakeConfig_clone(&channel_handshake_config_arg_conv);
25167         LDKChannelHandshakeLimits channel_handshake_limits_arg_conv;
25168         channel_handshake_limits_arg_conv.inner = untag_ptr(channel_handshake_limits_arg);
25169         channel_handshake_limits_arg_conv.is_owned = ptr_is_owned(channel_handshake_limits_arg);
25170         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_limits_arg_conv);
25171         channel_handshake_limits_arg_conv = ChannelHandshakeLimits_clone(&channel_handshake_limits_arg_conv);
25172         LDKChannelConfig channel_config_arg_conv;
25173         channel_config_arg_conv.inner = untag_ptr(channel_config_arg);
25174         channel_config_arg_conv.is_owned = ptr_is_owned(channel_config_arg);
25175         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_config_arg_conv);
25176         channel_config_arg_conv = ChannelConfig_clone(&channel_config_arg_conv);
25177         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);
25178         int64_t ret_ref = 0;
25179         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25180         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25181         return ret_ref;
25182 }
25183
25184 static inline uint64_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
25185         LDKUserConfig ret_var = UserConfig_clone(arg);
25186         int64_t ret_ref = 0;
25187         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25188         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25189         return ret_ref;
25190 }
25191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25192         LDKUserConfig arg_conv;
25193         arg_conv.inner = untag_ptr(arg);
25194         arg_conv.is_owned = ptr_is_owned(arg);
25195         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25196         arg_conv.is_owned = false;
25197         int64_t ret_conv = UserConfig_clone_ptr(&arg_conv);
25198         return ret_conv;
25199 }
25200
25201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25202         LDKUserConfig orig_conv;
25203         orig_conv.inner = untag_ptr(orig);
25204         orig_conv.is_owned = ptr_is_owned(orig);
25205         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25206         orig_conv.is_owned = false;
25207         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
25208         int64_t ret_ref = 0;
25209         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25210         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25211         return ret_ref;
25212 }
25213
25214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
25215         LDKUserConfig ret_var = UserConfig_default();
25216         int64_t ret_ref = 0;
25217         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25218         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25219         return ret_ref;
25220 }
25221
25222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25223         LDKBestBlock this_obj_conv;
25224         this_obj_conv.inner = untag_ptr(this_obj);
25225         this_obj_conv.is_owned = ptr_is_owned(this_obj);
25226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25227         BestBlock_free(this_obj_conv);
25228 }
25229
25230 static inline uint64_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
25231         LDKBestBlock ret_var = BestBlock_clone(arg);
25232         int64_t ret_ref = 0;
25233         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25234         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25235         return ret_ref;
25236 }
25237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25238         LDKBestBlock arg_conv;
25239         arg_conv.inner = untag_ptr(arg);
25240         arg_conv.is_owned = ptr_is_owned(arg);
25241         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25242         arg_conv.is_owned = false;
25243         int64_t ret_conv = BestBlock_clone_ptr(&arg_conv);
25244         return ret_conv;
25245 }
25246
25247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25248         LDKBestBlock orig_conv;
25249         orig_conv.inner = untag_ptr(orig);
25250         orig_conv.is_owned = ptr_is_owned(orig);
25251         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25252         orig_conv.is_owned = false;
25253         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
25254         int64_t ret_ref = 0;
25255         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25256         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25257         return ret_ref;
25258 }
25259
25260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
25261         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
25262         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
25263         int64_t ret_ref = 0;
25264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25265         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25266         return ret_ref;
25267 }
25268
25269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
25270         LDKThirtyTwoBytes block_hash_ref;
25271         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
25272         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
25273         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
25274         int64_t ret_ref = 0;
25275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25276         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25277         return ret_ref;
25278 }
25279
25280 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25281         LDKBestBlock this_arg_conv;
25282         this_arg_conv.inner = untag_ptr(this_arg);
25283         this_arg_conv.is_owned = ptr_is_owned(this_arg);
25284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25285         this_arg_conv.is_owned = false;
25286         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25287         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
25288         return ret_arr;
25289 }
25290
25291 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
25292         LDKBestBlock this_arg_conv;
25293         this_arg_conv.inner = untag_ptr(this_arg);
25294         this_arg_conv.is_owned = ptr_is_owned(this_arg);
25295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25296         this_arg_conv.is_owned = false;
25297         int32_t ret_conv = BestBlock_height(&this_arg_conv);
25298         return ret_conv;
25299 }
25300
25301 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25302         LDKAccessError* orig_conv = (LDKAccessError*)untag_ptr(orig);
25303         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
25304         return ret_conv;
25305 }
25306
25307 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1chain(JNIEnv *env, jclass clz) {
25308         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_chain());
25309         return ret_conv;
25310 }
25311
25312 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1tx(JNIEnv *env, jclass clz) {
25313         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_tx());
25314         return ret_conv;
25315 }
25316
25317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25318         if (!ptr_is_owned(this_ptr)) return;
25319         void* this_ptr_ptr = untag_ptr(this_ptr);
25320         CHECK_ACCESS(this_ptr_ptr);
25321         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
25322         FREE(untag_ptr(this_ptr));
25323         Access_free(this_ptr_conv);
25324 }
25325
25326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25327         if (!ptr_is_owned(this_ptr)) return;
25328         void* this_ptr_ptr = untag_ptr(this_ptr);
25329         CHECK_ACCESS(this_ptr_ptr);
25330         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
25331         FREE(untag_ptr(this_ptr));
25332         Listen_free(this_ptr_conv);
25333 }
25334
25335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25336         if (!ptr_is_owned(this_ptr)) return;
25337         void* this_ptr_ptr = untag_ptr(this_ptr);
25338         CHECK_ACCESS(this_ptr_ptr);
25339         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
25340         FREE(untag_ptr(this_ptr));
25341         Confirm_free(this_ptr_conv);
25342 }
25343
25344 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25345         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)untag_ptr(orig);
25346         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
25347         return ret_conv;
25348 }
25349
25350 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1temporary_1failure(JNIEnv *env, jclass clz) {
25351         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_temporary_failure());
25352         return ret_conv;
25353 }
25354
25355 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1permanent_1failure(JNIEnv *env, jclass clz) {
25356         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_permanent_failure());
25357         return ret_conv;
25358 }
25359
25360 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25361         if (!ptr_is_owned(this_ptr)) return;
25362         void* this_ptr_ptr = untag_ptr(this_ptr);
25363         CHECK_ACCESS(this_ptr_ptr);
25364         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
25365         FREE(untag_ptr(this_ptr));
25366         Watch_free(this_ptr_conv);
25367 }
25368
25369 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25370         if (!ptr_is_owned(this_ptr)) return;
25371         void* this_ptr_ptr = untag_ptr(this_ptr);
25372         CHECK_ACCESS(this_ptr_ptr);
25373         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
25374         FREE(untag_ptr(this_ptr));
25375         Filter_free(this_ptr_conv);
25376 }
25377
25378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25379         LDKWatchedOutput this_obj_conv;
25380         this_obj_conv.inner = untag_ptr(this_obj);
25381         this_obj_conv.is_owned = ptr_is_owned(this_obj);
25382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25383         WatchedOutput_free(this_obj_conv);
25384 }
25385
25386 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
25387         LDKWatchedOutput this_ptr_conv;
25388         this_ptr_conv.inner = untag_ptr(this_ptr);
25389         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25391         this_ptr_conv.is_owned = false;
25392         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25393         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
25394         return ret_arr;
25395 }
25396
25397 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25398         LDKWatchedOutput this_ptr_conv;
25399         this_ptr_conv.inner = untag_ptr(this_ptr);
25400         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25402         this_ptr_conv.is_owned = false;
25403         LDKThirtyTwoBytes val_ref;
25404         CHECK((*env)->GetArrayLength(env, val) == 32);
25405         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
25406         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
25407 }
25408
25409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
25410         LDKWatchedOutput this_ptr_conv;
25411         this_ptr_conv.inner = untag_ptr(this_ptr);
25412         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25414         this_ptr_conv.is_owned = false;
25415         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
25416         int64_t ret_ref = 0;
25417         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25418         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25419         return ret_ref;
25420 }
25421
25422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25423         LDKWatchedOutput this_ptr_conv;
25424         this_ptr_conv.inner = untag_ptr(this_ptr);
25425         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25427         this_ptr_conv.is_owned = false;
25428         LDKOutPoint val_conv;
25429         val_conv.inner = untag_ptr(val);
25430         val_conv.is_owned = ptr_is_owned(val);
25431         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25432         val_conv = OutPoint_clone(&val_conv);
25433         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
25434 }
25435
25436 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
25437         LDKWatchedOutput this_ptr_conv;
25438         this_ptr_conv.inner = untag_ptr(this_ptr);
25439         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25441         this_ptr_conv.is_owned = false;
25442         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
25443         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25444         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25445         return ret_arr;
25446 }
25447
25448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25449         LDKWatchedOutput this_ptr_conv;
25450         this_ptr_conv.inner = untag_ptr(this_ptr);
25451         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25453         this_ptr_conv.is_owned = false;
25454         LDKCVec_u8Z val_ref;
25455         val_ref.datalen = (*env)->GetArrayLength(env, val);
25456         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
25457         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
25458         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
25459 }
25460
25461 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) {
25462         LDKThirtyTwoBytes block_hash_arg_ref;
25463         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
25464         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
25465         LDKOutPoint outpoint_arg_conv;
25466         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
25467         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
25468         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
25469         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
25470         LDKCVec_u8Z script_pubkey_arg_ref;
25471         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
25472         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
25473         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
25474         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
25475         int64_t ret_ref = 0;
25476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25477         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25478         return ret_ref;
25479 }
25480
25481 static inline uint64_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
25482         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
25483         int64_t ret_ref = 0;
25484         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25485         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25486         return ret_ref;
25487 }
25488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25489         LDKWatchedOutput arg_conv;
25490         arg_conv.inner = untag_ptr(arg);
25491         arg_conv.is_owned = ptr_is_owned(arg);
25492         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25493         arg_conv.is_owned = false;
25494         int64_t ret_conv = WatchedOutput_clone_ptr(&arg_conv);
25495         return ret_conv;
25496 }
25497
25498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25499         LDKWatchedOutput orig_conv;
25500         orig_conv.inner = untag_ptr(orig);
25501         orig_conv.is_owned = ptr_is_owned(orig);
25502         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25503         orig_conv.is_owned = false;
25504         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
25505         int64_t ret_ref = 0;
25506         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25507         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25508         return ret_ref;
25509 }
25510
25511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
25512         LDKWatchedOutput o_conv;
25513         o_conv.inner = untag_ptr(o);
25514         o_conv.is_owned = ptr_is_owned(o);
25515         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25516         o_conv.is_owned = false;
25517         int64_t ret_conv = WatchedOutput_hash(&o_conv);
25518         return ret_conv;
25519 }
25520
25521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25522         if (!ptr_is_owned(this_ptr)) return;
25523         void* this_ptr_ptr = untag_ptr(this_ptr);
25524         CHECK_ACCESS(this_ptr_ptr);
25525         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
25526         FREE(untag_ptr(this_ptr));
25527         BroadcasterInterface_free(this_ptr_conv);
25528 }
25529
25530 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25531         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)untag_ptr(orig);
25532         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
25533         return ret_conv;
25534 }
25535
25536 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
25537         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
25538         return ret_conv;
25539 }
25540
25541 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
25542         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
25543         return ret_conv;
25544 }
25545
25546 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
25547         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
25548         return ret_conv;
25549 }
25550
25551 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25552         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)untag_ptr(a);
25553         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)untag_ptr(b);
25554         jboolean ret_conv = ConfirmationTarget_eq(a_conv, b_conv);
25555         return ret_conv;
25556 }
25557
25558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25559         if (!ptr_is_owned(this_ptr)) return;
25560         void* this_ptr_ptr = untag_ptr(this_ptr);
25561         CHECK_ACCESS(this_ptr_ptr);
25562         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
25563         FREE(untag_ptr(this_ptr));
25564         FeeEstimator_free(this_ptr_conv);
25565 }
25566
25567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25568         LDKMonitorUpdateId this_obj_conv;
25569         this_obj_conv.inner = untag_ptr(this_obj);
25570         this_obj_conv.is_owned = ptr_is_owned(this_obj);
25571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25572         MonitorUpdateId_free(this_obj_conv);
25573 }
25574
25575 static inline uint64_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
25576         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
25577         int64_t ret_ref = 0;
25578         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25579         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25580         return ret_ref;
25581 }
25582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25583         LDKMonitorUpdateId arg_conv;
25584         arg_conv.inner = untag_ptr(arg);
25585         arg_conv.is_owned = ptr_is_owned(arg);
25586         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25587         arg_conv.is_owned = false;
25588         int64_t ret_conv = MonitorUpdateId_clone_ptr(&arg_conv);
25589         return ret_conv;
25590 }
25591
25592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25593         LDKMonitorUpdateId orig_conv;
25594         orig_conv.inner = untag_ptr(orig);
25595         orig_conv.is_owned = ptr_is_owned(orig);
25596         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25597         orig_conv.is_owned = false;
25598         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
25599         int64_t ret_ref = 0;
25600         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25601         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25602         return ret_ref;
25603 }
25604
25605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1hash(JNIEnv *env, jclass clz, int64_t o) {
25606         LDKMonitorUpdateId o_conv;
25607         o_conv.inner = untag_ptr(o);
25608         o_conv.is_owned = ptr_is_owned(o);
25609         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25610         o_conv.is_owned = false;
25611         int64_t ret_conv = MonitorUpdateId_hash(&o_conv);
25612         return ret_conv;
25613 }
25614
25615 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25616         LDKMonitorUpdateId a_conv;
25617         a_conv.inner = untag_ptr(a);
25618         a_conv.is_owned = ptr_is_owned(a);
25619         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25620         a_conv.is_owned = false;
25621         LDKMonitorUpdateId b_conv;
25622         b_conv.inner = untag_ptr(b);
25623         b_conv.is_owned = ptr_is_owned(b);
25624         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
25625         b_conv.is_owned = false;
25626         jboolean ret_conv = MonitorUpdateId_eq(&a_conv, &b_conv);
25627         return ret_conv;
25628 }
25629
25630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25631         if (!ptr_is_owned(this_ptr)) return;
25632         void* this_ptr_ptr = untag_ptr(this_ptr);
25633         CHECK_ACCESS(this_ptr_ptr);
25634         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
25635         FREE(untag_ptr(this_ptr));
25636         Persist_free(this_ptr_conv);
25637 }
25638
25639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25640         LDKLockedChannelMonitor this_obj_conv;
25641         this_obj_conv.inner = untag_ptr(this_obj);
25642         this_obj_conv.is_owned = ptr_is_owned(this_obj);
25643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25644         LockedChannelMonitor_free(this_obj_conv);
25645 }
25646
25647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25648         LDKChainMonitor this_obj_conv;
25649         this_obj_conv.inner = untag_ptr(this_obj);
25650         this_obj_conv.is_owned = ptr_is_owned(this_obj);
25651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25652         ChainMonitor_free(this_obj_conv);
25653 }
25654
25655 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) {
25656         void* chain_source_ptr = untag_ptr(chain_source);
25657         CHECK_ACCESS(chain_source_ptr);
25658         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
25659         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
25660         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
25661                 // Manually implement clone for Java trait instances
25662                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
25663                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25664                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
25665                 }
25666         }
25667         void* broadcaster_ptr = untag_ptr(broadcaster);
25668         CHECK_ACCESS(broadcaster_ptr);
25669         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
25670         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
25671                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25672                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
25673         }
25674         void* logger_ptr = untag_ptr(logger);
25675         CHECK_ACCESS(logger_ptr);
25676         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
25677         if (logger_conv.free == LDKLogger_JCalls_free) {
25678                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25679                 LDKLogger_JCalls_cloned(&logger_conv);
25680         }
25681         void* feeest_ptr = untag_ptr(feeest);
25682         CHECK_ACCESS(feeest_ptr);
25683         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
25684         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
25685                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25686                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
25687         }
25688         void* persister_ptr = untag_ptr(persister);
25689         CHECK_ACCESS(persister_ptr);
25690         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
25691         if (persister_conv.free == LDKPersist_JCalls_free) {
25692                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25693                 LDKPersist_JCalls_cloned(&persister_conv);
25694         }
25695         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
25696         int64_t ret_ref = 0;
25697         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25698         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25699         return ret_ref;
25700 }
25701
25702 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) {
25703         LDKChainMonitor this_arg_conv;
25704         this_arg_conv.inner = untag_ptr(this_arg);
25705         this_arg_conv.is_owned = ptr_is_owned(this_arg);
25706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25707         this_arg_conv.is_owned = false;
25708         LDKCVec_ChannelDetailsZ ignored_channels_constr;
25709         ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels);
25710         if (ignored_channels_constr.datalen > 0)
25711                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
25712         else
25713                 ignored_channels_constr.data = NULL;
25714         int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL);
25715         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
25716                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
25717                 LDKChannelDetails ignored_channels_conv_16_conv;
25718                 ignored_channels_conv_16_conv.inner = untag_ptr(ignored_channels_conv_16);
25719                 ignored_channels_conv_16_conv.is_owned = ptr_is_owned(ignored_channels_conv_16);
25720                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
25721                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
25722                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
25723         }
25724         (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0);
25725         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
25726         int64_tArray ret_arr = NULL;
25727         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25728         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25729         for (size_t j = 0; j < ret_var.datalen; j++) {
25730                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25731                 *ret_conv_9_copy = ret_var.data[j];
25732                 int64_t ret_conv_9_ref = tag_ptr(ret_conv_9_copy, true);
25733                 ret_arr_ptr[j] = ret_conv_9_ref;
25734         }
25735         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25736         FREE(ret_var.data);
25737         return ret_arr;
25738 }
25739
25740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1monitor(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo) {
25741         LDKChainMonitor this_arg_conv;
25742         this_arg_conv.inner = untag_ptr(this_arg);
25743         this_arg_conv.is_owned = ptr_is_owned(this_arg);
25744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25745         this_arg_conv.is_owned = false;
25746         LDKOutPoint funding_txo_conv;
25747         funding_txo_conv.inner = untag_ptr(funding_txo);
25748         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
25749         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
25750         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
25751         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
25752         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
25753         return tag_ptr(ret_conv, true);
25754 }
25755
25756 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1monitors(JNIEnv *env, jclass clz, int64_t this_arg) {
25757         LDKChainMonitor this_arg_conv;
25758         this_arg_conv.inner = untag_ptr(this_arg);
25759         this_arg_conv.is_owned = ptr_is_owned(this_arg);
25760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25761         this_arg_conv.is_owned = false;
25762         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
25763         int64_tArray ret_arr = NULL;
25764         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25765         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25766         for (size_t k = 0; k < ret_var.datalen; k++) {
25767                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
25768                 int64_t ret_conv_10_ref = 0;
25769                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
25770                 ret_conv_10_ref = tag_ptr(ret_conv_10_var.inner, ret_conv_10_var.is_owned);
25771                 ret_arr_ptr[k] = ret_conv_10_ref;
25772         }
25773         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25774         FREE(ret_var.data);
25775         return ret_arr;
25776 }
25777
25778 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) {
25779         LDKChainMonitor this_arg_conv;
25780         this_arg_conv.inner = untag_ptr(this_arg);
25781         this_arg_conv.is_owned = ptr_is_owned(this_arg);
25782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25783         this_arg_conv.is_owned = false;
25784         LDKOutPoint funding_txo_conv;
25785         funding_txo_conv.inner = untag_ptr(funding_txo);
25786         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
25787         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
25788         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
25789         LDKMonitorUpdateId completed_update_id_conv;
25790         completed_update_id_conv.inner = untag_ptr(completed_update_id);
25791         completed_update_id_conv.is_owned = ptr_is_owned(completed_update_id);
25792         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
25793         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
25794         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25795         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
25796         return tag_ptr(ret_conv, true);
25797 }
25798
25799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
25800         LDKChainMonitor this_arg_conv;
25801         this_arg_conv.inner = untag_ptr(this_arg);
25802         this_arg_conv.is_owned = ptr_is_owned(this_arg);
25803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25804         this_arg_conv.is_owned = false;
25805         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
25806         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
25807         return tag_ptr(ret_ret, true);
25808 }
25809
25810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
25811         LDKChainMonitor this_arg_conv;
25812         this_arg_conv.inner = untag_ptr(this_arg);
25813         this_arg_conv.is_owned = ptr_is_owned(this_arg);
25814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25815         this_arg_conv.is_owned = false;
25816         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
25817         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
25818         return tag_ptr(ret_ret, true);
25819 }
25820
25821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
25822         LDKChainMonitor this_arg_conv;
25823         this_arg_conv.inner = untag_ptr(this_arg);
25824         this_arg_conv.is_owned = ptr_is_owned(this_arg);
25825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25826         this_arg_conv.is_owned = false;
25827         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
25828         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
25829         return tag_ptr(ret_ret, true);
25830 }
25831
25832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
25833         LDKChainMonitor this_arg_conv;
25834         this_arg_conv.inner = untag_ptr(this_arg);
25835         this_arg_conv.is_owned = ptr_is_owned(this_arg);
25836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25837         this_arg_conv.is_owned = false;
25838         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
25839         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
25840         return tag_ptr(ret_ret, true);
25841 }
25842
25843 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25844         LDKChannelMonitorUpdate this_obj_conv;
25845         this_obj_conv.inner = untag_ptr(this_obj);
25846         this_obj_conv.is_owned = ptr_is_owned(this_obj);
25847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25848         ChannelMonitorUpdate_free(this_obj_conv);
25849 }
25850
25851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
25852         LDKChannelMonitorUpdate this_ptr_conv;
25853         this_ptr_conv.inner = untag_ptr(this_ptr);
25854         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25856         this_ptr_conv.is_owned = false;
25857         int64_t ret_conv = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
25858         return ret_conv;
25859 }
25860
25861 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25862         LDKChannelMonitorUpdate this_ptr_conv;
25863         this_ptr_conv.inner = untag_ptr(this_ptr);
25864         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25866         this_ptr_conv.is_owned = false;
25867         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
25868 }
25869
25870 static inline uint64_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
25871         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
25872         int64_t ret_ref = 0;
25873         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25874         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25875         return ret_ref;
25876 }
25877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25878         LDKChannelMonitorUpdate arg_conv;
25879         arg_conv.inner = untag_ptr(arg);
25880         arg_conv.is_owned = ptr_is_owned(arg);
25881         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25882         arg_conv.is_owned = false;
25883         int64_t ret_conv = ChannelMonitorUpdate_clone_ptr(&arg_conv);
25884         return ret_conv;
25885 }
25886
25887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25888         LDKChannelMonitorUpdate orig_conv;
25889         orig_conv.inner = untag_ptr(orig);
25890         orig_conv.is_owned = ptr_is_owned(orig);
25891         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25892         orig_conv.is_owned = false;
25893         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
25894         int64_t ret_ref = 0;
25895         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25896         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25897         return ret_ref;
25898 }
25899
25900 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
25901         LDKChannelMonitorUpdate obj_conv;
25902         obj_conv.inner = untag_ptr(obj);
25903         obj_conv.is_owned = ptr_is_owned(obj);
25904         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25905         obj_conv.is_owned = false;
25906         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
25907         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25908         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25909         CVec_u8Z_free(ret_var);
25910         return ret_arr;
25911 }
25912
25913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25914         LDKu8slice ser_ref;
25915         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25916         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25917         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
25918         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
25919         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25920         return tag_ptr(ret_conv, true);
25921 }
25922
25923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25924         if (!ptr_is_owned(this_ptr)) return;
25925         void* this_ptr_ptr = untag_ptr(this_ptr);
25926         CHECK_ACCESS(this_ptr_ptr);
25927         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
25928         FREE(untag_ptr(this_ptr));
25929         MonitorEvent_free(this_ptr_conv);
25930 }
25931
25932 static inline uint64_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
25933         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25934         *ret_copy = MonitorEvent_clone(arg);
25935         int64_t ret_ref = tag_ptr(ret_copy, true);
25936         return ret_ref;
25937 }
25938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25939         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)untag_ptr(arg);
25940         int64_t ret_conv = MonitorEvent_clone_ptr(arg_conv);
25941         return ret_conv;
25942 }
25943
25944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25945         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)untag_ptr(orig);
25946         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25947         *ret_copy = MonitorEvent_clone(orig_conv);
25948         int64_t ret_ref = tag_ptr(ret_copy, true);
25949         return ret_ref;
25950 }
25951
25952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
25953         LDKHTLCUpdate a_conv;
25954         a_conv.inner = untag_ptr(a);
25955         a_conv.is_owned = ptr_is_owned(a);
25956         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25957         a_conv = HTLCUpdate_clone(&a_conv);
25958         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25959         *ret_copy = MonitorEvent_htlcevent(a_conv);
25960         int64_t ret_ref = tag_ptr(ret_copy, true);
25961         return ret_ref;
25962 }
25963
25964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) {
25965         LDKOutPoint a_conv;
25966         a_conv.inner = untag_ptr(a);
25967         a_conv.is_owned = ptr_is_owned(a);
25968         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25969         a_conv = OutPoint_clone(&a_conv);
25970         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25971         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
25972         int64_t ret_ref = tag_ptr(ret_copy, true);
25973         return ret_ref;
25974 }
25975
25976 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) {
25977         LDKOutPoint funding_txo_conv;
25978         funding_txo_conv.inner = untag_ptr(funding_txo);
25979         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
25980         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
25981         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
25982         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25983         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
25984         int64_t ret_ref = tag_ptr(ret_copy, true);
25985         return ret_ref;
25986 }
25987
25988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1failed(JNIEnv *env, jclass clz, int64_t a) {
25989         LDKOutPoint a_conv;
25990         a_conv.inner = untag_ptr(a);
25991         a_conv.is_owned = ptr_is_owned(a);
25992         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25993         a_conv = OutPoint_clone(&a_conv);
25994         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25995         *ret_copy = MonitorEvent_update_failed(a_conv);
25996         int64_t ret_ref = tag_ptr(ret_copy, true);
25997         return ret_ref;
25998 }
25999
26000 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1write(JNIEnv *env, jclass clz, int64_t obj) {
26001         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)untag_ptr(obj);
26002         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
26003         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26004         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26005         CVec_u8Z_free(ret_var);
26006         return ret_arr;
26007 }
26008
26009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26010         LDKu8slice ser_ref;
26011         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26012         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26013         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
26014         *ret_conv = MonitorEvent_read(ser_ref);
26015         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26016         return tag_ptr(ret_conv, true);
26017 }
26018
26019 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26020         LDKHTLCUpdate this_obj_conv;
26021         this_obj_conv.inner = untag_ptr(this_obj);
26022         this_obj_conv.is_owned = ptr_is_owned(this_obj);
26023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26024         HTLCUpdate_free(this_obj_conv);
26025 }
26026
26027 static inline uint64_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
26028         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
26029         int64_t ret_ref = 0;
26030         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26031         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26032         return ret_ref;
26033 }
26034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26035         LDKHTLCUpdate arg_conv;
26036         arg_conv.inner = untag_ptr(arg);
26037         arg_conv.is_owned = ptr_is_owned(arg);
26038         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26039         arg_conv.is_owned = false;
26040         int64_t ret_conv = HTLCUpdate_clone_ptr(&arg_conv);
26041         return ret_conv;
26042 }
26043
26044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26045         LDKHTLCUpdate orig_conv;
26046         orig_conv.inner = untag_ptr(orig);
26047         orig_conv.is_owned = ptr_is_owned(orig);
26048         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26049         orig_conv.is_owned = false;
26050         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
26051         int64_t ret_ref = 0;
26052         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26053         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26054         return ret_ref;
26055 }
26056
26057 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
26058         LDKHTLCUpdate obj_conv;
26059         obj_conv.inner = untag_ptr(obj);
26060         obj_conv.is_owned = ptr_is_owned(obj);
26061         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26062         obj_conv.is_owned = false;
26063         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
26064         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26065         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26066         CVec_u8Z_free(ret_var);
26067         return ret_arr;
26068 }
26069
26070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26071         LDKu8slice ser_ref;
26072         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26073         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26074         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
26075         *ret_conv = HTLCUpdate_read(ser_ref);
26076         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26077         return tag_ptr(ret_conv, true);
26078 }
26079
26080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26081         if (!ptr_is_owned(this_ptr)) return;
26082         void* this_ptr_ptr = untag_ptr(this_ptr);
26083         CHECK_ACCESS(this_ptr_ptr);
26084         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
26085         FREE(untag_ptr(this_ptr));
26086         Balance_free(this_ptr_conv);
26087 }
26088
26089 static inline uint64_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
26090         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26091         *ret_copy = Balance_clone(arg);
26092         int64_t ret_ref = tag_ptr(ret_copy, true);
26093         return ret_ref;
26094 }
26095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26096         LDKBalance* arg_conv = (LDKBalance*)untag_ptr(arg);
26097         int64_t ret_conv = Balance_clone_ptr(arg_conv);
26098         return ret_conv;
26099 }
26100
26101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26102         LDKBalance* orig_conv = (LDKBalance*)untag_ptr(orig);
26103         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26104         *ret_copy = Balance_clone(orig_conv);
26105         int64_t ret_ref = tag_ptr(ret_copy, true);
26106         return ret_ref;
26107 }
26108
26109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
26110         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26111         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
26112         int64_t ret_ref = tag_ptr(ret_copy, true);
26113         return ret_ref;
26114 }
26115
26116 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) {
26117         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26118         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
26119         int64_t ret_ref = tag_ptr(ret_copy, true);
26120         return ret_ref;
26121 }
26122
26123 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) {
26124         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26125         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
26126         int64_t ret_ref = tag_ptr(ret_copy, true);
26127         return ret_ref;
26128 }
26129
26130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1maybe_1claimable_1htlcawaiting_1timeout(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis, int32_t claimable_height) {
26131         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26132         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
26133         int64_t ret_ref = tag_ptr(ret_copy, true);
26134         return ret_ref;
26135 }
26136
26137 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26138         LDKBalance* a_conv = (LDKBalance*)untag_ptr(a);
26139         LDKBalance* b_conv = (LDKBalance*)untag_ptr(b);
26140         jboolean ret_conv = Balance_eq(a_conv, b_conv);
26141         return ret_conv;
26142 }
26143
26144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26145         LDKChannelMonitor this_obj_conv;
26146         this_obj_conv.inner = untag_ptr(this_obj);
26147         this_obj_conv.is_owned = ptr_is_owned(this_obj);
26148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26149         ChannelMonitor_free(this_obj_conv);
26150 }
26151
26152 static inline uint64_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
26153         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
26154         int64_t ret_ref = 0;
26155         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26156         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26157         return ret_ref;
26158 }
26159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26160         LDKChannelMonitor arg_conv;
26161         arg_conv.inner = untag_ptr(arg);
26162         arg_conv.is_owned = ptr_is_owned(arg);
26163         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26164         arg_conv.is_owned = false;
26165         int64_t ret_conv = ChannelMonitor_clone_ptr(&arg_conv);
26166         return ret_conv;
26167 }
26168
26169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26170         LDKChannelMonitor orig_conv;
26171         orig_conv.inner = untag_ptr(orig);
26172         orig_conv.is_owned = ptr_is_owned(orig);
26173         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26174         orig_conv.is_owned = false;
26175         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
26176         int64_t ret_ref = 0;
26177         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26178         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26179         return ret_ref;
26180 }
26181
26182 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
26183         LDKChannelMonitor obj_conv;
26184         obj_conv.inner = untag_ptr(obj);
26185         obj_conv.is_owned = ptr_is_owned(obj);
26186         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26187         obj_conv.is_owned = false;
26188         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
26189         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26190         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26191         CVec_u8Z_free(ret_var);
26192         return ret_arr;
26193 }
26194
26195 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) {
26196         LDKChannelMonitor this_arg_conv;
26197         this_arg_conv.inner = untag_ptr(this_arg);
26198         this_arg_conv.is_owned = ptr_is_owned(this_arg);
26199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26200         this_arg_conv.is_owned = false;
26201         LDKChannelMonitorUpdate updates_conv;
26202         updates_conv.inner = untag_ptr(updates);
26203         updates_conv.is_owned = ptr_is_owned(updates);
26204         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
26205         updates_conv.is_owned = false;
26206         void* broadcaster_ptr = untag_ptr(broadcaster);
26207         if (ptr_is_owned(broadcaster)) { CHECK_ACCESS(broadcaster_ptr); }
26208         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
26209         void* fee_estimator_ptr = untag_ptr(fee_estimator);
26210         CHECK_ACCESS(fee_estimator_ptr);
26211         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26212         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
26213                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26214                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
26215         }
26216         void* logger_ptr = untag_ptr(logger);
26217         if (ptr_is_owned(logger)) { CHECK_ACCESS(logger_ptr); }
26218         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
26219         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
26220         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
26221         return tag_ptr(ret_conv, true);
26222 }
26223
26224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
26225         LDKChannelMonitor this_arg_conv;
26226         this_arg_conv.inner = untag_ptr(this_arg);
26227         this_arg_conv.is_owned = ptr_is_owned(this_arg);
26228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26229         this_arg_conv.is_owned = false;
26230         int64_t ret_conv = ChannelMonitor_get_latest_update_id(&this_arg_conv);
26231         return ret_conv;
26232 }
26233
26234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
26235         LDKChannelMonitor this_arg_conv;
26236         this_arg_conv.inner = untag_ptr(this_arg);
26237         this_arg_conv.is_owned = ptr_is_owned(this_arg);
26238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26239         this_arg_conv.is_owned = false;
26240         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
26241         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
26242         return tag_ptr(ret_conv, true);
26243 }
26244
26245 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
26246         LDKChannelMonitor this_arg_conv;
26247         this_arg_conv.inner = untag_ptr(this_arg);
26248         this_arg_conv.is_owned = ptr_is_owned(this_arg);
26249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26250         this_arg_conv.is_owned = false;
26251         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
26252         int64_tArray ret_arr = NULL;
26253         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26254         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26255         for (size_t o = 0; o < ret_var.datalen; o++) {
26256                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
26257                 *ret_conv_40_conv = ret_var.data[o];
26258                 ret_arr_ptr[o] = tag_ptr(ret_conv_40_conv, true);
26259         }
26260         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26261         FREE(ret_var.data);
26262         return ret_arr;
26263 }
26264
26265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
26266         LDKChannelMonitor this_arg_conv;
26267         this_arg_conv.inner = untag_ptr(this_arg);
26268         this_arg_conv.is_owned = ptr_is_owned(this_arg);
26269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26270         this_arg_conv.is_owned = false;
26271         void* filter_ptr = untag_ptr(filter);
26272         if (ptr_is_owned(filter)) { CHECK_ACCESS(filter_ptr); }
26273         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
26274         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
26275 }
26276
26277 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
26278         LDKChannelMonitor this_arg_conv;
26279         this_arg_conv.inner = untag_ptr(this_arg);
26280         this_arg_conv.is_owned = ptr_is_owned(this_arg);
26281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26282         this_arg_conv.is_owned = false;
26283         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
26284         int64_tArray ret_arr = NULL;
26285         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26286         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26287         for (size_t o = 0; o < ret_var.datalen; o++) {
26288                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
26289                 *ret_conv_14_copy = ret_var.data[o];
26290                 int64_t ret_conv_14_ref = tag_ptr(ret_conv_14_copy, true);
26291                 ret_arr_ptr[o] = ret_conv_14_ref;
26292         }
26293         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26294         FREE(ret_var.data);
26295         return ret_arr;
26296 }
26297
26298 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
26299         LDKChannelMonitor this_arg_conv;
26300         this_arg_conv.inner = untag_ptr(this_arg);
26301         this_arg_conv.is_owned = ptr_is_owned(this_arg);
26302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26303         this_arg_conv.is_owned = false;
26304         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
26305         int64_tArray ret_arr = NULL;
26306         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26307         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26308         for (size_t h = 0; h < ret_var.datalen; h++) {
26309                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26310                 *ret_conv_7_copy = ret_var.data[h];
26311                 int64_t ret_conv_7_ref = tag_ptr(ret_conv_7_copy, true);
26312                 ret_arr_ptr[h] = ret_conv_7_ref;
26313         }
26314         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26315         FREE(ret_var.data);
26316         return ret_arr;
26317 }
26318
26319 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1counterparty_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
26320         LDKChannelMonitor this_arg_conv;
26321         this_arg_conv.inner = untag_ptr(this_arg);
26322         this_arg_conv.is_owned = ptr_is_owned(this_arg);
26323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26324         this_arg_conv.is_owned = false;
26325         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26326         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelMonitor_get_counterparty_node_id(&this_arg_conv).compressed_form);
26327         return ret_arr;
26328 }
26329
26330 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) {
26331         LDKChannelMonitor this_arg_conv;
26332         this_arg_conv.inner = untag_ptr(this_arg);
26333         this_arg_conv.is_owned = ptr_is_owned(this_arg);
26334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26335         this_arg_conv.is_owned = false;
26336         void* logger_ptr = untag_ptr(logger);
26337         if (ptr_is_owned(logger)) { CHECK_ACCESS(logger_ptr); }
26338         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
26339         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
26340         jobjectArray ret_arr = NULL;
26341         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
26342         ;
26343         for (size_t i = 0; i < ret_var.datalen; i++) {
26344                 LDKTransaction ret_conv_8_var = ret_var.data[i];
26345                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
26346                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
26347                 Transaction_free(ret_conv_8_var);
26348                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
26349         }
26350         
26351         FREE(ret_var.data);
26352         return ret_arr;
26353 }
26354
26355 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) {
26356         LDKChannelMonitor this_arg_conv;
26357         this_arg_conv.inner = untag_ptr(this_arg);
26358         this_arg_conv.is_owned = ptr_is_owned(this_arg);
26359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26360         this_arg_conv.is_owned = false;
26361         unsigned char header_arr[80];
26362         CHECK((*env)->GetArrayLength(env, header) == 80);
26363         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
26364         unsigned char (*header_ref)[80] = &header_arr;
26365         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
26366         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
26367         if (txdata_constr.datalen > 0)
26368                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
26369         else
26370                 txdata_constr.data = NULL;
26371         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
26372         for (size_t c = 0; c < txdata_constr.datalen; c++) {
26373                 int64_t txdata_conv_28 = txdata_vals[c];
26374                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
26375                 CHECK_ACCESS(txdata_conv_28_ptr);
26376                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
26377                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
26378                 txdata_constr.data[c] = txdata_conv_28_conv;
26379         }
26380         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
26381         void* broadcaster_ptr = untag_ptr(broadcaster);
26382         CHECK_ACCESS(broadcaster_ptr);
26383         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
26384         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26385                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26386                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
26387         }
26388         void* fee_estimator_ptr = untag_ptr(fee_estimator);
26389         CHECK_ACCESS(fee_estimator_ptr);
26390         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26391         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
26392                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26393                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
26394         }
26395         void* logger_ptr = untag_ptr(logger);
26396         CHECK_ACCESS(logger_ptr);
26397         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26398         if (logger_conv.free == LDKLogger_JCalls_free) {
26399                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26400                 LDKLogger_JCalls_cloned(&logger_conv);
26401         }
26402         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);
26403         int64_tArray ret_arr = NULL;
26404         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26405         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26406         for (size_t n = 0; n < ret_var.datalen; n++) {
26407                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
26408                 *ret_conv_39_conv = ret_var.data[n];
26409                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
26410         }
26411         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26412         FREE(ret_var.data);
26413         return ret_arr;
26414 }
26415
26416 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) {
26417         LDKChannelMonitor this_arg_conv;
26418         this_arg_conv.inner = untag_ptr(this_arg);
26419         this_arg_conv.is_owned = ptr_is_owned(this_arg);
26420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26421         this_arg_conv.is_owned = false;
26422         unsigned char header_arr[80];
26423         CHECK((*env)->GetArrayLength(env, header) == 80);
26424         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
26425         unsigned char (*header_ref)[80] = &header_arr;
26426         void* broadcaster_ptr = untag_ptr(broadcaster);
26427         CHECK_ACCESS(broadcaster_ptr);
26428         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
26429         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26430                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26431                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
26432         }
26433         void* fee_estimator_ptr = untag_ptr(fee_estimator);
26434         CHECK_ACCESS(fee_estimator_ptr);
26435         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26436         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
26437                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26438                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
26439         }
26440         void* logger_ptr = untag_ptr(logger);
26441         CHECK_ACCESS(logger_ptr);
26442         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26443         if (logger_conv.free == LDKLogger_JCalls_free) {
26444                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26445                 LDKLogger_JCalls_cloned(&logger_conv);
26446         }
26447         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
26448 }
26449
26450 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) {
26451         LDKChannelMonitor this_arg_conv;
26452         this_arg_conv.inner = untag_ptr(this_arg);
26453         this_arg_conv.is_owned = ptr_is_owned(this_arg);
26454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26455         this_arg_conv.is_owned = false;
26456         unsigned char header_arr[80];
26457         CHECK((*env)->GetArrayLength(env, header) == 80);
26458         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
26459         unsigned char (*header_ref)[80] = &header_arr;
26460         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
26461         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
26462         if (txdata_constr.datalen > 0)
26463                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
26464         else
26465                 txdata_constr.data = NULL;
26466         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
26467         for (size_t c = 0; c < txdata_constr.datalen; c++) {
26468                 int64_t txdata_conv_28 = txdata_vals[c];
26469                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
26470                 CHECK_ACCESS(txdata_conv_28_ptr);
26471                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
26472                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
26473                 txdata_constr.data[c] = txdata_conv_28_conv;
26474         }
26475         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
26476         void* broadcaster_ptr = untag_ptr(broadcaster);
26477         CHECK_ACCESS(broadcaster_ptr);
26478         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
26479         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26480                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26481                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
26482         }
26483         void* fee_estimator_ptr = untag_ptr(fee_estimator);
26484         CHECK_ACCESS(fee_estimator_ptr);
26485         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26486         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
26487                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26488                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
26489         }
26490         void* logger_ptr = untag_ptr(logger);
26491         CHECK_ACCESS(logger_ptr);
26492         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26493         if (logger_conv.free == LDKLogger_JCalls_free) {
26494                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26495                 LDKLogger_JCalls_cloned(&logger_conv);
26496         }
26497         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);
26498         int64_tArray ret_arr = NULL;
26499         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26500         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26501         for (size_t n = 0; n < ret_var.datalen; n++) {
26502                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
26503                 *ret_conv_39_conv = ret_var.data[n];
26504                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
26505         }
26506         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26507         FREE(ret_var.data);
26508         return ret_arr;
26509 }
26510
26511 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) {
26512         LDKChannelMonitor this_arg_conv;
26513         this_arg_conv.inner = untag_ptr(this_arg);
26514         this_arg_conv.is_owned = ptr_is_owned(this_arg);
26515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26516         this_arg_conv.is_owned = false;
26517         unsigned char txid_arr[32];
26518         CHECK((*env)->GetArrayLength(env, txid) == 32);
26519         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
26520         unsigned char (*txid_ref)[32] = &txid_arr;
26521         void* broadcaster_ptr = untag_ptr(broadcaster);
26522         CHECK_ACCESS(broadcaster_ptr);
26523         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
26524         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26525                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26526                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
26527         }
26528         void* fee_estimator_ptr = untag_ptr(fee_estimator);
26529         CHECK_ACCESS(fee_estimator_ptr);
26530         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26531         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
26532                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26533                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
26534         }
26535         void* logger_ptr = untag_ptr(logger);
26536         CHECK_ACCESS(logger_ptr);
26537         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26538         if (logger_conv.free == LDKLogger_JCalls_free) {
26539                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26540                 LDKLogger_JCalls_cloned(&logger_conv);
26541         }
26542         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
26543 }
26544
26545 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) {
26546         LDKChannelMonitor this_arg_conv;
26547         this_arg_conv.inner = untag_ptr(this_arg);
26548         this_arg_conv.is_owned = ptr_is_owned(this_arg);
26549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26550         this_arg_conv.is_owned = false;
26551         unsigned char header_arr[80];
26552         CHECK((*env)->GetArrayLength(env, header) == 80);
26553         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
26554         unsigned char (*header_ref)[80] = &header_arr;
26555         void* broadcaster_ptr = untag_ptr(broadcaster);
26556         CHECK_ACCESS(broadcaster_ptr);
26557         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
26558         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26559                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26560                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
26561         }
26562         void* fee_estimator_ptr = untag_ptr(fee_estimator);
26563         CHECK_ACCESS(fee_estimator_ptr);
26564         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26565         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
26566                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26567                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
26568         }
26569         void* logger_ptr = untag_ptr(logger);
26570         CHECK_ACCESS(logger_ptr);
26571         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26572         if (logger_conv.free == LDKLogger_JCalls_free) {
26573                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26574                 LDKLogger_JCalls_cloned(&logger_conv);
26575         }
26576         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
26577         int64_tArray ret_arr = NULL;
26578         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26579         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26580         for (size_t n = 0; n < ret_var.datalen; n++) {
26581                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
26582                 *ret_conv_39_conv = ret_var.data[n];
26583                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
26584         }
26585         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26586         FREE(ret_var.data);
26587         return ret_arr;
26588 }
26589
26590 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
26591         LDKChannelMonitor this_arg_conv;
26592         this_arg_conv.inner = untag_ptr(this_arg);
26593         this_arg_conv.is_owned = ptr_is_owned(this_arg);
26594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26595         this_arg_conv.is_owned = false;
26596         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
26597         jobjectArray ret_arr = NULL;
26598         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
26599         ;
26600         for (size_t i = 0; i < ret_var.datalen; i++) {
26601                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
26602                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
26603                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
26604         }
26605         
26606         FREE(ret_var.data);
26607         return ret_arr;
26608 }
26609
26610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
26611         LDKChannelMonitor this_arg_conv;
26612         this_arg_conv.inner = untag_ptr(this_arg);
26613         this_arg_conv.is_owned = ptr_is_owned(this_arg);
26614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26615         this_arg_conv.is_owned = false;
26616         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
26617         int64_t ret_ref = 0;
26618         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26619         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26620         return ret_ref;
26621 }
26622
26623 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) {
26624         LDKChannelMonitor this_arg_conv;
26625         this_arg_conv.inner = untag_ptr(this_arg);
26626         this_arg_conv.is_owned = ptr_is_owned(this_arg);
26627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26628         this_arg_conv.is_owned = false;
26629         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
26630         int64_tArray ret_arr = NULL;
26631         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26632         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26633         for (size_t j = 0; j < ret_var.datalen; j++) {
26634                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26635                 *ret_conv_9_copy = ret_var.data[j];
26636                 int64_t ret_conv_9_ref = tag_ptr(ret_conv_9_copy, true);
26637                 ret_arr_ptr[j] = ret_conv_9_ref;
26638         }
26639         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26640         FREE(ret_var.data);
26641         return ret_arr;
26642 }
26643
26644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
26645         LDKu8slice ser_ref;
26646         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26647         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26648         void* arg_ptr = untag_ptr(arg);
26649         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
26650         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
26651         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
26652         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
26653         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26654         return tag_ptr(ret_conv, true);
26655 }
26656
26657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26658         LDKOutPoint this_obj_conv;
26659         this_obj_conv.inner = untag_ptr(this_obj);
26660         this_obj_conv.is_owned = ptr_is_owned(this_obj);
26661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26662         OutPoint_free(this_obj_conv);
26663 }
26664
26665 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
26666         LDKOutPoint this_ptr_conv;
26667         this_ptr_conv.inner = untag_ptr(this_ptr);
26668         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26670         this_ptr_conv.is_owned = false;
26671         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26672         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
26673         return ret_arr;
26674 }
26675
26676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26677         LDKOutPoint this_ptr_conv;
26678         this_ptr_conv.inner = untag_ptr(this_ptr);
26679         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26681         this_ptr_conv.is_owned = false;
26682         LDKThirtyTwoBytes val_ref;
26683         CHECK((*env)->GetArrayLength(env, val) == 32);
26684         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26685         OutPoint_set_txid(&this_ptr_conv, val_ref);
26686 }
26687
26688 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
26689         LDKOutPoint this_ptr_conv;
26690         this_ptr_conv.inner = untag_ptr(this_ptr);
26691         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26693         this_ptr_conv.is_owned = false;
26694         int16_t ret_conv = OutPoint_get_index(&this_ptr_conv);
26695         return ret_conv;
26696 }
26697
26698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
26699         LDKOutPoint this_ptr_conv;
26700         this_ptr_conv.inner = untag_ptr(this_ptr);
26701         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26703         this_ptr_conv.is_owned = false;
26704         OutPoint_set_index(&this_ptr_conv, val);
26705 }
26706
26707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
26708         LDKThirtyTwoBytes txid_arg_ref;
26709         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
26710         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
26711         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
26712         int64_t ret_ref = 0;
26713         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26714         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26715         return ret_ref;
26716 }
26717
26718 static inline uint64_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
26719         LDKOutPoint ret_var = OutPoint_clone(arg);
26720         int64_t ret_ref = 0;
26721         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26722         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26723         return ret_ref;
26724 }
26725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26726         LDKOutPoint arg_conv;
26727         arg_conv.inner = untag_ptr(arg);
26728         arg_conv.is_owned = ptr_is_owned(arg);
26729         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26730         arg_conv.is_owned = false;
26731         int64_t ret_conv = OutPoint_clone_ptr(&arg_conv);
26732         return ret_conv;
26733 }
26734
26735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26736         LDKOutPoint orig_conv;
26737         orig_conv.inner = untag_ptr(orig);
26738         orig_conv.is_owned = ptr_is_owned(orig);
26739         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26740         orig_conv.is_owned = false;
26741         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
26742         int64_t ret_ref = 0;
26743         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26744         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26745         return ret_ref;
26746 }
26747
26748 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26749         LDKOutPoint a_conv;
26750         a_conv.inner = untag_ptr(a);
26751         a_conv.is_owned = ptr_is_owned(a);
26752         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26753         a_conv.is_owned = false;
26754         LDKOutPoint b_conv;
26755         b_conv.inner = untag_ptr(b);
26756         b_conv.is_owned = ptr_is_owned(b);
26757         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
26758         b_conv.is_owned = false;
26759         jboolean ret_conv = OutPoint_eq(&a_conv, &b_conv);
26760         return ret_conv;
26761 }
26762
26763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
26764         LDKOutPoint o_conv;
26765         o_conv.inner = untag_ptr(o);
26766         o_conv.is_owned = ptr_is_owned(o);
26767         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26768         o_conv.is_owned = false;
26769         int64_t ret_conv = OutPoint_hash(&o_conv);
26770         return ret_conv;
26771 }
26772
26773 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
26774         LDKOutPoint this_arg_conv;
26775         this_arg_conv.inner = untag_ptr(this_arg);
26776         this_arg_conv.is_owned = ptr_is_owned(this_arg);
26777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26778         this_arg_conv.is_owned = false;
26779         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26780         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
26781         return ret_arr;
26782 }
26783
26784 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
26785         LDKOutPoint obj_conv;
26786         obj_conv.inner = untag_ptr(obj);
26787         obj_conv.is_owned = ptr_is_owned(obj);
26788         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26789         obj_conv.is_owned = false;
26790         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
26791         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26792         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26793         CVec_u8Z_free(ret_var);
26794         return ret_arr;
26795 }
26796
26797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26798         LDKu8slice ser_ref;
26799         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26800         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26801         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
26802         *ret_conv = OutPoint_read(ser_ref);
26803         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26804         return tag_ptr(ret_conv, true);
26805 }
26806
26807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26808         LDKDelayedPaymentOutputDescriptor this_obj_conv;
26809         this_obj_conv.inner = untag_ptr(this_obj);
26810         this_obj_conv.is_owned = ptr_is_owned(this_obj);
26811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26812         DelayedPaymentOutputDescriptor_free(this_obj_conv);
26813 }
26814
26815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
26816         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26817         this_ptr_conv.inner = untag_ptr(this_ptr);
26818         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26820         this_ptr_conv.is_owned = false;
26821         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
26822         int64_t ret_ref = 0;
26823         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26824         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26825         return ret_ref;
26826 }
26827
26828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26829         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26830         this_ptr_conv.inner = untag_ptr(this_ptr);
26831         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26833         this_ptr_conv.is_owned = false;
26834         LDKOutPoint val_conv;
26835         val_conv.inner = untag_ptr(val);
26836         val_conv.is_owned = ptr_is_owned(val);
26837         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26838         val_conv = OutPoint_clone(&val_conv);
26839         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
26840 }
26841
26842 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
26843         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26844         this_ptr_conv.inner = untag_ptr(this_ptr);
26845         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26847         this_ptr_conv.is_owned = false;
26848         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26849         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
26850         return ret_arr;
26851 }
26852
26853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26854         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26855         this_ptr_conv.inner = untag_ptr(this_ptr);
26856         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26858         this_ptr_conv.is_owned = false;
26859         LDKPublicKey val_ref;
26860         CHECK((*env)->GetArrayLength(env, val) == 33);
26861         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26862         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
26863 }
26864
26865 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
26866         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26867         this_ptr_conv.inner = untag_ptr(this_ptr);
26868         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26870         this_ptr_conv.is_owned = false;
26871         int16_t ret_conv = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
26872         return ret_conv;
26873 }
26874
26875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
26876         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26877         this_ptr_conv.inner = untag_ptr(this_ptr);
26878         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26880         this_ptr_conv.is_owned = false;
26881         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
26882 }
26883
26884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1output(JNIEnv *env, jclass clz, int64_t this_ptr) {
26885         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26886         this_ptr_conv.inner = untag_ptr(this_ptr);
26887         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26889         this_ptr_conv.is_owned = false;
26890         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
26891         *ret_ref = DelayedPaymentOutputDescriptor_get_output(&this_ptr_conv);
26892         return tag_ptr(ret_ref, true);
26893 }
26894
26895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26896         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26897         this_ptr_conv.inner = untag_ptr(this_ptr);
26898         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26900         this_ptr_conv.is_owned = false;
26901         void* val_ptr = untag_ptr(val);
26902         CHECK_ACCESS(val_ptr);
26903         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
26904         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
26905         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
26906 }
26907
26908 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
26909         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26910         this_ptr_conv.inner = untag_ptr(this_ptr);
26911         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26913         this_ptr_conv.is_owned = false;
26914         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26915         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
26916         return ret_arr;
26917 }
26918
26919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26920         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26921         this_ptr_conv.inner = untag_ptr(this_ptr);
26922         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26924         this_ptr_conv.is_owned = false;
26925         LDKPublicKey val_ref;
26926         CHECK((*env)->GetArrayLength(env, val) == 33);
26927         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26928         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
26929 }
26930
26931 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26932         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26933         this_ptr_conv.inner = untag_ptr(this_ptr);
26934         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26936         this_ptr_conv.is_owned = false;
26937         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26938         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
26939         return ret_arr;
26940 }
26941
26942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26943         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26944         this_ptr_conv.inner = untag_ptr(this_ptr);
26945         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26947         this_ptr_conv.is_owned = false;
26948         LDKThirtyTwoBytes val_ref;
26949         CHECK((*env)->GetArrayLength(env, val) == 32);
26950         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26951         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
26952 }
26953
26954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26955         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26956         this_ptr_conv.inner = untag_ptr(this_ptr);
26957         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26959         this_ptr_conv.is_owned = false;
26960         int64_t ret_conv = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
26961         return ret_conv;
26962 }
26963
26964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26965         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26966         this_ptr_conv.inner = untag_ptr(this_ptr);
26967         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26969         this_ptr_conv.is_owned = false;
26970         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
26971 }
26972
26973 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) {
26974         LDKOutPoint outpoint_arg_conv;
26975         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
26976         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
26977         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
26978         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
26979         LDKPublicKey per_commitment_point_arg_ref;
26980         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
26981         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
26982         void* output_arg_ptr = untag_ptr(output_arg);
26983         CHECK_ACCESS(output_arg_ptr);
26984         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
26985         output_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(output_arg));
26986         LDKPublicKey revocation_pubkey_arg_ref;
26987         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
26988         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
26989         LDKThirtyTwoBytes channel_keys_id_arg_ref;
26990         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
26991         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
26992         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);
26993         int64_t ret_ref = 0;
26994         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26995         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26996         return ret_ref;
26997 }
26998
26999 static inline uint64_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
27000         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
27001         int64_t ret_ref = 0;
27002         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27003         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27004         return ret_ref;
27005 }
27006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27007         LDKDelayedPaymentOutputDescriptor arg_conv;
27008         arg_conv.inner = untag_ptr(arg);
27009         arg_conv.is_owned = ptr_is_owned(arg);
27010         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27011         arg_conv.is_owned = false;
27012         int64_t ret_conv = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
27013         return ret_conv;
27014 }
27015
27016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27017         LDKDelayedPaymentOutputDescriptor orig_conv;
27018         orig_conv.inner = untag_ptr(orig);
27019         orig_conv.is_owned = ptr_is_owned(orig);
27020         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27021         orig_conv.is_owned = false;
27022         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
27023         int64_t ret_ref = 0;
27024         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27025         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27026         return ret_ref;
27027 }
27028
27029 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
27030         LDKDelayedPaymentOutputDescriptor obj_conv;
27031         obj_conv.inner = untag_ptr(obj);
27032         obj_conv.is_owned = ptr_is_owned(obj);
27033         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27034         obj_conv.is_owned = false;
27035         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
27036         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27037         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27038         CVec_u8Z_free(ret_var);
27039         return ret_arr;
27040 }
27041
27042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27043         LDKu8slice ser_ref;
27044         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27045         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27046         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
27047         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
27048         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27049         return tag_ptr(ret_conv, true);
27050 }
27051
27052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27053         LDKStaticPaymentOutputDescriptor this_obj_conv;
27054         this_obj_conv.inner = untag_ptr(this_obj);
27055         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27057         StaticPaymentOutputDescriptor_free(this_obj_conv);
27058 }
27059
27060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
27061         LDKStaticPaymentOutputDescriptor this_ptr_conv;
27062         this_ptr_conv.inner = untag_ptr(this_ptr);
27063         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27065         this_ptr_conv.is_owned = false;
27066         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
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 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27074         LDKStaticPaymentOutputDescriptor this_ptr_conv;
27075         this_ptr_conv.inner = untag_ptr(this_ptr);
27076         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27078         this_ptr_conv.is_owned = false;
27079         LDKOutPoint val_conv;
27080         val_conv.inner = untag_ptr(val);
27081         val_conv.is_owned = ptr_is_owned(val);
27082         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27083         val_conv = OutPoint_clone(&val_conv);
27084         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
27085 }
27086
27087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1output(JNIEnv *env, jclass clz, int64_t this_ptr) {
27088         LDKStaticPaymentOutputDescriptor this_ptr_conv;
27089         this_ptr_conv.inner = untag_ptr(this_ptr);
27090         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27092         this_ptr_conv.is_owned = false;
27093         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
27094         *ret_ref = StaticPaymentOutputDescriptor_get_output(&this_ptr_conv);
27095         return tag_ptr(ret_ref, true);
27096 }
27097
27098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27099         LDKStaticPaymentOutputDescriptor this_ptr_conv;
27100         this_ptr_conv.inner = untag_ptr(this_ptr);
27101         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27103         this_ptr_conv.is_owned = false;
27104         void* val_ptr = untag_ptr(val);
27105         CHECK_ACCESS(val_ptr);
27106         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
27107         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
27108         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
27109 }
27110
27111 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27112         LDKStaticPaymentOutputDescriptor this_ptr_conv;
27113         this_ptr_conv.inner = untag_ptr(this_ptr);
27114         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27116         this_ptr_conv.is_owned = false;
27117         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27118         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
27119         return ret_arr;
27120 }
27121
27122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27123         LDKStaticPaymentOutputDescriptor this_ptr_conv;
27124         this_ptr_conv.inner = untag_ptr(this_ptr);
27125         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27127         this_ptr_conv.is_owned = false;
27128         LDKThirtyTwoBytes val_ref;
27129         CHECK((*env)->GetArrayLength(env, val) == 32);
27130         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27131         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
27132 }
27133
27134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
27135         LDKStaticPaymentOutputDescriptor this_ptr_conv;
27136         this_ptr_conv.inner = untag_ptr(this_ptr);
27137         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27139         this_ptr_conv.is_owned = false;
27140         int64_t ret_conv = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
27141         return ret_conv;
27142 }
27143
27144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27145         LDKStaticPaymentOutputDescriptor this_ptr_conv;
27146         this_ptr_conv.inner = untag_ptr(this_ptr);
27147         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27149         this_ptr_conv.is_owned = false;
27150         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
27151 }
27152
27153 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) {
27154         LDKOutPoint outpoint_arg_conv;
27155         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
27156         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
27157         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
27158         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
27159         void* output_arg_ptr = untag_ptr(output_arg);
27160         CHECK_ACCESS(output_arg_ptr);
27161         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
27162         output_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(output_arg));
27163         LDKThirtyTwoBytes channel_keys_id_arg_ref;
27164         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
27165         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
27166         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
27167         int64_t ret_ref = 0;
27168         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27169         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27170         return ret_ref;
27171 }
27172
27173 static inline uint64_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
27174         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
27175         int64_t ret_ref = 0;
27176         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27177         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27178         return ret_ref;
27179 }
27180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27181         LDKStaticPaymentOutputDescriptor arg_conv;
27182         arg_conv.inner = untag_ptr(arg);
27183         arg_conv.is_owned = ptr_is_owned(arg);
27184         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27185         arg_conv.is_owned = false;
27186         int64_t ret_conv = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
27187         return ret_conv;
27188 }
27189
27190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27191         LDKStaticPaymentOutputDescriptor orig_conv;
27192         orig_conv.inner = untag_ptr(orig);
27193         orig_conv.is_owned = ptr_is_owned(orig);
27194         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27195         orig_conv.is_owned = false;
27196         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
27197         int64_t ret_ref = 0;
27198         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27199         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27200         return ret_ref;
27201 }
27202
27203 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
27204         LDKStaticPaymentOutputDescriptor obj_conv;
27205         obj_conv.inner = untag_ptr(obj);
27206         obj_conv.is_owned = ptr_is_owned(obj);
27207         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27208         obj_conv.is_owned = false;
27209         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
27210         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27211         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27212         CVec_u8Z_free(ret_var);
27213         return ret_arr;
27214 }
27215
27216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27217         LDKu8slice ser_ref;
27218         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27219         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27220         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
27221         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
27222         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27223         return tag_ptr(ret_conv, true);
27224 }
27225
27226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27227         if (!ptr_is_owned(this_ptr)) return;
27228         void* this_ptr_ptr = untag_ptr(this_ptr);
27229         CHECK_ACCESS(this_ptr_ptr);
27230         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
27231         FREE(untag_ptr(this_ptr));
27232         SpendableOutputDescriptor_free(this_ptr_conv);
27233 }
27234
27235 static inline uint64_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
27236         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27237         *ret_copy = SpendableOutputDescriptor_clone(arg);
27238         int64_t ret_ref = tag_ptr(ret_copy, true);
27239         return ret_ref;
27240 }
27241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27242         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)untag_ptr(arg);
27243         int64_t ret_conv = SpendableOutputDescriptor_clone_ptr(arg_conv);
27244         return ret_conv;
27245 }
27246
27247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27248         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)untag_ptr(orig);
27249         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27250         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
27251         int64_t ret_ref = tag_ptr(ret_copy, true);
27252         return ret_ref;
27253 }
27254
27255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
27256         LDKOutPoint outpoint_conv;
27257         outpoint_conv.inner = untag_ptr(outpoint);
27258         outpoint_conv.is_owned = ptr_is_owned(outpoint);
27259         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
27260         outpoint_conv = OutPoint_clone(&outpoint_conv);
27261         void* output_ptr = untag_ptr(output);
27262         CHECK_ACCESS(output_ptr);
27263         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
27264         output_conv = TxOut_clone((LDKTxOut*)untag_ptr(output));
27265         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27266         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
27267         int64_t ret_ref = tag_ptr(ret_copy, true);
27268         return ret_ref;
27269 }
27270
27271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
27272         LDKDelayedPaymentOutputDescriptor a_conv;
27273         a_conv.inner = untag_ptr(a);
27274         a_conv.is_owned = ptr_is_owned(a);
27275         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27276         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
27277         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27278         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
27279         int64_t ret_ref = tag_ptr(ret_copy, true);
27280         return ret_ref;
27281 }
27282
27283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
27284         LDKStaticPaymentOutputDescriptor a_conv;
27285         a_conv.inner = untag_ptr(a);
27286         a_conv.is_owned = ptr_is_owned(a);
27287         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27288         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
27289         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27290         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
27291         int64_t ret_ref = tag_ptr(ret_copy, true);
27292         return ret_ref;
27293 }
27294
27295 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
27296         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)untag_ptr(obj);
27297         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
27298         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27299         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27300         CVec_u8Z_free(ret_var);
27301         return ret_arr;
27302 }
27303
27304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27305         LDKu8slice ser_ref;
27306         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27307         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27308         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
27309         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
27310         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27311         return tag_ptr(ret_conv, true);
27312 }
27313
27314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27315         if (!ptr_is_owned(this_ptr)) return;
27316         void* this_ptr_ptr = untag_ptr(this_ptr);
27317         CHECK_ACCESS(this_ptr_ptr);
27318         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
27319         FREE(untag_ptr(this_ptr));
27320         BaseSign_free(this_ptr_conv);
27321 }
27322
27323 static inline uint64_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
27324         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
27325         *ret_ret = Sign_clone(arg);
27326         return tag_ptr(ret_ret, true);
27327 }
27328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27329         void* arg_ptr = untag_ptr(arg);
27330         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
27331         LDKSign* arg_conv = (LDKSign*)arg_ptr;
27332         int64_t ret_conv = Sign_clone_ptr(arg_conv);
27333         return ret_conv;
27334 }
27335
27336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27337         void* orig_ptr = untag_ptr(orig);
27338         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
27339         LDKSign* orig_conv = (LDKSign*)orig_ptr;
27340         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
27341         *ret_ret = Sign_clone(orig_conv);
27342         return tag_ptr(ret_ret, true);
27343 }
27344
27345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27346         if (!ptr_is_owned(this_ptr)) return;
27347         void* this_ptr_ptr = untag_ptr(this_ptr);
27348         CHECK_ACCESS(this_ptr_ptr);
27349         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
27350         FREE(untag_ptr(this_ptr));
27351         Sign_free(this_ptr_conv);
27352 }
27353
27354 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27355         LDKRecipient* orig_conv = (LDKRecipient*)untag_ptr(orig);
27356         jclass ret_conv = LDKRecipient_to_java(env, Recipient_clone(orig_conv));
27357         return ret_conv;
27358 }
27359
27360 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1node(JNIEnv *env, jclass clz) {
27361         jclass ret_conv = LDKRecipient_to_java(env, Recipient_node());
27362         return ret_conv;
27363 }
27364
27365 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1phantom_1node(JNIEnv *env, jclass clz) {
27366         jclass ret_conv = LDKRecipient_to_java(env, Recipient_phantom_node());
27367         return ret_conv;
27368 }
27369
27370 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27371         if (!ptr_is_owned(this_ptr)) return;
27372         void* this_ptr_ptr = untag_ptr(this_ptr);
27373         CHECK_ACCESS(this_ptr_ptr);
27374         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
27375         FREE(untag_ptr(this_ptr));
27376         KeysInterface_free(this_ptr_conv);
27377 }
27378
27379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27380         LDKInMemorySigner this_obj_conv;
27381         this_obj_conv.inner = untag_ptr(this_obj);
27382         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27384         InMemorySigner_free(this_obj_conv);
27385 }
27386
27387 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
27388         LDKInMemorySigner this_ptr_conv;
27389         this_ptr_conv.inner = untag_ptr(this_ptr);
27390         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27392         this_ptr_conv.is_owned = false;
27393         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27394         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
27395         return ret_arr;
27396 }
27397
27398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27399         LDKInMemorySigner this_ptr_conv;
27400         this_ptr_conv.inner = untag_ptr(this_ptr);
27401         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27403         this_ptr_conv.is_owned = false;
27404         LDKSecretKey val_ref;
27405         CHECK((*env)->GetArrayLength(env, val) == 32);
27406         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
27407         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
27408 }
27409
27410 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
27411         LDKInMemorySigner this_ptr_conv;
27412         this_ptr_conv.inner = untag_ptr(this_ptr);
27413         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27415         this_ptr_conv.is_owned = false;
27416         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27417         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
27418         return ret_arr;
27419 }
27420
27421 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27422         LDKInMemorySigner this_ptr_conv;
27423         this_ptr_conv.inner = untag_ptr(this_ptr);
27424         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27426         this_ptr_conv.is_owned = false;
27427         LDKSecretKey val_ref;
27428         CHECK((*env)->GetArrayLength(env, val) == 32);
27429         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
27430         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
27431 }
27432
27433 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
27434         LDKInMemorySigner this_ptr_conv;
27435         this_ptr_conv.inner = untag_ptr(this_ptr);
27436         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27438         this_ptr_conv.is_owned = false;
27439         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27440         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
27441         return ret_arr;
27442 }
27443
27444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27445         LDKInMemorySigner this_ptr_conv;
27446         this_ptr_conv.inner = untag_ptr(this_ptr);
27447         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27449         this_ptr_conv.is_owned = false;
27450         LDKSecretKey val_ref;
27451         CHECK((*env)->GetArrayLength(env, val) == 32);
27452         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
27453         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
27454 }
27455
27456 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
27457         LDKInMemorySigner this_ptr_conv;
27458         this_ptr_conv.inner = untag_ptr(this_ptr);
27459         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27461         this_ptr_conv.is_owned = false;
27462         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27463         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
27464         return ret_arr;
27465 }
27466
27467 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) {
27468         LDKInMemorySigner this_ptr_conv;
27469         this_ptr_conv.inner = untag_ptr(this_ptr);
27470         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27472         this_ptr_conv.is_owned = false;
27473         LDKSecretKey val_ref;
27474         CHECK((*env)->GetArrayLength(env, val) == 32);
27475         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
27476         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
27477 }
27478
27479 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
27480         LDKInMemorySigner this_ptr_conv;
27481         this_ptr_conv.inner = untag_ptr(this_ptr);
27482         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27484         this_ptr_conv.is_owned = false;
27485         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27486         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
27487         return ret_arr;
27488 }
27489
27490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27491         LDKInMemorySigner this_ptr_conv;
27492         this_ptr_conv.inner = untag_ptr(this_ptr);
27493         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27495         this_ptr_conv.is_owned = false;
27496         LDKSecretKey val_ref;
27497         CHECK((*env)->GetArrayLength(env, val) == 32);
27498         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
27499         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
27500 }
27501
27502 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
27503         LDKInMemorySigner this_ptr_conv;
27504         this_ptr_conv.inner = untag_ptr(this_ptr);
27505         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27507         this_ptr_conv.is_owned = false;
27508         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27509         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
27510         return ret_arr;
27511 }
27512
27513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27514         LDKInMemorySigner this_ptr_conv;
27515         this_ptr_conv.inner = untag_ptr(this_ptr);
27516         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27518         this_ptr_conv.is_owned = false;
27519         LDKThirtyTwoBytes val_ref;
27520         CHECK((*env)->GetArrayLength(env, val) == 32);
27521         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27522         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
27523 }
27524
27525 static inline uint64_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
27526         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
27527         int64_t ret_ref = 0;
27528         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27529         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27530         return ret_ref;
27531 }
27532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27533         LDKInMemorySigner arg_conv;
27534         arg_conv.inner = untag_ptr(arg);
27535         arg_conv.is_owned = ptr_is_owned(arg);
27536         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27537         arg_conv.is_owned = false;
27538         int64_t ret_conv = InMemorySigner_clone_ptr(&arg_conv);
27539         return ret_conv;
27540 }
27541
27542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27543         LDKInMemorySigner orig_conv;
27544         orig_conv.inner = untag_ptr(orig);
27545         orig_conv.is_owned = ptr_is_owned(orig);
27546         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27547         orig_conv.is_owned = false;
27548         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
27549         int64_t ret_ref = 0;
27550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27551         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27552         return ret_ref;
27553 }
27554
27555 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) {
27556         LDKSecretKey node_secret_ref;
27557         CHECK((*env)->GetArrayLength(env, node_secret) == 32);
27558         (*env)->GetByteArrayRegion(env, node_secret, 0, 32, node_secret_ref.bytes);
27559         LDKSecretKey funding_key_ref;
27560         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
27561         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
27562         LDKSecretKey revocation_base_key_ref;
27563         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
27564         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
27565         LDKSecretKey payment_key_ref;
27566         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
27567         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
27568         LDKSecretKey delayed_payment_base_key_ref;
27569         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
27570         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
27571         LDKSecretKey htlc_base_key_ref;
27572         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
27573         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
27574         LDKThirtyTwoBytes commitment_seed_ref;
27575         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
27576         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
27577         LDKThirtyTwoBytes channel_keys_id_ref;
27578         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
27579         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
27580         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);
27581         int64_t ret_ref = 0;
27582         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27583         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27584         return ret_ref;
27585 }
27586
27587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
27588         LDKInMemorySigner this_arg_conv;
27589         this_arg_conv.inner = untag_ptr(this_arg);
27590         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27592         this_arg_conv.is_owned = false;
27593         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
27594         int64_t ret_ref = 0;
27595         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27596         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27597         return ret_ref;
27598 }
27599
27600 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
27601         LDKInMemorySigner this_arg_conv;
27602         this_arg_conv.inner = untag_ptr(this_arg);
27603         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27605         this_arg_conv.is_owned = false;
27606         int16_t ret_conv = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
27607         return ret_conv;
27608 }
27609
27610 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
27611         LDKInMemorySigner this_arg_conv;
27612         this_arg_conv.inner = untag_ptr(this_arg);
27613         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27615         this_arg_conv.is_owned = false;
27616         int16_t ret_conv = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
27617         return ret_conv;
27618 }
27619
27620 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
27621         LDKInMemorySigner this_arg_conv;
27622         this_arg_conv.inner = untag_ptr(this_arg);
27623         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27625         this_arg_conv.is_owned = false;
27626         jboolean ret_conv = InMemorySigner_is_outbound(&this_arg_conv);
27627         return ret_conv;
27628 }
27629
27630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
27631         LDKInMemorySigner this_arg_conv;
27632         this_arg_conv.inner = untag_ptr(this_arg);
27633         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27635         this_arg_conv.is_owned = false;
27636         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
27637         int64_t ret_ref = 0;
27638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27639         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27640         return ret_ref;
27641 }
27642
27643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
27644         LDKInMemorySigner this_arg_conv;
27645         this_arg_conv.inner = untag_ptr(this_arg);
27646         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27648         this_arg_conv.is_owned = false;
27649         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
27650         int64_t ret_ref = 0;
27651         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27652         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27653         return ret_ref;
27654 }
27655
27656 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
27657         LDKInMemorySigner this_arg_conv;
27658         this_arg_conv.inner = untag_ptr(this_arg);
27659         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27661         this_arg_conv.is_owned = false;
27662         jboolean ret_conv = InMemorySigner_opt_anchors(&this_arg_conv);
27663         return ret_conv;
27664 }
27665
27666 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) {
27667         LDKInMemorySigner this_arg_conv;
27668         this_arg_conv.inner = untag_ptr(this_arg);
27669         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27671         this_arg_conv.is_owned = false;
27672         LDKTransaction spend_tx_ref;
27673         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
27674         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
27675         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
27676         spend_tx_ref.data_is_owned = true;
27677         LDKStaticPaymentOutputDescriptor descriptor_conv;
27678         descriptor_conv.inner = untag_ptr(descriptor);
27679         descriptor_conv.is_owned = ptr_is_owned(descriptor);
27680         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
27681         descriptor_conv.is_owned = false;
27682         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
27683         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
27684         return tag_ptr(ret_conv, true);
27685 }
27686
27687 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) {
27688         LDKInMemorySigner this_arg_conv;
27689         this_arg_conv.inner = untag_ptr(this_arg);
27690         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27692         this_arg_conv.is_owned = false;
27693         LDKTransaction spend_tx_ref;
27694         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
27695         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
27696         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
27697         spend_tx_ref.data_is_owned = true;
27698         LDKDelayedPaymentOutputDescriptor descriptor_conv;
27699         descriptor_conv.inner = untag_ptr(descriptor);
27700         descriptor_conv.is_owned = ptr_is_owned(descriptor);
27701         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
27702         descriptor_conv.is_owned = false;
27703         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
27704         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
27705         return tag_ptr(ret_conv, true);
27706 }
27707
27708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
27709         LDKInMemorySigner this_arg_conv;
27710         this_arg_conv.inner = untag_ptr(this_arg);
27711         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27713         this_arg_conv.is_owned = false;
27714         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
27715         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
27716         return tag_ptr(ret_ret, true);
27717 }
27718
27719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
27720         LDKInMemorySigner this_arg_conv;
27721         this_arg_conv.inner = untag_ptr(this_arg);
27722         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27724         this_arg_conv.is_owned = false;
27725         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
27726         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
27727         return tag_ptr(ret_ret, true);
27728 }
27729
27730 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
27731         LDKInMemorySigner obj_conv;
27732         obj_conv.inner = untag_ptr(obj);
27733         obj_conv.is_owned = ptr_is_owned(obj);
27734         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27735         obj_conv.is_owned = false;
27736         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
27737         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27738         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27739         CVec_u8Z_free(ret_var);
27740         return ret_arr;
27741 }
27742
27743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser, int8_tArray arg) {
27744         LDKu8slice ser_ref;
27745         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27746         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27747         LDKSecretKey arg_ref;
27748         CHECK((*env)->GetArrayLength(env, arg) == 32);
27749         (*env)->GetByteArrayRegion(env, arg, 0, 32, arg_ref.bytes);
27750         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
27751         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
27752         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27753         return tag_ptr(ret_conv, true);
27754 }
27755
27756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27757         LDKKeysManager this_obj_conv;
27758         this_obj_conv.inner = untag_ptr(this_obj);
27759         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27761         KeysManager_free(this_obj_conv);
27762 }
27763
27764 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) {
27765         unsigned char seed_arr[32];
27766         CHECK((*env)->GetArrayLength(env, seed) == 32);
27767         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
27768         unsigned char (*seed_ref)[32] = &seed_arr;
27769         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
27770         int64_t ret_ref = 0;
27771         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27772         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27773         return ret_ref;
27774 }
27775
27776 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) {
27777         LDKKeysManager this_arg_conv;
27778         this_arg_conv.inner = untag_ptr(this_arg);
27779         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27781         this_arg_conv.is_owned = false;
27782         unsigned char params_arr[32];
27783         CHECK((*env)->GetArrayLength(env, params) == 32);
27784         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
27785         unsigned char (*params_ref)[32] = &params_arr;
27786         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
27787         int64_t ret_ref = 0;
27788         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27789         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27790         return ret_ref;
27791 }
27792
27793 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) {
27794         LDKKeysManager this_arg_conv;
27795         this_arg_conv.inner = untag_ptr(this_arg);
27796         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27798         this_arg_conv.is_owned = false;
27799         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
27800         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
27801         if (descriptors_constr.datalen > 0)
27802                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
27803         else
27804                 descriptors_constr.data = NULL;
27805         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
27806         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
27807                 int64_t descriptors_conv_27 = descriptors_vals[b];
27808                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
27809                 CHECK_ACCESS(descriptors_conv_27_ptr);
27810                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
27811                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
27812                 descriptors_constr.data[b] = descriptors_conv_27_conv;
27813         }
27814         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
27815         LDKCVec_TxOutZ outputs_constr;
27816         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
27817         if (outputs_constr.datalen > 0)
27818                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
27819         else
27820                 outputs_constr.data = NULL;
27821         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
27822         for (size_t h = 0; h < outputs_constr.datalen; h++) {
27823                 int64_t outputs_conv_7 = outputs_vals[h];
27824                 void* outputs_conv_7_ptr = untag_ptr(outputs_conv_7);
27825                 CHECK_ACCESS(outputs_conv_7_ptr);
27826                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
27827                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(outputs_conv_7));
27828                 outputs_constr.data[h] = outputs_conv_7_conv;
27829         }
27830         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
27831         LDKCVec_u8Z change_destination_script_ref;
27832         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
27833         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
27834         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
27835         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
27836         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
27837         return tag_ptr(ret_conv, true);
27838 }
27839
27840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
27841         LDKKeysManager this_arg_conv;
27842         this_arg_conv.inner = untag_ptr(this_arg);
27843         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27845         this_arg_conv.is_owned = false;
27846         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
27847         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
27848         return tag_ptr(ret_ret, true);
27849 }
27850
27851 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27852         LDKPhantomKeysManager this_obj_conv;
27853         this_obj_conv.inner = untag_ptr(this_obj);
27854         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27856         PhantomKeysManager_free(this_obj_conv);
27857 }
27858
27859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
27860         LDKPhantomKeysManager this_arg_conv;
27861         this_arg_conv.inner = untag_ptr(this_arg);
27862         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27864         this_arg_conv.is_owned = false;
27865         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
27866         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
27867         return tag_ptr(ret_ret, true);
27868 }
27869
27870 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) {
27871         unsigned char seed_arr[32];
27872         CHECK((*env)->GetArrayLength(env, seed) == 32);
27873         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
27874         unsigned char (*seed_ref)[32] = &seed_arr;
27875         unsigned char cross_node_seed_arr[32];
27876         CHECK((*env)->GetArrayLength(env, cross_node_seed) == 32);
27877         (*env)->GetByteArrayRegion(env, cross_node_seed, 0, 32, cross_node_seed_arr);
27878         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
27879         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
27880         int64_t ret_ref = 0;
27881         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27882         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27883         return ret_ref;
27884 }
27885
27886 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) {
27887         LDKPhantomKeysManager this_arg_conv;
27888         this_arg_conv.inner = untag_ptr(this_arg);
27889         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27891         this_arg_conv.is_owned = false;
27892         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
27893         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
27894         if (descriptors_constr.datalen > 0)
27895                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
27896         else
27897                 descriptors_constr.data = NULL;
27898         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
27899         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
27900                 int64_t descriptors_conv_27 = descriptors_vals[b];
27901                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
27902                 CHECK_ACCESS(descriptors_conv_27_ptr);
27903                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
27904                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
27905                 descriptors_constr.data[b] = descriptors_conv_27_conv;
27906         }
27907         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
27908         LDKCVec_TxOutZ outputs_constr;
27909         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
27910         if (outputs_constr.datalen > 0)
27911                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
27912         else
27913                 outputs_constr.data = NULL;
27914         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
27915         for (size_t h = 0; h < outputs_constr.datalen; h++) {
27916                 int64_t outputs_conv_7 = outputs_vals[h];
27917                 void* outputs_conv_7_ptr = untag_ptr(outputs_conv_7);
27918                 CHECK_ACCESS(outputs_conv_7_ptr);
27919                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
27920                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(outputs_conv_7));
27921                 outputs_constr.data[h] = outputs_conv_7_conv;
27922         }
27923         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
27924         LDKCVec_u8Z change_destination_script_ref;
27925         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
27926         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
27927         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
27928         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
27929         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
27930         return tag_ptr(ret_conv, true);
27931 }
27932
27933 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) {
27934         LDKPhantomKeysManager this_arg_conv;
27935         this_arg_conv.inner = untag_ptr(this_arg);
27936         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27938         this_arg_conv.is_owned = false;
27939         unsigned char params_arr[32];
27940         CHECK((*env)->GetArrayLength(env, params) == 32);
27941         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
27942         unsigned char (*params_ref)[32] = &params_arr;
27943         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
27944         int64_t ret_ref = 0;
27945         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27946         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27947         return ret_ref;
27948 }
27949
27950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27951         LDKChannelManager this_obj_conv;
27952         this_obj_conv.inner = untag_ptr(this_obj);
27953         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27955         ChannelManager_free(this_obj_conv);
27956 }
27957
27958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27959         LDKChainParameters this_obj_conv;
27960         this_obj_conv.inner = untag_ptr(this_obj);
27961         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27963         ChainParameters_free(this_obj_conv);
27964 }
27965
27966 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
27967         LDKChainParameters this_ptr_conv;
27968         this_ptr_conv.inner = untag_ptr(this_ptr);
27969         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27971         this_ptr_conv.is_owned = false;
27972         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
27973         return ret_conv;
27974 }
27975
27976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
27977         LDKChainParameters this_ptr_conv;
27978         this_ptr_conv.inner = untag_ptr(this_ptr);
27979         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27981         this_ptr_conv.is_owned = false;
27982         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
27983         ChainParameters_set_network(&this_ptr_conv, val_conv);
27984 }
27985
27986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
27987         LDKChainParameters this_ptr_conv;
27988         this_ptr_conv.inner = untag_ptr(this_ptr);
27989         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27991         this_ptr_conv.is_owned = false;
27992         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
27993         int64_t ret_ref = 0;
27994         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27995         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27996         return ret_ref;
27997 }
27998
27999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28000         LDKChainParameters this_ptr_conv;
28001         this_ptr_conv.inner = untag_ptr(this_ptr);
28002         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28004         this_ptr_conv.is_owned = false;
28005         LDKBestBlock val_conv;
28006         val_conv.inner = untag_ptr(val);
28007         val_conv.is_owned = ptr_is_owned(val);
28008         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28009         val_conv = BestBlock_clone(&val_conv);
28010         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
28011 }
28012
28013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
28014         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
28015         LDKBestBlock best_block_arg_conv;
28016         best_block_arg_conv.inner = untag_ptr(best_block_arg);
28017         best_block_arg_conv.is_owned = ptr_is_owned(best_block_arg);
28018         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
28019         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
28020         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
28021         int64_t ret_ref = 0;
28022         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28023         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28024         return ret_ref;
28025 }
28026
28027 static inline uint64_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
28028         LDKChainParameters ret_var = ChainParameters_clone(arg);
28029         int64_t ret_ref = 0;
28030         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28031         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28032         return ret_ref;
28033 }
28034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28035         LDKChainParameters arg_conv;
28036         arg_conv.inner = untag_ptr(arg);
28037         arg_conv.is_owned = ptr_is_owned(arg);
28038         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28039         arg_conv.is_owned = false;
28040         int64_t ret_conv = ChainParameters_clone_ptr(&arg_conv);
28041         return ret_conv;
28042 }
28043
28044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28045         LDKChainParameters orig_conv;
28046         orig_conv.inner = untag_ptr(orig);
28047         orig_conv.is_owned = ptr_is_owned(orig);
28048         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28049         orig_conv.is_owned = false;
28050         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
28051         int64_t ret_ref = 0;
28052         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28053         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28054         return ret_ref;
28055 }
28056
28057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28058         LDKCounterpartyForwardingInfo this_obj_conv;
28059         this_obj_conv.inner = untag_ptr(this_obj);
28060         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28062         CounterpartyForwardingInfo_free(this_obj_conv);
28063 }
28064
28065 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28066         LDKCounterpartyForwardingInfo this_ptr_conv;
28067         this_ptr_conv.inner = untag_ptr(this_ptr);
28068         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28070         this_ptr_conv.is_owned = false;
28071         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
28072         return ret_conv;
28073 }
28074
28075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
28076         LDKCounterpartyForwardingInfo this_ptr_conv;
28077         this_ptr_conv.inner = untag_ptr(this_ptr);
28078         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28080         this_ptr_conv.is_owned = false;
28081         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
28082 }
28083
28084 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
28085         LDKCounterpartyForwardingInfo this_ptr_conv;
28086         this_ptr_conv.inner = untag_ptr(this_ptr);
28087         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28089         this_ptr_conv.is_owned = false;
28090         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
28091         return ret_conv;
28092 }
28093
28094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
28095         LDKCounterpartyForwardingInfo this_ptr_conv;
28096         this_ptr_conv.inner = untag_ptr(this_ptr);
28097         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28099         this_ptr_conv.is_owned = false;
28100         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
28101 }
28102
28103 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
28104         LDKCounterpartyForwardingInfo this_ptr_conv;
28105         this_ptr_conv.inner = untag_ptr(this_ptr);
28106         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28108         this_ptr_conv.is_owned = false;
28109         int16_t ret_conv = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
28110         return ret_conv;
28111 }
28112
28113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
28114         LDKCounterpartyForwardingInfo this_ptr_conv;
28115         this_ptr_conv.inner = untag_ptr(this_ptr);
28116         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28118         this_ptr_conv.is_owned = false;
28119         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
28120 }
28121
28122 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) {
28123         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
28124         int64_t ret_ref = 0;
28125         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28126         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28127         return ret_ref;
28128 }
28129
28130 static inline uint64_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
28131         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
28132         int64_t ret_ref = 0;
28133         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28134         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28135         return ret_ref;
28136 }
28137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28138         LDKCounterpartyForwardingInfo arg_conv;
28139         arg_conv.inner = untag_ptr(arg);
28140         arg_conv.is_owned = ptr_is_owned(arg);
28141         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28142         arg_conv.is_owned = false;
28143         int64_t ret_conv = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
28144         return ret_conv;
28145 }
28146
28147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28148         LDKCounterpartyForwardingInfo orig_conv;
28149         orig_conv.inner = untag_ptr(orig);
28150         orig_conv.is_owned = ptr_is_owned(orig);
28151         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28152         orig_conv.is_owned = false;
28153         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
28154         int64_t ret_ref = 0;
28155         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28156         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28157         return ret_ref;
28158 }
28159
28160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28161         LDKChannelCounterparty this_obj_conv;
28162         this_obj_conv.inner = untag_ptr(this_obj);
28163         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28165         ChannelCounterparty_free(this_obj_conv);
28166 }
28167
28168 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28169         LDKChannelCounterparty this_ptr_conv;
28170         this_ptr_conv.inner = untag_ptr(this_ptr);
28171         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28173         this_ptr_conv.is_owned = false;
28174         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28175         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
28176         return ret_arr;
28177 }
28178
28179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28180         LDKChannelCounterparty this_ptr_conv;
28181         this_ptr_conv.inner = untag_ptr(this_ptr);
28182         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28184         this_ptr_conv.is_owned = false;
28185         LDKPublicKey val_ref;
28186         CHECK((*env)->GetArrayLength(env, val) == 33);
28187         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28188         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
28189 }
28190
28191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
28192         LDKChannelCounterparty this_ptr_conv;
28193         this_ptr_conv.inner = untag_ptr(this_ptr);
28194         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28196         this_ptr_conv.is_owned = false;
28197         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
28198         int64_t ret_ref = 0;
28199         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28200         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28201         return ret_ref;
28202 }
28203
28204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28205         LDKChannelCounterparty this_ptr_conv;
28206         this_ptr_conv.inner = untag_ptr(this_ptr);
28207         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28209         this_ptr_conv.is_owned = false;
28210         LDKInitFeatures val_conv;
28211         val_conv.inner = untag_ptr(val);
28212         val_conv.is_owned = ptr_is_owned(val);
28213         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28214         val_conv = InitFeatures_clone(&val_conv);
28215         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
28216 }
28217
28218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
28219         LDKChannelCounterparty this_ptr_conv;
28220         this_ptr_conv.inner = untag_ptr(this_ptr);
28221         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28223         this_ptr_conv.is_owned = false;
28224         int64_t ret_conv = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
28225         return ret_conv;
28226 }
28227
28228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28229         LDKChannelCounterparty this_ptr_conv;
28230         this_ptr_conv.inner = untag_ptr(this_ptr);
28231         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28233         this_ptr_conv.is_owned = false;
28234         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
28235 }
28236
28237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
28238         LDKChannelCounterparty this_ptr_conv;
28239         this_ptr_conv.inner = untag_ptr(this_ptr);
28240         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28242         this_ptr_conv.is_owned = false;
28243         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
28244         int64_t ret_ref = 0;
28245         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28246         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28247         return ret_ref;
28248 }
28249
28250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28251         LDKChannelCounterparty this_ptr_conv;
28252         this_ptr_conv.inner = untag_ptr(this_ptr);
28253         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28255         this_ptr_conv.is_owned = false;
28256         LDKCounterpartyForwardingInfo val_conv;
28257         val_conv.inner = untag_ptr(val);
28258         val_conv.is_owned = ptr_is_owned(val);
28259         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28260         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
28261         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
28262 }
28263
28264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28265         LDKChannelCounterparty this_ptr_conv;
28266         this_ptr_conv.inner = untag_ptr(this_ptr);
28267         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28269         this_ptr_conv.is_owned = false;
28270         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
28271         *ret_copy = ChannelCounterparty_get_outbound_htlc_minimum_msat(&this_ptr_conv);
28272         int64_t ret_ref = tag_ptr(ret_copy, true);
28273         return ret_ref;
28274 }
28275
28276 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) {
28277         LDKChannelCounterparty this_ptr_conv;
28278         this_ptr_conv.inner = untag_ptr(this_ptr);
28279         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28281         this_ptr_conv.is_owned = false;
28282         void* val_ptr = untag_ptr(val);
28283         CHECK_ACCESS(val_ptr);
28284         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
28285         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
28286         ChannelCounterparty_set_outbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
28287 }
28288
28289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28290         LDKChannelCounterparty this_ptr_conv;
28291         this_ptr_conv.inner = untag_ptr(this_ptr);
28292         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28294         this_ptr_conv.is_owned = false;
28295         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
28296         *ret_copy = ChannelCounterparty_get_outbound_htlc_maximum_msat(&this_ptr_conv);
28297         int64_t ret_ref = tag_ptr(ret_copy, true);
28298         return ret_ref;
28299 }
28300
28301 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) {
28302         LDKChannelCounterparty this_ptr_conv;
28303         this_ptr_conv.inner = untag_ptr(this_ptr);
28304         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28306         this_ptr_conv.is_owned = false;
28307         void* val_ptr = untag_ptr(val);
28308         CHECK_ACCESS(val_ptr);
28309         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
28310         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
28311         ChannelCounterparty_set_outbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
28312 }
28313
28314 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) {
28315         LDKPublicKey node_id_arg_ref;
28316         CHECK((*env)->GetArrayLength(env, node_id_arg) == 33);
28317         (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form);
28318         LDKInitFeatures features_arg_conv;
28319         features_arg_conv.inner = untag_ptr(features_arg);
28320         features_arg_conv.is_owned = ptr_is_owned(features_arg);
28321         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
28322         features_arg_conv = InitFeatures_clone(&features_arg_conv);
28323         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
28324         forwarding_info_arg_conv.inner = untag_ptr(forwarding_info_arg);
28325         forwarding_info_arg_conv.is_owned = ptr_is_owned(forwarding_info_arg);
28326         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
28327         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
28328         void* outbound_htlc_minimum_msat_arg_ptr = untag_ptr(outbound_htlc_minimum_msat_arg);
28329         CHECK_ACCESS(outbound_htlc_minimum_msat_arg_ptr);
28330         LDKCOption_u64Z outbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_minimum_msat_arg_ptr);
28331         outbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_htlc_minimum_msat_arg));
28332         void* outbound_htlc_maximum_msat_arg_ptr = untag_ptr(outbound_htlc_maximum_msat_arg);
28333         CHECK_ACCESS(outbound_htlc_maximum_msat_arg_ptr);
28334         LDKCOption_u64Z outbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_maximum_msat_arg_ptr);
28335         outbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_htlc_maximum_msat_arg));
28336         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);
28337         int64_t ret_ref = 0;
28338         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28339         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28340         return ret_ref;
28341 }
28342
28343 static inline uint64_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
28344         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
28345         int64_t ret_ref = 0;
28346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28347         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28348         return ret_ref;
28349 }
28350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28351         LDKChannelCounterparty arg_conv;
28352         arg_conv.inner = untag_ptr(arg);
28353         arg_conv.is_owned = ptr_is_owned(arg);
28354         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28355         arg_conv.is_owned = false;
28356         int64_t ret_conv = ChannelCounterparty_clone_ptr(&arg_conv);
28357         return ret_conv;
28358 }
28359
28360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28361         LDKChannelCounterparty orig_conv;
28362         orig_conv.inner = untag_ptr(orig);
28363         orig_conv.is_owned = ptr_is_owned(orig);
28364         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28365         orig_conv.is_owned = false;
28366         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
28367         int64_t ret_ref = 0;
28368         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28369         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28370         return ret_ref;
28371 }
28372
28373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28374         LDKChannelDetails this_obj_conv;
28375         this_obj_conv.inner = untag_ptr(this_obj);
28376         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28378         ChannelDetails_free(this_obj_conv);
28379 }
28380
28381 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28382         LDKChannelDetails this_ptr_conv;
28383         this_ptr_conv.inner = untag_ptr(this_ptr);
28384         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28386         this_ptr_conv.is_owned = false;
28387         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28388         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
28389         return ret_arr;
28390 }
28391
28392 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28393         LDKChannelDetails this_ptr_conv;
28394         this_ptr_conv.inner = untag_ptr(this_ptr);
28395         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28397         this_ptr_conv.is_owned = false;
28398         LDKThirtyTwoBytes val_ref;
28399         CHECK((*env)->GetArrayLength(env, val) == 32);
28400         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28401         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
28402 }
28403
28404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
28405         LDKChannelDetails this_ptr_conv;
28406         this_ptr_conv.inner = untag_ptr(this_ptr);
28407         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28409         this_ptr_conv.is_owned = false;
28410         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
28411         int64_t ret_ref = 0;
28412         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28413         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28414         return ret_ref;
28415 }
28416
28417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28418         LDKChannelDetails this_ptr_conv;
28419         this_ptr_conv.inner = untag_ptr(this_ptr);
28420         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28422         this_ptr_conv.is_owned = false;
28423         LDKChannelCounterparty val_conv;
28424         val_conv.inner = untag_ptr(val);
28425         val_conv.is_owned = ptr_is_owned(val);
28426         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28427         val_conv = ChannelCounterparty_clone(&val_conv);
28428         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
28429 }
28430
28431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
28432         LDKChannelDetails this_ptr_conv;
28433         this_ptr_conv.inner = untag_ptr(this_ptr);
28434         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28436         this_ptr_conv.is_owned = false;
28437         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
28438         int64_t ret_ref = 0;
28439         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28440         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28441         return ret_ref;
28442 }
28443
28444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28445         LDKChannelDetails this_ptr_conv;
28446         this_ptr_conv.inner = untag_ptr(this_ptr);
28447         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28449         this_ptr_conv.is_owned = false;
28450         LDKOutPoint val_conv;
28451         val_conv.inner = untag_ptr(val);
28452         val_conv.is_owned = ptr_is_owned(val);
28453         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28454         val_conv = OutPoint_clone(&val_conv);
28455         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
28456 }
28457
28458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
28459         LDKChannelDetails this_ptr_conv;
28460         this_ptr_conv.inner = untag_ptr(this_ptr);
28461         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28463         this_ptr_conv.is_owned = false;
28464         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
28465         int64_t ret_ref = 0;
28466         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28467         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28468         return ret_ref;
28469 }
28470
28471 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28472         LDKChannelDetails this_ptr_conv;
28473         this_ptr_conv.inner = untag_ptr(this_ptr);
28474         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28476         this_ptr_conv.is_owned = false;
28477         LDKChannelTypeFeatures val_conv;
28478         val_conv.inner = untag_ptr(val);
28479         val_conv.is_owned = ptr_is_owned(val);
28480         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28481         val_conv = ChannelTypeFeatures_clone(&val_conv);
28482         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
28483 }
28484
28485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28486         LDKChannelDetails this_ptr_conv;
28487         this_ptr_conv.inner = untag_ptr(this_ptr);
28488         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28490         this_ptr_conv.is_owned = false;
28491         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
28492         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
28493         int64_t ret_ref = tag_ptr(ret_copy, true);
28494         return ret_ref;
28495 }
28496
28497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28498         LDKChannelDetails this_ptr_conv;
28499         this_ptr_conv.inner = untag_ptr(this_ptr);
28500         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28502         this_ptr_conv.is_owned = false;
28503         void* val_ptr = untag_ptr(val);
28504         CHECK_ACCESS(val_ptr);
28505         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
28506         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
28507         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
28508 }
28509
28510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
28511         LDKChannelDetails this_ptr_conv;
28512         this_ptr_conv.inner = untag_ptr(this_ptr);
28513         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28515         this_ptr_conv.is_owned = false;
28516         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
28517         *ret_copy = ChannelDetails_get_outbound_scid_alias(&this_ptr_conv);
28518         int64_t ret_ref = tag_ptr(ret_copy, true);
28519         return ret_ref;
28520 }
28521
28522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28523         LDKChannelDetails this_ptr_conv;
28524         this_ptr_conv.inner = untag_ptr(this_ptr);
28525         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28527         this_ptr_conv.is_owned = false;
28528         void* val_ptr = untag_ptr(val);
28529         CHECK_ACCESS(val_ptr);
28530         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
28531         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
28532         ChannelDetails_set_outbound_scid_alias(&this_ptr_conv, val_conv);
28533 }
28534
28535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
28536         LDKChannelDetails this_ptr_conv;
28537         this_ptr_conv.inner = untag_ptr(this_ptr);
28538         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28540         this_ptr_conv.is_owned = false;
28541         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
28542         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
28543         int64_t ret_ref = tag_ptr(ret_copy, true);
28544         return ret_ref;
28545 }
28546
28547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28548         LDKChannelDetails this_ptr_conv;
28549         this_ptr_conv.inner = untag_ptr(this_ptr);
28550         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28552         this_ptr_conv.is_owned = false;
28553         void* val_ptr = untag_ptr(val);
28554         CHECK_ACCESS(val_ptr);
28555         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
28556         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
28557         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
28558 }
28559
28560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28561         LDKChannelDetails this_ptr_conv;
28562         this_ptr_conv.inner = untag_ptr(this_ptr);
28563         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28565         this_ptr_conv.is_owned = false;
28566         int64_t ret_conv = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
28567         return ret_conv;
28568 }
28569
28570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28571         LDKChannelDetails this_ptr_conv;
28572         this_ptr_conv.inner = untag_ptr(this_ptr);
28573         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28575         this_ptr_conv.is_owned = false;
28576         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
28577 }
28578
28579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
28580         LDKChannelDetails 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         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
28586         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
28587         int64_t ret_ref = tag_ptr(ret_copy, true);
28588         return ret_ref;
28589 }
28590
28591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28592         LDKChannelDetails 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         void* val_ptr = untag_ptr(val);
28598         CHECK_ACCESS(val_ptr);
28599         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
28600         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
28601         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
28602 }
28603
28604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28605         LDKChannelDetails this_ptr_conv;
28606         this_ptr_conv.inner = untag_ptr(this_ptr);
28607         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28609         this_ptr_conv.is_owned = false;
28610         int64_t ret_conv = ChannelDetails_get_user_channel_id(&this_ptr_conv);
28611         return ret_conv;
28612 }
28613
28614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28615         LDKChannelDetails this_ptr_conv;
28616         this_ptr_conv.inner = untag_ptr(this_ptr);
28617         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28619         this_ptr_conv.is_owned = false;
28620         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
28621 }
28622
28623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28624         LDKChannelDetails this_ptr_conv;
28625         this_ptr_conv.inner = untag_ptr(this_ptr);
28626         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28628         this_ptr_conv.is_owned = false;
28629         int64_t ret_conv = ChannelDetails_get_balance_msat(&this_ptr_conv);
28630         return ret_conv;
28631 }
28632
28633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28634         LDKChannelDetails this_ptr_conv;
28635         this_ptr_conv.inner = untag_ptr(this_ptr);
28636         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28638         this_ptr_conv.is_owned = false;
28639         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
28640 }
28641
28642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28643         LDKChannelDetails this_ptr_conv;
28644         this_ptr_conv.inner = untag_ptr(this_ptr);
28645         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28647         this_ptr_conv.is_owned = false;
28648         int64_t ret_conv = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
28649         return ret_conv;
28650 }
28651
28652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28653         LDKChannelDetails this_ptr_conv;
28654         this_ptr_conv.inner = untag_ptr(this_ptr);
28655         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28657         this_ptr_conv.is_owned = false;
28658         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
28659 }
28660
28661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1next_1outbound_1htlc_1limit_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28662         LDKChannelDetails this_ptr_conv;
28663         this_ptr_conv.inner = untag_ptr(this_ptr);
28664         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28666         this_ptr_conv.is_owned = false;
28667         int64_t ret_conv = ChannelDetails_get_next_outbound_htlc_limit_msat(&this_ptr_conv);
28668         return ret_conv;
28669 }
28670
28671 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) {
28672         LDKChannelDetails this_ptr_conv;
28673         this_ptr_conv.inner = untag_ptr(this_ptr);
28674         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28676         this_ptr_conv.is_owned = false;
28677         ChannelDetails_set_next_outbound_htlc_limit_msat(&this_ptr_conv, val);
28678 }
28679
28680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28681         LDKChannelDetails this_ptr_conv;
28682         this_ptr_conv.inner = untag_ptr(this_ptr);
28683         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28685         this_ptr_conv.is_owned = false;
28686         int64_t ret_conv = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
28687         return ret_conv;
28688 }
28689
28690 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28691         LDKChannelDetails this_ptr_conv;
28692         this_ptr_conv.inner = untag_ptr(this_ptr);
28693         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28695         this_ptr_conv.is_owned = false;
28696         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
28697 }
28698
28699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
28700         LDKChannelDetails this_ptr_conv;
28701         this_ptr_conv.inner = untag_ptr(this_ptr);
28702         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28704         this_ptr_conv.is_owned = false;
28705         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
28706         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
28707         int64_t ret_ref = tag_ptr(ret_copy, true);
28708         return ret_ref;
28709 }
28710
28711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28712         LDKChannelDetails this_ptr_conv;
28713         this_ptr_conv.inner = untag_ptr(this_ptr);
28714         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28716         this_ptr_conv.is_owned = false;
28717         void* val_ptr = untag_ptr(val);
28718         CHECK_ACCESS(val_ptr);
28719         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
28720         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
28721         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
28722 }
28723
28724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
28725         LDKChannelDetails this_ptr_conv;
28726         this_ptr_conv.inner = untag_ptr(this_ptr);
28727         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28729         this_ptr_conv.is_owned = false;
28730         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
28731         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
28732         int64_t ret_ref = tag_ptr(ret_copy, true);
28733         return ret_ref;
28734 }
28735
28736 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) {
28737         LDKChannelDetails this_ptr_conv;
28738         this_ptr_conv.inner = untag_ptr(this_ptr);
28739         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28741         this_ptr_conv.is_owned = false;
28742         void* val_ptr = untag_ptr(val);
28743         CHECK_ACCESS(val_ptr);
28744         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
28745         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(val));
28746         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
28747 }
28748
28749 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
28750         LDKChannelDetails this_ptr_conv;
28751         this_ptr_conv.inner = untag_ptr(this_ptr);
28752         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28754         this_ptr_conv.is_owned = false;
28755         jboolean ret_conv = ChannelDetails_get_is_outbound(&this_ptr_conv);
28756         return ret_conv;
28757 }
28758
28759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28760         LDKChannelDetails this_ptr_conv;
28761         this_ptr_conv.inner = untag_ptr(this_ptr);
28762         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28764         this_ptr_conv.is_owned = false;
28765         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
28766 }
28767
28768 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr) {
28769         LDKChannelDetails 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         jboolean ret_conv = ChannelDetails_get_is_channel_ready(&this_ptr_conv);
28775         return ret_conv;
28776 }
28777
28778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28779         LDKChannelDetails 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         ChannelDetails_set_is_channel_ready(&this_ptr_conv, val);
28785 }
28786
28787 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
28788         LDKChannelDetails 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         jboolean ret_conv = ChannelDetails_get_is_usable(&this_ptr_conv);
28794         return ret_conv;
28795 }
28796
28797 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28798         LDKChannelDetails this_ptr_conv;
28799         this_ptr_conv.inner = untag_ptr(this_ptr);
28800         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28802         this_ptr_conv.is_owned = false;
28803         ChannelDetails_set_is_usable(&this_ptr_conv, val);
28804 }
28805
28806 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
28807         LDKChannelDetails this_ptr_conv;
28808         this_ptr_conv.inner = untag_ptr(this_ptr);
28809         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28811         this_ptr_conv.is_owned = false;
28812         jboolean ret_conv = ChannelDetails_get_is_public(&this_ptr_conv);
28813         return ret_conv;
28814 }
28815
28816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28817         LDKChannelDetails this_ptr_conv;
28818         this_ptr_conv.inner = untag_ptr(this_ptr);
28819         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28821         this_ptr_conv.is_owned = false;
28822         ChannelDetails_set_is_public(&this_ptr_conv, val);
28823 }
28824
28825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28826         LDKChannelDetails this_ptr_conv;
28827         this_ptr_conv.inner = untag_ptr(this_ptr);
28828         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28830         this_ptr_conv.is_owned = false;
28831         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
28832         *ret_copy = ChannelDetails_get_inbound_htlc_minimum_msat(&this_ptr_conv);
28833         int64_t ret_ref = tag_ptr(ret_copy, true);
28834         return ret_ref;
28835 }
28836
28837 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) {
28838         LDKChannelDetails this_ptr_conv;
28839         this_ptr_conv.inner = untag_ptr(this_ptr);
28840         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28842         this_ptr_conv.is_owned = false;
28843         void* val_ptr = untag_ptr(val);
28844         CHECK_ACCESS(val_ptr);
28845         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
28846         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
28847         ChannelDetails_set_inbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
28848 }
28849
28850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28851         LDKChannelDetails this_ptr_conv;
28852         this_ptr_conv.inner = untag_ptr(this_ptr);
28853         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28855         this_ptr_conv.is_owned = false;
28856         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
28857         *ret_copy = ChannelDetails_get_inbound_htlc_maximum_msat(&this_ptr_conv);
28858         int64_t ret_ref = tag_ptr(ret_copy, true);
28859         return ret_ref;
28860 }
28861
28862 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) {
28863         LDKChannelDetails this_ptr_conv;
28864         this_ptr_conv.inner = untag_ptr(this_ptr);
28865         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28867         this_ptr_conv.is_owned = false;
28868         void* val_ptr = untag_ptr(val);
28869         CHECK_ACCESS(val_ptr);
28870         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
28871         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
28872         ChannelDetails_set_inbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
28873 }
28874
28875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
28876         LDKChannelDetails this_ptr_conv;
28877         this_ptr_conv.inner = untag_ptr(this_ptr);
28878         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28880         this_ptr_conv.is_owned = false;
28881         LDKChannelConfig ret_var = ChannelDetails_get_config(&this_ptr_conv);
28882         int64_t ret_ref = 0;
28883         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28884         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28885         return ret_ref;
28886 }
28887
28888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28889         LDKChannelDetails this_ptr_conv;
28890         this_ptr_conv.inner = untag_ptr(this_ptr);
28891         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28893         this_ptr_conv.is_owned = false;
28894         LDKChannelConfig val_conv;
28895         val_conv.inner = untag_ptr(val);
28896         val_conv.is_owned = ptr_is_owned(val);
28897         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28898         val_conv = ChannelConfig_clone(&val_conv);
28899         ChannelDetails_set_config(&this_ptr_conv, val_conv);
28900 }
28901
28902 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) {
28903         LDKThirtyTwoBytes channel_id_arg_ref;
28904         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
28905         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
28906         LDKChannelCounterparty counterparty_arg_conv;
28907         counterparty_arg_conv.inner = untag_ptr(counterparty_arg);
28908         counterparty_arg_conv.is_owned = ptr_is_owned(counterparty_arg);
28909         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
28910         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
28911         LDKOutPoint funding_txo_arg_conv;
28912         funding_txo_arg_conv.inner = untag_ptr(funding_txo_arg);
28913         funding_txo_arg_conv.is_owned = ptr_is_owned(funding_txo_arg);
28914         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
28915         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
28916         LDKChannelTypeFeatures channel_type_arg_conv;
28917         channel_type_arg_conv.inner = untag_ptr(channel_type_arg);
28918         channel_type_arg_conv.is_owned = ptr_is_owned(channel_type_arg);
28919         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
28920         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
28921         void* short_channel_id_arg_ptr = untag_ptr(short_channel_id_arg);
28922         CHECK_ACCESS(short_channel_id_arg_ptr);
28923         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
28924         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id_arg));
28925         void* outbound_scid_alias_arg_ptr = untag_ptr(outbound_scid_alias_arg);
28926         CHECK_ACCESS(outbound_scid_alias_arg_ptr);
28927         LDKCOption_u64Z outbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(outbound_scid_alias_arg_ptr);
28928         outbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_scid_alias_arg));
28929         void* inbound_scid_alias_arg_ptr = untag_ptr(inbound_scid_alias_arg);
28930         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
28931         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
28932         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_scid_alias_arg));
28933         void* unspendable_punishment_reserve_arg_ptr = untag_ptr(unspendable_punishment_reserve_arg);
28934         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
28935         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
28936         void* confirmations_required_arg_ptr = untag_ptr(confirmations_required_arg);
28937         CHECK_ACCESS(confirmations_required_arg_ptr);
28938         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
28939         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(confirmations_required_arg));
28940         void* force_close_spend_delay_arg_ptr = untag_ptr(force_close_spend_delay_arg);
28941         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
28942         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
28943         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(force_close_spend_delay_arg));
28944         void* inbound_htlc_minimum_msat_arg_ptr = untag_ptr(inbound_htlc_minimum_msat_arg);
28945         CHECK_ACCESS(inbound_htlc_minimum_msat_arg_ptr);
28946         LDKCOption_u64Z inbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_minimum_msat_arg_ptr);
28947         inbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_htlc_minimum_msat_arg));
28948         void* inbound_htlc_maximum_msat_arg_ptr = untag_ptr(inbound_htlc_maximum_msat_arg);
28949         CHECK_ACCESS(inbound_htlc_maximum_msat_arg_ptr);
28950         LDKCOption_u64Z inbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_maximum_msat_arg_ptr);
28951         inbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_htlc_maximum_msat_arg));
28952         LDKChannelConfig config_arg_conv;
28953         config_arg_conv.inner = untag_ptr(config_arg);
28954         config_arg_conv.is_owned = ptr_is_owned(config_arg);
28955         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_arg_conv);
28956         config_arg_conv = ChannelConfig_clone(&config_arg_conv);
28957         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);
28958         int64_t ret_ref = 0;
28959         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28960         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28961         return ret_ref;
28962 }
28963
28964 static inline uint64_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
28965         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
28966         int64_t ret_ref = 0;
28967         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28968         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28969         return ret_ref;
28970 }
28971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28972         LDKChannelDetails arg_conv;
28973         arg_conv.inner = untag_ptr(arg);
28974         arg_conv.is_owned = ptr_is_owned(arg);
28975         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28976         arg_conv.is_owned = false;
28977         int64_t ret_conv = ChannelDetails_clone_ptr(&arg_conv);
28978         return ret_conv;
28979 }
28980
28981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28982         LDKChannelDetails orig_conv;
28983         orig_conv.inner = untag_ptr(orig);
28984         orig_conv.is_owned = ptr_is_owned(orig);
28985         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28986         orig_conv.is_owned = false;
28987         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
28988         int64_t ret_ref = 0;
28989         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28990         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28991         return ret_ref;
28992 }
28993
28994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
28995         LDKChannelDetails this_arg_conv;
28996         this_arg_conv.inner = untag_ptr(this_arg);
28997         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28999         this_arg_conv.is_owned = false;
29000         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29001         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
29002         int64_t ret_ref = tag_ptr(ret_copy, true);
29003         return ret_ref;
29004 }
29005
29006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
29007         LDKChannelDetails this_arg_conv;
29008         this_arg_conv.inner = untag_ptr(this_arg);
29009         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29011         this_arg_conv.is_owned = false;
29012         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29013         *ret_copy = ChannelDetails_get_outbound_payment_scid(&this_arg_conv);
29014         int64_t ret_ref = tag_ptr(ret_copy, true);
29015         return ret_ref;
29016 }
29017
29018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29019         if (!ptr_is_owned(this_ptr)) return;
29020         void* this_ptr_ptr = untag_ptr(this_ptr);
29021         CHECK_ACCESS(this_ptr_ptr);
29022         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
29023         FREE(untag_ptr(this_ptr));
29024         PaymentSendFailure_free(this_ptr_conv);
29025 }
29026
29027 static inline uint64_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
29028         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
29029         *ret_copy = PaymentSendFailure_clone(arg);
29030         int64_t ret_ref = tag_ptr(ret_copy, true);
29031         return ret_ref;
29032 }
29033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29034         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)untag_ptr(arg);
29035         int64_t ret_conv = PaymentSendFailure_clone_ptr(arg_conv);
29036         return ret_conv;
29037 }
29038
29039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29040         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)untag_ptr(orig);
29041         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
29042         *ret_copy = PaymentSendFailure_clone(orig_conv);
29043         int64_t ret_ref = tag_ptr(ret_copy, true);
29044         return ret_ref;
29045 }
29046
29047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
29048         void* a_ptr = untag_ptr(a);
29049         CHECK_ACCESS(a_ptr);
29050         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
29051         a_conv = APIError_clone((LDKAPIError*)untag_ptr(a));
29052         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
29053         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
29054         int64_t ret_ref = tag_ptr(ret_copy, true);
29055         return ret_ref;
29056 }
29057
29058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
29059         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
29060         a_constr.datalen = (*env)->GetArrayLength(env, a);
29061         if (a_constr.datalen > 0)
29062                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
29063         else
29064                 a_constr.data = NULL;
29065         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
29066         for (size_t w = 0; w < a_constr.datalen; w++) {
29067                 int64_t a_conv_22 = a_vals[w];
29068                 void* a_conv_22_ptr = untag_ptr(a_conv_22);
29069                 CHECK_ACCESS(a_conv_22_ptr);
29070                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
29071                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)untag_ptr(a_conv_22));
29072                 a_constr.data[w] = a_conv_22_conv;
29073         }
29074         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
29075         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
29076         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
29077         int64_t ret_ref = tag_ptr(ret_copy, true);
29078         return ret_ref;
29079 }
29080
29081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1retry_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
29082         LDKCVec_APIErrorZ a_constr;
29083         a_constr.datalen = (*env)->GetArrayLength(env, a);
29084         if (a_constr.datalen > 0)
29085                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
29086         else
29087                 a_constr.data = NULL;
29088         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
29089         for (size_t k = 0; k < a_constr.datalen; k++) {
29090                 int64_t a_conv_10 = a_vals[k];
29091                 void* a_conv_10_ptr = untag_ptr(a_conv_10);
29092                 CHECK_ACCESS(a_conv_10_ptr);
29093                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
29094                 a_conv_10_conv = APIError_clone((LDKAPIError*)untag_ptr(a_conv_10));
29095                 a_constr.data[k] = a_conv_10_conv;
29096         }
29097         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
29098         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
29099         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
29100         int64_t ret_ref = tag_ptr(ret_copy, true);
29101         return ret_ref;
29102 }
29103
29104 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) {
29105         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
29106         results_constr.datalen = (*env)->GetArrayLength(env, results);
29107         if (results_constr.datalen > 0)
29108                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
29109         else
29110                 results_constr.data = NULL;
29111         int64_t* results_vals = (*env)->GetLongArrayElements (env, results, NULL);
29112         for (size_t w = 0; w < results_constr.datalen; w++) {
29113                 int64_t results_conv_22 = results_vals[w];
29114                 void* results_conv_22_ptr = untag_ptr(results_conv_22);
29115                 CHECK_ACCESS(results_conv_22_ptr);
29116                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
29117                 results_constr.data[w] = results_conv_22_conv;
29118         }
29119         (*env)->ReleaseLongArrayElements(env, results, results_vals, 0);
29120         LDKRouteParameters failed_paths_retry_conv;
29121         failed_paths_retry_conv.inner = untag_ptr(failed_paths_retry);
29122         failed_paths_retry_conv.is_owned = ptr_is_owned(failed_paths_retry);
29123         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
29124         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
29125         LDKThirtyTwoBytes payment_id_ref;
29126         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
29127         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
29128         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
29129         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
29130         int64_t ret_ref = tag_ptr(ret_copy, true);
29131         return ret_ref;
29132 }
29133
29134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29135         LDKPhantomRouteHints this_obj_conv;
29136         this_obj_conv.inner = untag_ptr(this_obj);
29137         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29139         PhantomRouteHints_free(this_obj_conv);
29140 }
29141
29142 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
29143         LDKPhantomRouteHints this_ptr_conv;
29144         this_ptr_conv.inner = untag_ptr(this_ptr);
29145         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29147         this_ptr_conv.is_owned = false;
29148         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
29149         int64_tArray ret_arr = NULL;
29150         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29151         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29152         for (size_t q = 0; q < ret_var.datalen; q++) {
29153                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
29154                 int64_t ret_conv_16_ref = 0;
29155                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
29156                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
29157                 ret_arr_ptr[q] = ret_conv_16_ref;
29158         }
29159         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29160         FREE(ret_var.data);
29161         return ret_arr;
29162 }
29163
29164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
29165         LDKPhantomRouteHints this_ptr_conv;
29166         this_ptr_conv.inner = untag_ptr(this_ptr);
29167         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29169         this_ptr_conv.is_owned = false;
29170         LDKCVec_ChannelDetailsZ val_constr;
29171         val_constr.datalen = (*env)->GetArrayLength(env, val);
29172         if (val_constr.datalen > 0)
29173                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
29174         else
29175                 val_constr.data = NULL;
29176         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
29177         for (size_t q = 0; q < val_constr.datalen; q++) {
29178                 int64_t val_conv_16 = val_vals[q];
29179                 LDKChannelDetails val_conv_16_conv;
29180                 val_conv_16_conv.inner = untag_ptr(val_conv_16);
29181                 val_conv_16_conv.is_owned = ptr_is_owned(val_conv_16);
29182                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
29183                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
29184                 val_constr.data[q] = val_conv_16_conv;
29185         }
29186         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
29187         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
29188 }
29189
29190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr) {
29191         LDKPhantomRouteHints this_ptr_conv;
29192         this_ptr_conv.inner = untag_ptr(this_ptr);
29193         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29195         this_ptr_conv.is_owned = false;
29196         int64_t ret_conv = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
29197         return ret_conv;
29198 }
29199
29200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29201         LDKPhantomRouteHints this_ptr_conv;
29202         this_ptr_conv.inner = untag_ptr(this_ptr);
29203         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29205         this_ptr_conv.is_owned = false;
29206         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
29207 }
29208
29209 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
29210         LDKPhantomRouteHints this_ptr_conv;
29211         this_ptr_conv.inner = untag_ptr(this_ptr);
29212         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29214         this_ptr_conv.is_owned = false;
29215         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29216         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form);
29217         return ret_arr;
29218 }
29219
29220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29221         LDKPhantomRouteHints this_ptr_conv;
29222         this_ptr_conv.inner = untag_ptr(this_ptr);
29223         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29225         this_ptr_conv.is_owned = false;
29226         LDKPublicKey val_ref;
29227         CHECK((*env)->GetArrayLength(env, val) == 33);
29228         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
29229         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
29230 }
29231
29232 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) {
29233         LDKCVec_ChannelDetailsZ channels_arg_constr;
29234         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
29235         if (channels_arg_constr.datalen > 0)
29236                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
29237         else
29238                 channels_arg_constr.data = NULL;
29239         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
29240         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
29241                 int64_t channels_arg_conv_16 = channels_arg_vals[q];
29242                 LDKChannelDetails channels_arg_conv_16_conv;
29243                 channels_arg_conv_16_conv.inner = untag_ptr(channels_arg_conv_16);
29244                 channels_arg_conv_16_conv.is_owned = ptr_is_owned(channels_arg_conv_16);
29245                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
29246                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
29247                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
29248         }
29249         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
29250         LDKPublicKey real_node_pubkey_arg_ref;
29251         CHECK((*env)->GetArrayLength(env, real_node_pubkey_arg) == 33);
29252         (*env)->GetByteArrayRegion(env, real_node_pubkey_arg, 0, 33, real_node_pubkey_arg_ref.compressed_form);
29253         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
29254         int64_t ret_ref = 0;
29255         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29256         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29257         return ret_ref;
29258 }
29259
29260 static inline uint64_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
29261         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
29262         int64_t ret_ref = 0;
29263         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29264         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29265         return ret_ref;
29266 }
29267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29268         LDKPhantomRouteHints arg_conv;
29269         arg_conv.inner = untag_ptr(arg);
29270         arg_conv.is_owned = ptr_is_owned(arg);
29271         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29272         arg_conv.is_owned = false;
29273         int64_t ret_conv = PhantomRouteHints_clone_ptr(&arg_conv);
29274         return ret_conv;
29275 }
29276
29277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29278         LDKPhantomRouteHints orig_conv;
29279         orig_conv.inner = untag_ptr(orig);
29280         orig_conv.is_owned = ptr_is_owned(orig);
29281         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29282         orig_conv.is_owned = false;
29283         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
29284         int64_t ret_ref = 0;
29285         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29286         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29287         return ret_ref;
29288 }
29289
29290 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) {
29291         void* fee_est_ptr = untag_ptr(fee_est);
29292         CHECK_ACCESS(fee_est_ptr);
29293         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
29294         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
29295                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29296                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
29297         }
29298         void* chain_monitor_ptr = untag_ptr(chain_monitor);
29299         CHECK_ACCESS(chain_monitor_ptr);
29300         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
29301         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
29302                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29303                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
29304         }
29305         void* tx_broadcaster_ptr = untag_ptr(tx_broadcaster);
29306         CHECK_ACCESS(tx_broadcaster_ptr);
29307         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
29308         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
29309                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29310                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
29311         }
29312         void* logger_ptr = untag_ptr(logger);
29313         CHECK_ACCESS(logger_ptr);
29314         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
29315         if (logger_conv.free == LDKLogger_JCalls_free) {
29316                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29317                 LDKLogger_JCalls_cloned(&logger_conv);
29318         }
29319         void* keys_manager_ptr = untag_ptr(keys_manager);
29320         CHECK_ACCESS(keys_manager_ptr);
29321         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
29322         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
29323                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29324                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
29325         }
29326         LDKUserConfig config_conv;
29327         config_conv.inner = untag_ptr(config);
29328         config_conv.is_owned = ptr_is_owned(config);
29329         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
29330         config_conv = UserConfig_clone(&config_conv);
29331         LDKChainParameters params_conv;
29332         params_conv.inner = untag_ptr(params);
29333         params_conv.is_owned = ptr_is_owned(params);
29334         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
29335         params_conv = ChainParameters_clone(&params_conv);
29336         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
29337         int64_t ret_ref = 0;
29338         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29339         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29340         return ret_ref;
29341 }
29342
29343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
29344         LDKChannelManager this_arg_conv;
29345         this_arg_conv.inner = untag_ptr(this_arg);
29346         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29348         this_arg_conv.is_owned = false;
29349         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
29350         int64_t ret_ref = 0;
29351         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29352         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29353         return ret_ref;
29354 }
29355
29356 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) {
29357         LDKChannelManager this_arg_conv;
29358         this_arg_conv.inner = untag_ptr(this_arg);
29359         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29361         this_arg_conv.is_owned = false;
29362         LDKPublicKey their_network_key_ref;
29363         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
29364         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
29365         LDKUserConfig override_config_conv;
29366         override_config_conv.inner = untag_ptr(override_config);
29367         override_config_conv.is_owned = ptr_is_owned(override_config);
29368         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
29369         override_config_conv = UserConfig_clone(&override_config_conv);
29370         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
29371         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
29372         return tag_ptr(ret_conv, true);
29373 }
29374
29375 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
29376         LDKChannelManager this_arg_conv;
29377         this_arg_conv.inner = untag_ptr(this_arg);
29378         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29380         this_arg_conv.is_owned = false;
29381         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
29382         int64_tArray ret_arr = NULL;
29383         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29384         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29385         for (size_t q = 0; q < ret_var.datalen; q++) {
29386                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
29387                 int64_t ret_conv_16_ref = 0;
29388                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
29389                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
29390                 ret_arr_ptr[q] = ret_conv_16_ref;
29391         }
29392         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29393         FREE(ret_var.data);
29394         return ret_arr;
29395 }
29396
29397 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
29398         LDKChannelManager this_arg_conv;
29399         this_arg_conv.inner = untag_ptr(this_arg);
29400         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29402         this_arg_conv.is_owned = false;
29403         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
29404         int64_tArray ret_arr = NULL;
29405         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29406         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29407         for (size_t q = 0; q < ret_var.datalen; q++) {
29408                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
29409                 int64_t ret_conv_16_ref = 0;
29410                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
29411                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
29412                 ret_arr_ptr[q] = ret_conv_16_ref;
29413         }
29414         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29415         FREE(ret_var.data);
29416         return ret_arr;
29417 }
29418
29419 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) {
29420         LDKChannelManager this_arg_conv;
29421         this_arg_conv.inner = untag_ptr(this_arg);
29422         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29424         this_arg_conv.is_owned = false;
29425         unsigned char channel_id_arr[32];
29426         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
29427         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
29428         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
29429         LDKPublicKey counterparty_node_id_ref;
29430         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
29431         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
29432         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29433         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
29434         return tag_ptr(ret_conv, true);
29435 }
29436
29437 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) {
29438         LDKChannelManager this_arg_conv;
29439         this_arg_conv.inner = untag_ptr(this_arg);
29440         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29442         this_arg_conv.is_owned = false;
29443         unsigned char channel_id_arr[32];
29444         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
29445         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
29446         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
29447         LDKPublicKey counterparty_node_id_ref;
29448         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
29449         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
29450         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29451         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, counterparty_node_id_ref, target_feerate_sats_per_1000_weight);
29452         return tag_ptr(ret_conv, true);
29453 }
29454
29455 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) {
29456         LDKChannelManager this_arg_conv;
29457         this_arg_conv.inner = untag_ptr(this_arg);
29458         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29460         this_arg_conv.is_owned = false;
29461         unsigned char channel_id_arr[32];
29462         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
29463         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
29464         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
29465         LDKPublicKey counterparty_node_id_ref;
29466         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
29467         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
29468         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29469         *ret_conv = ChannelManager_force_close_broadcasting_latest_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
29470         return tag_ptr(ret_conv, true);
29471 }
29472
29473 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) {
29474         LDKChannelManager this_arg_conv;
29475         this_arg_conv.inner = untag_ptr(this_arg);
29476         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29478         this_arg_conv.is_owned = false;
29479         unsigned char channel_id_arr[32];
29480         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
29481         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
29482         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
29483         LDKPublicKey counterparty_node_id_ref;
29484         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
29485         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
29486         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29487         *ret_conv = ChannelManager_force_close_without_broadcasting_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
29488         return tag_ptr(ret_conv, true);
29489 }
29490
29491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1broadcasting_1latest_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
29492         LDKChannelManager this_arg_conv;
29493         this_arg_conv.inner = untag_ptr(this_arg);
29494         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29496         this_arg_conv.is_owned = false;
29497         ChannelManager_force_close_all_channels_broadcasting_latest_txn(&this_arg_conv);
29498 }
29499
29500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1without_1broadcasting_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
29501         LDKChannelManager this_arg_conv;
29502         this_arg_conv.inner = untag_ptr(this_arg);
29503         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29505         this_arg_conv.is_owned = false;
29506         ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv);
29507 }
29508
29509 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) {
29510         LDKChannelManager this_arg_conv;
29511         this_arg_conv.inner = untag_ptr(this_arg);
29512         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29514         this_arg_conv.is_owned = false;
29515         LDKRoute route_conv;
29516         route_conv.inner = untag_ptr(route);
29517         route_conv.is_owned = ptr_is_owned(route);
29518         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
29519         route_conv.is_owned = false;
29520         LDKThirtyTwoBytes payment_hash_ref;
29521         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
29522         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
29523         LDKThirtyTwoBytes payment_secret_ref;
29524         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
29525         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
29526         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
29527         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
29528         return tag_ptr(ret_conv, true);
29529 }
29530
29531 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) {
29532         LDKChannelManager this_arg_conv;
29533         this_arg_conv.inner = untag_ptr(this_arg);
29534         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29536         this_arg_conv.is_owned = false;
29537         LDKRoute route_conv;
29538         route_conv.inner = untag_ptr(route);
29539         route_conv.is_owned = ptr_is_owned(route);
29540         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
29541         route_conv.is_owned = false;
29542         LDKThirtyTwoBytes payment_id_ref;
29543         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
29544         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
29545         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
29546         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
29547         return tag_ptr(ret_conv, true);
29548 }
29549
29550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
29551         LDKChannelManager this_arg_conv;
29552         this_arg_conv.inner = untag_ptr(this_arg);
29553         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29555         this_arg_conv.is_owned = false;
29556         LDKThirtyTwoBytes payment_id_ref;
29557         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
29558         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
29559         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
29560 }
29561
29562 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) {
29563         LDKChannelManager this_arg_conv;
29564         this_arg_conv.inner = untag_ptr(this_arg);
29565         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29567         this_arg_conv.is_owned = false;
29568         LDKRoute route_conv;
29569         route_conv.inner = untag_ptr(route);
29570         route_conv.is_owned = ptr_is_owned(route);
29571         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
29572         route_conv.is_owned = false;
29573         LDKThirtyTwoBytes payment_preimage_ref;
29574         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
29575         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
29576         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
29577         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
29578         return tag_ptr(ret_conv, true);
29579 }
29580
29581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1probe(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray hops) {
29582         LDKChannelManager this_arg_conv;
29583         this_arg_conv.inner = untag_ptr(this_arg);
29584         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29586         this_arg_conv.is_owned = false;
29587         LDKCVec_RouteHopZ hops_constr;
29588         hops_constr.datalen = (*env)->GetArrayLength(env, hops);
29589         if (hops_constr.datalen > 0)
29590                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
29591         else
29592                 hops_constr.data = NULL;
29593         int64_t* hops_vals = (*env)->GetLongArrayElements (env, hops, NULL);
29594         for (size_t k = 0; k < hops_constr.datalen; k++) {
29595                 int64_t hops_conv_10 = hops_vals[k];
29596                 LDKRouteHop hops_conv_10_conv;
29597                 hops_conv_10_conv.inner = untag_ptr(hops_conv_10);
29598                 hops_conv_10_conv.is_owned = ptr_is_owned(hops_conv_10);
29599                 CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv_10_conv);
29600                 hops_conv_10_conv = RouteHop_clone(&hops_conv_10_conv);
29601                 hops_constr.data[k] = hops_conv_10_conv;
29602         }
29603         (*env)->ReleaseLongArrayElements(env, hops, hops_vals, 0);
29604         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
29605         *ret_conv = ChannelManager_send_probe(&this_arg_conv, hops_constr);
29606         return tag_ptr(ret_conv, true);
29607 }
29608
29609 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) {
29610         LDKChannelManager this_arg_conv;
29611         this_arg_conv.inner = untag_ptr(this_arg);
29612         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29614         this_arg_conv.is_owned = false;
29615         unsigned char temporary_channel_id_arr[32];
29616         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
29617         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
29618         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
29619         LDKPublicKey counterparty_node_id_ref;
29620         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
29621         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
29622         LDKTransaction funding_transaction_ref;
29623         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
29624         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
29625         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
29626         funding_transaction_ref.data_is_owned = true;
29627         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29628         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, funding_transaction_ref);
29629         return tag_ptr(ret_conv, true);
29630 }
29631
29632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray rgb, int8_tArray alias, int64_tArray addresses) {
29633         LDKChannelManager this_arg_conv;
29634         this_arg_conv.inner = untag_ptr(this_arg);
29635         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29637         this_arg_conv.is_owned = false;
29638         LDKThreeBytes rgb_ref;
29639         CHECK((*env)->GetArrayLength(env, rgb) == 3);
29640         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
29641         LDKThirtyTwoBytes alias_ref;
29642         CHECK((*env)->GetArrayLength(env, alias) == 32);
29643         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
29644         LDKCVec_NetAddressZ addresses_constr;
29645         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
29646         if (addresses_constr.datalen > 0)
29647                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
29648         else
29649                 addresses_constr.data = NULL;
29650         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
29651         for (size_t m = 0; m < addresses_constr.datalen; m++) {
29652                 int64_t addresses_conv_12 = addresses_vals[m];
29653                 void* addresses_conv_12_ptr = untag_ptr(addresses_conv_12);
29654                 CHECK_ACCESS(addresses_conv_12_ptr);
29655                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
29656                 addresses_constr.data[m] = addresses_conv_12_conv;
29657         }
29658         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
29659         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
29660 }
29661
29662 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) {
29663         LDKChannelManager this_arg_conv;
29664         this_arg_conv.inner = untag_ptr(this_arg);
29665         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29667         this_arg_conv.is_owned = false;
29668         LDKPublicKey counterparty_node_id_ref;
29669         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
29670         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
29671         LDKCVec_ThirtyTwoBytesZ channel_ids_constr;
29672         channel_ids_constr.datalen = (*env)->GetArrayLength(env, channel_ids);
29673         if (channel_ids_constr.datalen > 0)
29674                 channel_ids_constr.data = MALLOC(channel_ids_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
29675         else
29676                 channel_ids_constr.data = NULL;
29677         for (size_t i = 0; i < channel_ids_constr.datalen; i++) {
29678                 int8_tArray channel_ids_conv_8 = (*env)->GetObjectArrayElement(env, channel_ids, i);
29679                 LDKThirtyTwoBytes channel_ids_conv_8_ref;
29680                 CHECK((*env)->GetArrayLength(env, channel_ids_conv_8) == 32);
29681                 (*env)->GetByteArrayRegion(env, channel_ids_conv_8, 0, 32, channel_ids_conv_8_ref.data);
29682                 channel_ids_constr.data[i] = channel_ids_conv_8_ref;
29683         }
29684         LDKChannelConfig config_conv;
29685         config_conv.inner = untag_ptr(config);
29686         config_conv.is_owned = ptr_is_owned(config);
29687         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
29688         config_conv.is_owned = false;
29689         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29690         *ret_conv = ChannelManager_update_channel_config(&this_arg_conv, counterparty_node_id_ref, channel_ids_constr, &config_conv);
29691         return tag_ptr(ret_conv, true);
29692 }
29693
29694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
29695         LDKChannelManager this_arg_conv;
29696         this_arg_conv.inner = untag_ptr(this_arg);
29697         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29699         this_arg_conv.is_owned = false;
29700         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
29701 }
29702
29703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
29704         LDKChannelManager this_arg_conv;
29705         this_arg_conv.inner = untag_ptr(this_arg);
29706         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29708         this_arg_conv.is_owned = false;
29709         ChannelManager_timer_tick_occurred(&this_arg_conv);
29710 }
29711
29712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
29713         LDKChannelManager this_arg_conv;
29714         this_arg_conv.inner = untag_ptr(this_arg);
29715         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29717         this_arg_conv.is_owned = false;
29718         unsigned char payment_hash_arr[32];
29719         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
29720         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
29721         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
29722         ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
29723 }
29724
29725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
29726         LDKChannelManager this_arg_conv;
29727         this_arg_conv.inner = untag_ptr(this_arg);
29728         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29730         this_arg_conv.is_owned = false;
29731         LDKThirtyTwoBytes payment_preimage_ref;
29732         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
29733         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
29734         ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
29735 }
29736
29737 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
29738         LDKChannelManager this_arg_conv;
29739         this_arg_conv.inner = untag_ptr(this_arg);
29740         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29742         this_arg_conv.is_owned = false;
29743         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29744         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
29745         return ret_arr;
29746 }
29747
29748 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) {
29749         LDKChannelManager this_arg_conv;
29750         this_arg_conv.inner = untag_ptr(this_arg);
29751         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29753         this_arg_conv.is_owned = false;
29754         unsigned char temporary_channel_id_arr[32];
29755         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
29756         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
29757         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
29758         LDKPublicKey counterparty_node_id_ref;
29759         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
29760         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
29761         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29762         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
29763         return tag_ptr(ret_conv, true);
29764 }
29765
29766 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) {
29767         LDKChannelManager this_arg_conv;
29768         this_arg_conv.inner = untag_ptr(this_arg);
29769         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29771         this_arg_conv.is_owned = false;
29772         unsigned char temporary_channel_id_arr[32];
29773         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
29774         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
29775         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
29776         LDKPublicKey counterparty_node_id_ref;
29777         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
29778         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
29779         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29780         *ret_conv = ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
29781         return tag_ptr(ret_conv, true);
29782 }
29783
29784 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) {
29785         LDKChannelManager this_arg_conv;
29786         this_arg_conv.inner = untag_ptr(this_arg);
29787         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29789         this_arg_conv.is_owned = false;
29790         void* min_value_msat_ptr = untag_ptr(min_value_msat);
29791         CHECK_ACCESS(min_value_msat_ptr);
29792         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
29793         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
29794         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
29795         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
29796         return tag_ptr(ret_conv, true);
29797 }
29798
29799 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) {
29800         LDKChannelManager this_arg_conv;
29801         this_arg_conv.inner = untag_ptr(this_arg);
29802         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29804         this_arg_conv.is_owned = false;
29805         void* min_value_msat_ptr = untag_ptr(min_value_msat);
29806         CHECK_ACCESS(min_value_msat_ptr);
29807         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
29808         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
29809         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
29810         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
29811         return tag_ptr(ret_conv, true);
29812 }
29813
29814 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) {
29815         LDKChannelManager this_arg_conv;
29816         this_arg_conv.inner = untag_ptr(this_arg);
29817         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29819         this_arg_conv.is_owned = false;
29820         LDKThirtyTwoBytes payment_hash_ref;
29821         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
29822         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
29823         void* min_value_msat_ptr = untag_ptr(min_value_msat);
29824         CHECK_ACCESS(min_value_msat_ptr);
29825         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
29826         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
29827         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
29828         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
29829         return tag_ptr(ret_conv, true);
29830 }
29831
29832 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) {
29833         LDKChannelManager this_arg_conv;
29834         this_arg_conv.inner = untag_ptr(this_arg);
29835         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29837         this_arg_conv.is_owned = false;
29838         LDKThirtyTwoBytes payment_hash_ref;
29839         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
29840         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
29841         void* min_value_msat_ptr = untag_ptr(min_value_msat);
29842         CHECK_ACCESS(min_value_msat_ptr);
29843         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
29844         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
29845         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
29846         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
29847         return tag_ptr(ret_conv, true);
29848 }
29849
29850 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) {
29851         LDKChannelManager this_arg_conv;
29852         this_arg_conv.inner = untag_ptr(this_arg);
29853         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29855         this_arg_conv.is_owned = false;
29856         LDKThirtyTwoBytes payment_hash_ref;
29857         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
29858         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
29859         LDKThirtyTwoBytes payment_secret_ref;
29860         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
29861         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
29862         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
29863         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
29864         return tag_ptr(ret_conv, true);
29865 }
29866
29867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
29868         LDKChannelManager this_arg_conv;
29869         this_arg_conv.inner = untag_ptr(this_arg);
29870         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29872         this_arg_conv.is_owned = false;
29873         int64_t ret_conv = ChannelManager_get_phantom_scid(&this_arg_conv);
29874         return ret_conv;
29875 }
29876
29877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
29878         LDKChannelManager this_arg_conv;
29879         this_arg_conv.inner = untag_ptr(this_arg);
29880         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29882         this_arg_conv.is_owned = false;
29883         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
29884         int64_t ret_ref = 0;
29885         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29886         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29887         return ret_ref;
29888 }
29889
29890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
29891         LDKChannelManager this_arg_conv;
29892         this_arg_conv.inner = untag_ptr(this_arg);
29893         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29895         this_arg_conv.is_owned = false;
29896         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
29897         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
29898         return tag_ptr(ret_ret, true);
29899 }
29900
29901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
29902         LDKChannelManager this_arg_conv;
29903         this_arg_conv.inner = untag_ptr(this_arg);
29904         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29906         this_arg_conv.is_owned = false;
29907         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
29908         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
29909         return tag_ptr(ret_ret, true);
29910 }
29911
29912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
29913         LDKChannelManager this_arg_conv;
29914         this_arg_conv.inner = untag_ptr(this_arg);
29915         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29917         this_arg_conv.is_owned = false;
29918         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
29919         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
29920         return tag_ptr(ret_ret, true);
29921 }
29922
29923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
29924         LDKChannelManager this_arg_conv;
29925         this_arg_conv.inner = untag_ptr(this_arg);
29926         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29928         this_arg_conv.is_owned = false;
29929         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
29930         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
29931         return tag_ptr(ret_ret, true);
29932 }
29933
29934 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) {
29935         LDKChannelManager this_arg_conv;
29936         this_arg_conv.inner = untag_ptr(this_arg);
29937         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29939         this_arg_conv.is_owned = false;
29940         jboolean ret_conv = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
29941         return ret_conv;
29942 }
29943
29944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
29945         LDKChannelManager this_arg_conv;
29946         this_arg_conv.inner = untag_ptr(this_arg);
29947         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29949         this_arg_conv.is_owned = false;
29950         ChannelManager_await_persistable_update(&this_arg_conv);
29951 }
29952
29953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
29954         LDKChannelManager this_arg_conv;
29955         this_arg_conv.inner = untag_ptr(this_arg);
29956         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29958         this_arg_conv.is_owned = false;
29959         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
29960         int64_t ret_ref = 0;
29961         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29962         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29963         return ret_ref;
29964 }
29965
29966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
29967         LDKChannelManager this_arg_conv;
29968         this_arg_conv.inner = untag_ptr(this_arg);
29969         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29971         this_arg_conv.is_owned = false;
29972         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
29973         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
29974         return tag_ptr(ret_ret, true);
29975 }
29976
29977 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
29978         LDKCounterpartyForwardingInfo obj_conv;
29979         obj_conv.inner = untag_ptr(obj);
29980         obj_conv.is_owned = ptr_is_owned(obj);
29981         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29982         obj_conv.is_owned = false;
29983         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
29984         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29985         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29986         CVec_u8Z_free(ret_var);
29987         return ret_arr;
29988 }
29989
29990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29991         LDKu8slice ser_ref;
29992         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29993         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29994         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
29995         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
29996         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29997         return tag_ptr(ret_conv, true);
29998 }
29999
30000 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1write(JNIEnv *env, jclass clz, int64_t obj) {
30001         LDKChannelCounterparty obj_conv;
30002         obj_conv.inner = untag_ptr(obj);
30003         obj_conv.is_owned = ptr_is_owned(obj);
30004         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30005         obj_conv.is_owned = false;
30006         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
30007         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30008         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30009         CVec_u8Z_free(ret_var);
30010         return ret_arr;
30011 }
30012
30013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30014         LDKu8slice ser_ref;
30015         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30016         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30017         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
30018         *ret_conv = ChannelCounterparty_read(ser_ref);
30019         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30020         return tag_ptr(ret_conv, true);
30021 }
30022
30023 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1write(JNIEnv *env, jclass clz, int64_t obj) {
30024         LDKChannelDetails obj_conv;
30025         obj_conv.inner = untag_ptr(obj);
30026         obj_conv.is_owned = ptr_is_owned(obj);
30027         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30028         obj_conv.is_owned = false;
30029         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
30030         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30031         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30032         CVec_u8Z_free(ret_var);
30033         return ret_arr;
30034 }
30035
30036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30037         LDKu8slice ser_ref;
30038         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30039         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30040         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
30041         *ret_conv = ChannelDetails_read(ser_ref);
30042         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30043         return tag_ptr(ret_conv, true);
30044 }
30045
30046 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1write(JNIEnv *env, jclass clz, int64_t obj) {
30047         LDKPhantomRouteHints obj_conv;
30048         obj_conv.inner = untag_ptr(obj);
30049         obj_conv.is_owned = ptr_is_owned(obj);
30050         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30051         obj_conv.is_owned = false;
30052         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
30053         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30054         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30055         CVec_u8Z_free(ret_var);
30056         return ret_arr;
30057 }
30058
30059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30060         LDKu8slice ser_ref;
30061         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30062         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30063         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
30064         *ret_conv = PhantomRouteHints_read(ser_ref);
30065         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30066         return tag_ptr(ret_conv, true);
30067 }
30068
30069 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
30070         LDKChannelManager obj_conv;
30071         obj_conv.inner = untag_ptr(obj);
30072         obj_conv.is_owned = ptr_is_owned(obj);
30073         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30074         obj_conv.is_owned = false;
30075         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
30076         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30077         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30078         CVec_u8Z_free(ret_var);
30079         return ret_arr;
30080 }
30081
30082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30083         LDKChannelManagerReadArgs this_obj_conv;
30084         this_obj_conv.inner = untag_ptr(this_obj);
30085         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30087         ChannelManagerReadArgs_free(this_obj_conv);
30088 }
30089
30090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
30091         LDKChannelManagerReadArgs this_ptr_conv;
30092         this_ptr_conv.inner = untag_ptr(this_ptr);
30093         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30095         this_ptr_conv.is_owned = false;
30096         // WARNING: This object doesn't live past this scope, needs clone!
30097         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv), false);
30098         return ret_ret;
30099 }
30100
30101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30102         LDKChannelManagerReadArgs this_ptr_conv;
30103         this_ptr_conv.inner = untag_ptr(this_ptr);
30104         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30106         this_ptr_conv.is_owned = false;
30107         void* val_ptr = untag_ptr(val);
30108         CHECK_ACCESS(val_ptr);
30109         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
30110         if (val_conv.free == LDKKeysInterface_JCalls_free) {
30111                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30112                 LDKKeysInterface_JCalls_cloned(&val_conv);
30113         }
30114         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
30115 }
30116
30117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
30118         LDKChannelManagerReadArgs this_ptr_conv;
30119         this_ptr_conv.inner = untag_ptr(this_ptr);
30120         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30122         this_ptr_conv.is_owned = false;
30123         // WARNING: This object doesn't live past this scope, needs clone!
30124         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv), false);
30125         return ret_ret;
30126 }
30127
30128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30129         LDKChannelManagerReadArgs this_ptr_conv;
30130         this_ptr_conv.inner = untag_ptr(this_ptr);
30131         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30133         this_ptr_conv.is_owned = false;
30134         void* val_ptr = untag_ptr(val);
30135         CHECK_ACCESS(val_ptr);
30136         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
30137         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
30138                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30139                 LDKFeeEstimator_JCalls_cloned(&val_conv);
30140         }
30141         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
30142 }
30143
30144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
30145         LDKChannelManagerReadArgs this_ptr_conv;
30146         this_ptr_conv.inner = untag_ptr(this_ptr);
30147         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30149         this_ptr_conv.is_owned = false;
30150         // WARNING: This object doesn't live past this scope, needs clone!
30151         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv), false);
30152         return ret_ret;
30153 }
30154
30155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30156         LDKChannelManagerReadArgs this_ptr_conv;
30157         this_ptr_conv.inner = untag_ptr(this_ptr);
30158         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30160         this_ptr_conv.is_owned = false;
30161         void* val_ptr = untag_ptr(val);
30162         CHECK_ACCESS(val_ptr);
30163         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
30164         if (val_conv.free == LDKWatch_JCalls_free) {
30165                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30166                 LDKWatch_JCalls_cloned(&val_conv);
30167         }
30168         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
30169 }
30170
30171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
30172         LDKChannelManagerReadArgs this_ptr_conv;
30173         this_ptr_conv.inner = untag_ptr(this_ptr);
30174         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30176         this_ptr_conv.is_owned = false;
30177         // WARNING: This object doesn't live past this scope, needs clone!
30178         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv), false);
30179         return ret_ret;
30180 }
30181
30182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30183         LDKChannelManagerReadArgs this_ptr_conv;
30184         this_ptr_conv.inner = untag_ptr(this_ptr);
30185         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30187         this_ptr_conv.is_owned = false;
30188         void* val_ptr = untag_ptr(val);
30189         CHECK_ACCESS(val_ptr);
30190         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
30191         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
30192                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30193                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
30194         }
30195         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
30196 }
30197
30198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
30199         LDKChannelManagerReadArgs this_ptr_conv;
30200         this_ptr_conv.inner = untag_ptr(this_ptr);
30201         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30203         this_ptr_conv.is_owned = false;
30204         // WARNING: This object doesn't live past this scope, needs clone!
30205         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_logger(&this_ptr_conv), false);
30206         return ret_ret;
30207 }
30208
30209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30210         LDKChannelManagerReadArgs this_ptr_conv;
30211         this_ptr_conv.inner = untag_ptr(this_ptr);
30212         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30214         this_ptr_conv.is_owned = false;
30215         void* val_ptr = untag_ptr(val);
30216         CHECK_ACCESS(val_ptr);
30217         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
30218         if (val_conv.free == LDKLogger_JCalls_free) {
30219                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30220                 LDKLogger_JCalls_cloned(&val_conv);
30221         }
30222         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
30223 }
30224
30225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
30226         LDKChannelManagerReadArgs this_ptr_conv;
30227         this_ptr_conv.inner = untag_ptr(this_ptr);
30228         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30230         this_ptr_conv.is_owned = false;
30231         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
30232         int64_t ret_ref = 0;
30233         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30234         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30235         return ret_ref;
30236 }
30237
30238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30239         LDKChannelManagerReadArgs this_ptr_conv;
30240         this_ptr_conv.inner = untag_ptr(this_ptr);
30241         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30243         this_ptr_conv.is_owned = false;
30244         LDKUserConfig val_conv;
30245         val_conv.inner = untag_ptr(val);
30246         val_conv.is_owned = ptr_is_owned(val);
30247         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30248         val_conv = UserConfig_clone(&val_conv);
30249         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
30250 }
30251
30252 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) {
30253         void* keys_manager_ptr = untag_ptr(keys_manager);
30254         CHECK_ACCESS(keys_manager_ptr);
30255         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
30256         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
30257                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30258                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
30259         }
30260         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30261         CHECK_ACCESS(fee_estimator_ptr);
30262         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30263         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30264                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30265                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30266         }
30267         void* chain_monitor_ptr = untag_ptr(chain_monitor);
30268         CHECK_ACCESS(chain_monitor_ptr);
30269         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
30270         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
30271                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30272                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
30273         }
30274         void* tx_broadcaster_ptr = untag_ptr(tx_broadcaster);
30275         CHECK_ACCESS(tx_broadcaster_ptr);
30276         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
30277         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30278                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30279                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
30280         }
30281         void* logger_ptr = untag_ptr(logger);
30282         CHECK_ACCESS(logger_ptr);
30283         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30284         if (logger_conv.free == LDKLogger_JCalls_free) {
30285                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30286                 LDKLogger_JCalls_cloned(&logger_conv);
30287         }
30288         LDKUserConfig default_config_conv;
30289         default_config_conv.inner = untag_ptr(default_config);
30290         default_config_conv.is_owned = ptr_is_owned(default_config);
30291         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
30292         default_config_conv = UserConfig_clone(&default_config_conv);
30293         LDKCVec_ChannelMonitorZ channel_monitors_constr;
30294         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
30295         if (channel_monitors_constr.datalen > 0)
30296                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
30297         else
30298                 channel_monitors_constr.data = NULL;
30299         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
30300         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
30301                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
30302                 LDKChannelMonitor channel_monitors_conv_16_conv;
30303                 channel_monitors_conv_16_conv.inner = untag_ptr(channel_monitors_conv_16);
30304                 channel_monitors_conv_16_conv.is_owned = ptr_is_owned(channel_monitors_conv_16);
30305                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
30306                 channel_monitors_conv_16_conv.is_owned = false;
30307                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
30308         }
30309         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
30310         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);
30311         int64_t ret_ref = 0;
30312         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30313         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30314         return ret_ref;
30315 }
30316
30317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
30318         LDKu8slice ser_ref;
30319         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30320         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30321         LDKChannelManagerReadArgs arg_conv;
30322         arg_conv.inner = untag_ptr(arg);
30323         arg_conv.is_owned = ptr_is_owned(arg);
30324         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30325         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
30326         
30327         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
30328         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
30329         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30330         return tag_ptr(ret_conv, true);
30331 }
30332
30333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30334         LDKExpandedKey this_obj_conv;
30335         this_obj_conv.inner = untag_ptr(this_obj);
30336         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30338         ExpandedKey_free(this_obj_conv);
30339 }
30340
30341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1new(JNIEnv *env, jclass clz, int8_tArray key_material) {
30342         unsigned char key_material_arr[32];
30343         CHECK((*env)->GetArrayLength(env, key_material) == 32);
30344         (*env)->GetByteArrayRegion(env, key_material, 0, 32, key_material_arr);
30345         unsigned char (*key_material_ref)[32] = &key_material_arr;
30346         LDKExpandedKey ret_var = ExpandedKey_new(key_material_ref);
30347         int64_t ret_ref = 0;
30348         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30349         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30350         return ret_ref;
30351 }
30352
30353 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) {
30354         LDKExpandedKey keys_conv;
30355         keys_conv.inner = untag_ptr(keys);
30356         keys_conv.is_owned = ptr_is_owned(keys);
30357         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
30358         keys_conv.is_owned = false;
30359         void* min_value_msat_ptr = untag_ptr(min_value_msat);
30360         CHECK_ACCESS(min_value_msat_ptr);
30361         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
30362         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
30363         void* keys_manager_ptr = untag_ptr(keys_manager);
30364         if (ptr_is_owned(keys_manager)) { CHECK_ACCESS(keys_manager_ptr); }
30365         LDKKeysInterface* keys_manager_conv = (LDKKeysInterface*)keys_manager_ptr;
30366         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
30367         *ret_conv = create(&keys_conv, min_value_msat_conv, invoice_expiry_delta_secs, keys_manager_conv, current_time);
30368         return tag_ptr(ret_conv, true);
30369 }
30370
30371 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) {
30372         LDKExpandedKey keys_conv;
30373         keys_conv.inner = untag_ptr(keys);
30374         keys_conv.is_owned = ptr_is_owned(keys);
30375         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
30376         keys_conv.is_owned = false;
30377         void* min_value_msat_ptr = untag_ptr(min_value_msat);
30378         CHECK_ACCESS(min_value_msat_ptr);
30379         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
30380         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
30381         LDKThirtyTwoBytes payment_hash_ref;
30382         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
30383         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
30384         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
30385         *ret_conv = create_from_hash(&keys_conv, min_value_msat_conv, payment_hash_ref, invoice_expiry_delta_secs, current_time);
30386         return tag_ptr(ret_conv, true);
30387 }
30388
30389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30390         LDKDecodeError this_obj_conv;
30391         this_obj_conv.inner = untag_ptr(this_obj);
30392         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30394         DecodeError_free(this_obj_conv);
30395 }
30396
30397 static inline uint64_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
30398         LDKDecodeError ret_var = DecodeError_clone(arg);
30399         int64_t ret_ref = 0;
30400         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30401         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30402         return ret_ref;
30403 }
30404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30405         LDKDecodeError arg_conv;
30406         arg_conv.inner = untag_ptr(arg);
30407         arg_conv.is_owned = ptr_is_owned(arg);
30408         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30409         arg_conv.is_owned = false;
30410         int64_t ret_conv = DecodeError_clone_ptr(&arg_conv);
30411         return ret_conv;
30412 }
30413
30414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30415         LDKDecodeError orig_conv;
30416         orig_conv.inner = untag_ptr(orig);
30417         orig_conv.is_owned = ptr_is_owned(orig);
30418         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30419         orig_conv.is_owned = false;
30420         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
30421         int64_t ret_ref = 0;
30422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30423         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30424         return ret_ref;
30425 }
30426
30427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30428         LDKInit this_obj_conv;
30429         this_obj_conv.inner = untag_ptr(this_obj);
30430         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30432         Init_free(this_obj_conv);
30433 }
30434
30435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
30436         LDKInit this_ptr_conv;
30437         this_ptr_conv.inner = untag_ptr(this_ptr);
30438         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30440         this_ptr_conv.is_owned = false;
30441         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
30442         int64_t ret_ref = 0;
30443         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30444         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30445         return ret_ref;
30446 }
30447
30448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30449         LDKInit this_ptr_conv;
30450         this_ptr_conv.inner = untag_ptr(this_ptr);
30451         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30453         this_ptr_conv.is_owned = false;
30454         LDKInitFeatures val_conv;
30455         val_conv.inner = untag_ptr(val);
30456         val_conv.is_owned = ptr_is_owned(val);
30457         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30458         val_conv = InitFeatures_clone(&val_conv);
30459         Init_set_features(&this_ptr_conv, val_conv);
30460 }
30461
30462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr) {
30463         LDKInit this_ptr_conv;
30464         this_ptr_conv.inner = untag_ptr(this_ptr);
30465         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30467         this_ptr_conv.is_owned = false;
30468         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
30469         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
30470         int64_t ret_ref = tag_ptr(ret_copy, true);
30471         return ret_ref;
30472 }
30473
30474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30475         LDKInit this_ptr_conv;
30476         this_ptr_conv.inner = untag_ptr(this_ptr);
30477         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30479         this_ptr_conv.is_owned = false;
30480         void* val_ptr = untag_ptr(val);
30481         CHECK_ACCESS(val_ptr);
30482         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
30483         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)untag_ptr(val));
30484         Init_set_remote_network_address(&this_ptr_conv, val_conv);
30485 }
30486
30487 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) {
30488         LDKInitFeatures features_arg_conv;
30489         features_arg_conv.inner = untag_ptr(features_arg);
30490         features_arg_conv.is_owned = ptr_is_owned(features_arg);
30491         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
30492         features_arg_conv = InitFeatures_clone(&features_arg_conv);
30493         void* remote_network_address_arg_ptr = untag_ptr(remote_network_address_arg);
30494         CHECK_ACCESS(remote_network_address_arg_ptr);
30495         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
30496         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
30497         int64_t ret_ref = 0;
30498         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30499         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30500         return ret_ref;
30501 }
30502
30503 static inline uint64_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
30504         LDKInit ret_var = Init_clone(arg);
30505         int64_t ret_ref = 0;
30506         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30507         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30508         return ret_ref;
30509 }
30510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30511         LDKInit arg_conv;
30512         arg_conv.inner = untag_ptr(arg);
30513         arg_conv.is_owned = ptr_is_owned(arg);
30514         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30515         arg_conv.is_owned = false;
30516         int64_t ret_conv = Init_clone_ptr(&arg_conv);
30517         return ret_conv;
30518 }
30519
30520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30521         LDKInit orig_conv;
30522         orig_conv.inner = untag_ptr(orig);
30523         orig_conv.is_owned = ptr_is_owned(orig);
30524         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30525         orig_conv.is_owned = false;
30526         LDKInit ret_var = Init_clone(&orig_conv);
30527         int64_t ret_ref = 0;
30528         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30529         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30530         return ret_ref;
30531 }
30532
30533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30534         LDKErrorMessage this_obj_conv;
30535         this_obj_conv.inner = untag_ptr(this_obj);
30536         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30538         ErrorMessage_free(this_obj_conv);
30539 }
30540
30541 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30542         LDKErrorMessage this_ptr_conv;
30543         this_ptr_conv.inner = untag_ptr(this_ptr);
30544         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30546         this_ptr_conv.is_owned = false;
30547         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30548         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
30549         return ret_arr;
30550 }
30551
30552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30553         LDKErrorMessage this_ptr_conv;
30554         this_ptr_conv.inner = untag_ptr(this_ptr);
30555         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30557         this_ptr_conv.is_owned = false;
30558         LDKThirtyTwoBytes val_ref;
30559         CHECK((*env)->GetArrayLength(env, val) == 32);
30560         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30561         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
30562 }
30563
30564 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
30565         LDKErrorMessage 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         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
30571         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
30572         Str_free(ret_str);
30573         return ret_conv;
30574 }
30575
30576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
30577         LDKErrorMessage this_ptr_conv;
30578         this_ptr_conv.inner = untag_ptr(this_ptr);
30579         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30581         this_ptr_conv.is_owned = false;
30582         LDKStr val_conv = java_to_owned_str(env, val);
30583         ErrorMessage_set_data(&this_ptr_conv, val_conv);
30584 }
30585
30586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
30587         LDKThirtyTwoBytes channel_id_arg_ref;
30588         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
30589         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
30590         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
30591         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
30592         int64_t ret_ref = 0;
30593         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30594         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30595         return ret_ref;
30596 }
30597
30598 static inline uint64_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
30599         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
30600         int64_t ret_ref = 0;
30601         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30602         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30603         return ret_ref;
30604 }
30605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30606         LDKErrorMessage arg_conv;
30607         arg_conv.inner = untag_ptr(arg);
30608         arg_conv.is_owned = ptr_is_owned(arg);
30609         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30610         arg_conv.is_owned = false;
30611         int64_t ret_conv = ErrorMessage_clone_ptr(&arg_conv);
30612         return ret_conv;
30613 }
30614
30615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30616         LDKErrorMessage orig_conv;
30617         orig_conv.inner = untag_ptr(orig);
30618         orig_conv.is_owned = ptr_is_owned(orig);
30619         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30620         orig_conv.is_owned = false;
30621         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
30622         int64_t ret_ref = 0;
30623         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30624         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30625         return ret_ref;
30626 }
30627
30628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30629         LDKWarningMessage this_obj_conv;
30630         this_obj_conv.inner = untag_ptr(this_obj);
30631         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30633         WarningMessage_free(this_obj_conv);
30634 }
30635
30636 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30637         LDKWarningMessage this_ptr_conv;
30638         this_ptr_conv.inner = untag_ptr(this_ptr);
30639         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30641         this_ptr_conv.is_owned = false;
30642         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30643         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *WarningMessage_get_channel_id(&this_ptr_conv));
30644         return ret_arr;
30645 }
30646
30647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30648         LDKWarningMessage this_ptr_conv;
30649         this_ptr_conv.inner = untag_ptr(this_ptr);
30650         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30652         this_ptr_conv.is_owned = false;
30653         LDKThirtyTwoBytes val_ref;
30654         CHECK((*env)->GetArrayLength(env, val) == 32);
30655         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30656         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
30657 }
30658
30659 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
30660         LDKWarningMessage this_ptr_conv;
30661         this_ptr_conv.inner = untag_ptr(this_ptr);
30662         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30664         this_ptr_conv.is_owned = false;
30665         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
30666         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
30667         Str_free(ret_str);
30668         return ret_conv;
30669 }
30670
30671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
30672         LDKWarningMessage 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         LDKStr val_conv = java_to_owned_str(env, val);
30678         WarningMessage_set_data(&this_ptr_conv, val_conv);
30679 }
30680
30681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
30682         LDKThirtyTwoBytes channel_id_arg_ref;
30683         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
30684         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
30685         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
30686         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
30687         int64_t ret_ref = 0;
30688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30689         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30690         return ret_ref;
30691 }
30692
30693 static inline uint64_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
30694         LDKWarningMessage ret_var = WarningMessage_clone(arg);
30695         int64_t ret_ref = 0;
30696         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30697         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30698         return ret_ref;
30699 }
30700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30701         LDKWarningMessage arg_conv;
30702         arg_conv.inner = untag_ptr(arg);
30703         arg_conv.is_owned = ptr_is_owned(arg);
30704         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30705         arg_conv.is_owned = false;
30706         int64_t ret_conv = WarningMessage_clone_ptr(&arg_conv);
30707         return ret_conv;
30708 }
30709
30710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30711         LDKWarningMessage orig_conv;
30712         orig_conv.inner = untag_ptr(orig);
30713         orig_conv.is_owned = ptr_is_owned(orig);
30714         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30715         orig_conv.is_owned = false;
30716         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
30717         int64_t ret_ref = 0;
30718         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30719         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30720         return ret_ref;
30721 }
30722
30723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30724         LDKPing this_obj_conv;
30725         this_obj_conv.inner = untag_ptr(this_obj);
30726         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30728         Ping_free(this_obj_conv);
30729 }
30730
30731 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
30732         LDKPing this_ptr_conv;
30733         this_ptr_conv.inner = untag_ptr(this_ptr);
30734         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30736         this_ptr_conv.is_owned = false;
30737         int16_t ret_conv = Ping_get_ponglen(&this_ptr_conv);
30738         return ret_conv;
30739 }
30740
30741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30742         LDKPing this_ptr_conv;
30743         this_ptr_conv.inner = untag_ptr(this_ptr);
30744         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30746         this_ptr_conv.is_owned = false;
30747         Ping_set_ponglen(&this_ptr_conv, val);
30748 }
30749
30750 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
30751         LDKPing this_ptr_conv;
30752         this_ptr_conv.inner = untag_ptr(this_ptr);
30753         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30755         this_ptr_conv.is_owned = false;
30756         int16_t ret_conv = Ping_get_byteslen(&this_ptr_conv);
30757         return ret_conv;
30758 }
30759
30760 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30761         LDKPing this_ptr_conv;
30762         this_ptr_conv.inner = untag_ptr(this_ptr);
30763         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30765         this_ptr_conv.is_owned = false;
30766         Ping_set_byteslen(&this_ptr_conv, val);
30767 }
30768
30769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
30770         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
30771         int64_t ret_ref = 0;
30772         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30773         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30774         return ret_ref;
30775 }
30776
30777 static inline uint64_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
30778         LDKPing ret_var = Ping_clone(arg);
30779         int64_t ret_ref = 0;
30780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30781         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30782         return ret_ref;
30783 }
30784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30785         LDKPing arg_conv;
30786         arg_conv.inner = untag_ptr(arg);
30787         arg_conv.is_owned = ptr_is_owned(arg);
30788         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30789         arg_conv.is_owned = false;
30790         int64_t ret_conv = Ping_clone_ptr(&arg_conv);
30791         return ret_conv;
30792 }
30793
30794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30795         LDKPing orig_conv;
30796         orig_conv.inner = untag_ptr(orig);
30797         orig_conv.is_owned = ptr_is_owned(orig);
30798         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30799         orig_conv.is_owned = false;
30800         LDKPing ret_var = Ping_clone(&orig_conv);
30801         int64_t ret_ref = 0;
30802         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30803         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30804         return ret_ref;
30805 }
30806
30807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30808         LDKPong this_obj_conv;
30809         this_obj_conv.inner = untag_ptr(this_obj);
30810         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30812         Pong_free(this_obj_conv);
30813 }
30814
30815 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
30816         LDKPong this_ptr_conv;
30817         this_ptr_conv.inner = untag_ptr(this_ptr);
30818         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30820         this_ptr_conv.is_owned = false;
30821         int16_t ret_conv = Pong_get_byteslen(&this_ptr_conv);
30822         return ret_conv;
30823 }
30824
30825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30826         LDKPong this_ptr_conv;
30827         this_ptr_conv.inner = untag_ptr(this_ptr);
30828         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30830         this_ptr_conv.is_owned = false;
30831         Pong_set_byteslen(&this_ptr_conv, val);
30832 }
30833
30834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
30835         LDKPong ret_var = Pong_new(byteslen_arg);
30836         int64_t ret_ref = 0;
30837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30838         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30839         return ret_ref;
30840 }
30841
30842 static inline uint64_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
30843         LDKPong ret_var = Pong_clone(arg);
30844         int64_t ret_ref = 0;
30845         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30846         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30847         return ret_ref;
30848 }
30849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30850         LDKPong arg_conv;
30851         arg_conv.inner = untag_ptr(arg);
30852         arg_conv.is_owned = ptr_is_owned(arg);
30853         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30854         arg_conv.is_owned = false;
30855         int64_t ret_conv = Pong_clone_ptr(&arg_conv);
30856         return ret_conv;
30857 }
30858
30859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30860         LDKPong orig_conv;
30861         orig_conv.inner = untag_ptr(orig);
30862         orig_conv.is_owned = ptr_is_owned(orig);
30863         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30864         orig_conv.is_owned = false;
30865         LDKPong ret_var = Pong_clone(&orig_conv);
30866         int64_t ret_ref = 0;
30867         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30868         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30869         return ret_ref;
30870 }
30871
30872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30873         LDKOpenChannel this_obj_conv;
30874         this_obj_conv.inner = untag_ptr(this_obj);
30875         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30877         OpenChannel_free(this_obj_conv);
30878 }
30879
30880 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
30881         LDKOpenChannel this_ptr_conv;
30882         this_ptr_conv.inner = untag_ptr(this_ptr);
30883         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30885         this_ptr_conv.is_owned = false;
30886         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30887         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
30888         return ret_arr;
30889 }
30890
30891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30892         LDKOpenChannel this_ptr_conv;
30893         this_ptr_conv.inner = untag_ptr(this_ptr);
30894         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30896         this_ptr_conv.is_owned = false;
30897         LDKThirtyTwoBytes val_ref;
30898         CHECK((*env)->GetArrayLength(env, val) == 32);
30899         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30900         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
30901 }
30902
30903 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30904         LDKOpenChannel this_ptr_conv;
30905         this_ptr_conv.inner = untag_ptr(this_ptr);
30906         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30908         this_ptr_conv.is_owned = false;
30909         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30910         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
30911         return ret_arr;
30912 }
30913
30914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30915         LDKOpenChannel this_ptr_conv;
30916         this_ptr_conv.inner = untag_ptr(this_ptr);
30917         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30919         this_ptr_conv.is_owned = false;
30920         LDKThirtyTwoBytes val_ref;
30921         CHECK((*env)->GetArrayLength(env, val) == 32);
30922         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30923         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
30924 }
30925
30926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30927         LDKOpenChannel this_ptr_conv;
30928         this_ptr_conv.inner = untag_ptr(this_ptr);
30929         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30931         this_ptr_conv.is_owned = false;
30932         int64_t ret_conv = OpenChannel_get_funding_satoshis(&this_ptr_conv);
30933         return ret_conv;
30934 }
30935
30936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30937         LDKOpenChannel this_ptr_conv;
30938         this_ptr_conv.inner = untag_ptr(this_ptr);
30939         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30941         this_ptr_conv.is_owned = false;
30942         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
30943 }
30944
30945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30946         LDKOpenChannel this_ptr_conv;
30947         this_ptr_conv.inner = untag_ptr(this_ptr);
30948         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30950         this_ptr_conv.is_owned = false;
30951         int64_t ret_conv = OpenChannel_get_push_msat(&this_ptr_conv);
30952         return ret_conv;
30953 }
30954
30955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30956         LDKOpenChannel this_ptr_conv;
30957         this_ptr_conv.inner = untag_ptr(this_ptr);
30958         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30960         this_ptr_conv.is_owned = false;
30961         OpenChannel_set_push_msat(&this_ptr_conv, val);
30962 }
30963
30964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30965         LDKOpenChannel this_ptr_conv;
30966         this_ptr_conv.inner = untag_ptr(this_ptr);
30967         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30969         this_ptr_conv.is_owned = false;
30970         int64_t ret_conv = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
30971         return ret_conv;
30972 }
30973
30974 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30975         LDKOpenChannel this_ptr_conv;
30976         this_ptr_conv.inner = untag_ptr(this_ptr);
30977         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30979         this_ptr_conv.is_owned = false;
30980         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
30981 }
30982
30983 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) {
30984         LDKOpenChannel this_ptr_conv;
30985         this_ptr_conv.inner = untag_ptr(this_ptr);
30986         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30988         this_ptr_conv.is_owned = false;
30989         int64_t ret_conv = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
30990         return ret_conv;
30991 }
30992
30993 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) {
30994         LDKOpenChannel this_ptr_conv;
30995         this_ptr_conv.inner = untag_ptr(this_ptr);
30996         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30998         this_ptr_conv.is_owned = false;
30999         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
31000 }
31001
31002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
31003         LDKOpenChannel this_ptr_conv;
31004         this_ptr_conv.inner = untag_ptr(this_ptr);
31005         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31007         this_ptr_conv.is_owned = false;
31008         int64_t ret_conv = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
31009         return ret_conv;
31010 }
31011
31012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31013         LDKOpenChannel this_ptr_conv;
31014         this_ptr_conv.inner = untag_ptr(this_ptr);
31015         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31017         this_ptr_conv.is_owned = false;
31018         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
31019 }
31020
31021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31022         LDKOpenChannel this_ptr_conv;
31023         this_ptr_conv.inner = untag_ptr(this_ptr);
31024         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31026         this_ptr_conv.is_owned = false;
31027         int64_t ret_conv = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
31028         return ret_conv;
31029 }
31030
31031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31032         LDKOpenChannel this_ptr_conv;
31033         this_ptr_conv.inner = untag_ptr(this_ptr);
31034         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31036         this_ptr_conv.is_owned = false;
31037         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
31038 }
31039
31040 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
31041         LDKOpenChannel this_ptr_conv;
31042         this_ptr_conv.inner = untag_ptr(this_ptr);
31043         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31045         this_ptr_conv.is_owned = false;
31046         int32_t ret_conv = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
31047         return ret_conv;
31048 }
31049
31050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31051         LDKOpenChannel this_ptr_conv;
31052         this_ptr_conv.inner = untag_ptr(this_ptr);
31053         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31055         this_ptr_conv.is_owned = false;
31056         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
31057 }
31058
31059 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
31060         LDKOpenChannel this_ptr_conv;
31061         this_ptr_conv.inner = untag_ptr(this_ptr);
31062         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31064         this_ptr_conv.is_owned = false;
31065         int16_t ret_conv = OpenChannel_get_to_self_delay(&this_ptr_conv);
31066         return ret_conv;
31067 }
31068
31069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31070         LDKOpenChannel this_ptr_conv;
31071         this_ptr_conv.inner = untag_ptr(this_ptr);
31072         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31074         this_ptr_conv.is_owned = false;
31075         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
31076 }
31077
31078 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
31079         LDKOpenChannel this_ptr_conv;
31080         this_ptr_conv.inner = untag_ptr(this_ptr);
31081         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31083         this_ptr_conv.is_owned = false;
31084         int16_t ret_conv = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
31085         return ret_conv;
31086 }
31087
31088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31089         LDKOpenChannel this_ptr_conv;
31090         this_ptr_conv.inner = untag_ptr(this_ptr);
31091         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31093         this_ptr_conv.is_owned = false;
31094         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
31095 }
31096
31097 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
31098         LDKOpenChannel this_ptr_conv;
31099         this_ptr_conv.inner = untag_ptr(this_ptr);
31100         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31102         this_ptr_conv.is_owned = false;
31103         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31104         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
31105         return ret_arr;
31106 }
31107
31108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31109         LDKOpenChannel this_ptr_conv;
31110         this_ptr_conv.inner = untag_ptr(this_ptr);
31111         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31113         this_ptr_conv.is_owned = false;
31114         LDKPublicKey val_ref;
31115         CHECK((*env)->GetArrayLength(env, val) == 33);
31116         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31117         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
31118 }
31119
31120 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
31121         LDKOpenChannel this_ptr_conv;
31122         this_ptr_conv.inner = untag_ptr(this_ptr);
31123         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31125         this_ptr_conv.is_owned = false;
31126         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31127         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
31128         return ret_arr;
31129 }
31130
31131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31132         LDKOpenChannel this_ptr_conv;
31133         this_ptr_conv.inner = untag_ptr(this_ptr);
31134         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31136         this_ptr_conv.is_owned = false;
31137         LDKPublicKey val_ref;
31138         CHECK((*env)->GetArrayLength(env, val) == 33);
31139         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31140         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
31141 }
31142
31143 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
31144         LDKOpenChannel this_ptr_conv;
31145         this_ptr_conv.inner = untag_ptr(this_ptr);
31146         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31148         this_ptr_conv.is_owned = false;
31149         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31150         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
31151         return ret_arr;
31152 }
31153
31154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31155         LDKOpenChannel this_ptr_conv;
31156         this_ptr_conv.inner = untag_ptr(this_ptr);
31157         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31159         this_ptr_conv.is_owned = false;
31160         LDKPublicKey val_ref;
31161         CHECK((*env)->GetArrayLength(env, val) == 33);
31162         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31163         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
31164 }
31165
31166 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
31167         LDKOpenChannel this_ptr_conv;
31168         this_ptr_conv.inner = untag_ptr(this_ptr);
31169         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31171         this_ptr_conv.is_owned = false;
31172         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31173         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
31174         return ret_arr;
31175 }
31176
31177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31178         LDKOpenChannel this_ptr_conv;
31179         this_ptr_conv.inner = untag_ptr(this_ptr);
31180         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31182         this_ptr_conv.is_owned = false;
31183         LDKPublicKey val_ref;
31184         CHECK((*env)->GetArrayLength(env, val) == 33);
31185         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31186         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
31187 }
31188
31189 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
31190         LDKOpenChannel this_ptr_conv;
31191         this_ptr_conv.inner = untag_ptr(this_ptr);
31192         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31194         this_ptr_conv.is_owned = false;
31195         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31196         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
31197         return ret_arr;
31198 }
31199
31200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31201         LDKOpenChannel this_ptr_conv;
31202         this_ptr_conv.inner = untag_ptr(this_ptr);
31203         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31205         this_ptr_conv.is_owned = false;
31206         LDKPublicKey val_ref;
31207         CHECK((*env)->GetArrayLength(env, val) == 33);
31208         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31209         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
31210 }
31211
31212 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
31213         LDKOpenChannel this_ptr_conv;
31214         this_ptr_conv.inner = untag_ptr(this_ptr);
31215         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31217         this_ptr_conv.is_owned = false;
31218         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31219         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
31220         return ret_arr;
31221 }
31222
31223 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) {
31224         LDKOpenChannel this_ptr_conv;
31225         this_ptr_conv.inner = untag_ptr(this_ptr);
31226         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31228         this_ptr_conv.is_owned = false;
31229         LDKPublicKey val_ref;
31230         CHECK((*env)->GetArrayLength(env, val) == 33);
31231         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31232         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
31233 }
31234
31235 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
31236         LDKOpenChannel this_ptr_conv;
31237         this_ptr_conv.inner = untag_ptr(this_ptr);
31238         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31240         this_ptr_conv.is_owned = false;
31241         int8_t ret_conv = OpenChannel_get_channel_flags(&this_ptr_conv);
31242         return ret_conv;
31243 }
31244
31245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
31246         LDKOpenChannel this_ptr_conv;
31247         this_ptr_conv.inner = untag_ptr(this_ptr);
31248         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31250         this_ptr_conv.is_owned = false;
31251         OpenChannel_set_channel_flags(&this_ptr_conv, val);
31252 }
31253
31254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
31255         LDKOpenChannel this_ptr_conv;
31256         this_ptr_conv.inner = untag_ptr(this_ptr);
31257         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31259         this_ptr_conv.is_owned = false;
31260         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
31261         int64_t ret_ref = 0;
31262         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31263         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31264         return ret_ref;
31265 }
31266
31267 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31268         LDKOpenChannel this_ptr_conv;
31269         this_ptr_conv.inner = untag_ptr(this_ptr);
31270         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31272         this_ptr_conv.is_owned = false;
31273         LDKChannelTypeFeatures val_conv;
31274         val_conv.inner = untag_ptr(val);
31275         val_conv.is_owned = ptr_is_owned(val);
31276         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31277         val_conv = ChannelTypeFeatures_clone(&val_conv);
31278         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
31279 }
31280
31281 static inline uint64_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
31282         LDKOpenChannel ret_var = OpenChannel_clone(arg);
31283         int64_t ret_ref = 0;
31284         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31285         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31286         return ret_ref;
31287 }
31288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31289         LDKOpenChannel arg_conv;
31290         arg_conv.inner = untag_ptr(arg);
31291         arg_conv.is_owned = ptr_is_owned(arg);
31292         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31293         arg_conv.is_owned = false;
31294         int64_t ret_conv = OpenChannel_clone_ptr(&arg_conv);
31295         return ret_conv;
31296 }
31297
31298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31299         LDKOpenChannel orig_conv;
31300         orig_conv.inner = untag_ptr(orig);
31301         orig_conv.is_owned = ptr_is_owned(orig);
31302         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31303         orig_conv.is_owned = false;
31304         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
31305         int64_t ret_ref = 0;
31306         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31307         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31308         return ret_ref;
31309 }
31310
31311 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31312         LDKAcceptChannel this_obj_conv;
31313         this_obj_conv.inner = untag_ptr(this_obj);
31314         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31316         AcceptChannel_free(this_obj_conv);
31317 }
31318
31319 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31320         LDKAcceptChannel this_ptr_conv;
31321         this_ptr_conv.inner = untag_ptr(this_ptr);
31322         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31324         this_ptr_conv.is_owned = false;
31325         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31326         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
31327         return ret_arr;
31328 }
31329
31330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31331         LDKAcceptChannel this_ptr_conv;
31332         this_ptr_conv.inner = untag_ptr(this_ptr);
31333         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31335         this_ptr_conv.is_owned = false;
31336         LDKThirtyTwoBytes val_ref;
31337         CHECK((*env)->GetArrayLength(env, val) == 32);
31338         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31339         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
31340 }
31341
31342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
31343         LDKAcceptChannel this_ptr_conv;
31344         this_ptr_conv.inner = untag_ptr(this_ptr);
31345         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31347         this_ptr_conv.is_owned = false;
31348         int64_t ret_conv = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
31349         return ret_conv;
31350 }
31351
31352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31353         LDKAcceptChannel this_ptr_conv;
31354         this_ptr_conv.inner = untag_ptr(this_ptr);
31355         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31357         this_ptr_conv.is_owned = false;
31358         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
31359 }
31360
31361 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) {
31362         LDKAcceptChannel this_ptr_conv;
31363         this_ptr_conv.inner = untag_ptr(this_ptr);
31364         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31366         this_ptr_conv.is_owned = false;
31367         int64_t ret_conv = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
31368         return ret_conv;
31369 }
31370
31371 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) {
31372         LDKAcceptChannel this_ptr_conv;
31373         this_ptr_conv.inner = untag_ptr(this_ptr);
31374         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31376         this_ptr_conv.is_owned = false;
31377         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
31378 }
31379
31380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
31381         LDKAcceptChannel this_ptr_conv;
31382         this_ptr_conv.inner = untag_ptr(this_ptr);
31383         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31385         this_ptr_conv.is_owned = false;
31386         int64_t ret_conv = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
31387         return ret_conv;
31388 }
31389
31390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31391         LDKAcceptChannel this_ptr_conv;
31392         this_ptr_conv.inner = untag_ptr(this_ptr);
31393         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31395         this_ptr_conv.is_owned = false;
31396         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
31397 }
31398
31399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31400         LDKAcceptChannel this_ptr_conv;
31401         this_ptr_conv.inner = untag_ptr(this_ptr);
31402         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31404         this_ptr_conv.is_owned = false;
31405         int64_t ret_conv = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
31406         return ret_conv;
31407 }
31408
31409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31410         LDKAcceptChannel this_ptr_conv;
31411         this_ptr_conv.inner = untag_ptr(this_ptr);
31412         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31414         this_ptr_conv.is_owned = false;
31415         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
31416 }
31417
31418 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
31419         LDKAcceptChannel this_ptr_conv;
31420         this_ptr_conv.inner = untag_ptr(this_ptr);
31421         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31423         this_ptr_conv.is_owned = false;
31424         int32_t ret_conv = AcceptChannel_get_minimum_depth(&this_ptr_conv);
31425         return ret_conv;
31426 }
31427
31428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31429         LDKAcceptChannel this_ptr_conv;
31430         this_ptr_conv.inner = untag_ptr(this_ptr);
31431         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31433         this_ptr_conv.is_owned = false;
31434         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
31435 }
31436
31437 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
31438         LDKAcceptChannel this_ptr_conv;
31439         this_ptr_conv.inner = untag_ptr(this_ptr);
31440         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31442         this_ptr_conv.is_owned = false;
31443         int16_t ret_conv = AcceptChannel_get_to_self_delay(&this_ptr_conv);
31444         return ret_conv;
31445 }
31446
31447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31448         LDKAcceptChannel this_ptr_conv;
31449         this_ptr_conv.inner = untag_ptr(this_ptr);
31450         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31452         this_ptr_conv.is_owned = false;
31453         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
31454 }
31455
31456 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
31457         LDKAcceptChannel this_ptr_conv;
31458         this_ptr_conv.inner = untag_ptr(this_ptr);
31459         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31461         this_ptr_conv.is_owned = false;
31462         int16_t ret_conv = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
31463         return ret_conv;
31464 }
31465
31466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31467         LDKAcceptChannel this_ptr_conv;
31468         this_ptr_conv.inner = untag_ptr(this_ptr);
31469         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31471         this_ptr_conv.is_owned = false;
31472         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
31473 }
31474
31475 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
31476         LDKAcceptChannel this_ptr_conv;
31477         this_ptr_conv.inner = untag_ptr(this_ptr);
31478         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31480         this_ptr_conv.is_owned = false;
31481         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31482         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
31483         return ret_arr;
31484 }
31485
31486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31487         LDKAcceptChannel this_ptr_conv;
31488         this_ptr_conv.inner = untag_ptr(this_ptr);
31489         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31491         this_ptr_conv.is_owned = false;
31492         LDKPublicKey val_ref;
31493         CHECK((*env)->GetArrayLength(env, val) == 33);
31494         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31495         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
31496 }
31497
31498 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
31499         LDKAcceptChannel this_ptr_conv;
31500         this_ptr_conv.inner = untag_ptr(this_ptr);
31501         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31503         this_ptr_conv.is_owned = false;
31504         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31505         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
31506         return ret_arr;
31507 }
31508
31509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31510         LDKAcceptChannel this_ptr_conv;
31511         this_ptr_conv.inner = untag_ptr(this_ptr);
31512         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31514         this_ptr_conv.is_owned = false;
31515         LDKPublicKey val_ref;
31516         CHECK((*env)->GetArrayLength(env, val) == 33);
31517         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31518         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
31519 }
31520
31521 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
31522         LDKAcceptChannel this_ptr_conv;
31523         this_ptr_conv.inner = untag_ptr(this_ptr);
31524         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31526         this_ptr_conv.is_owned = false;
31527         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31528         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
31529         return ret_arr;
31530 }
31531
31532 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31533         LDKAcceptChannel this_ptr_conv;
31534         this_ptr_conv.inner = untag_ptr(this_ptr);
31535         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31537         this_ptr_conv.is_owned = false;
31538         LDKPublicKey val_ref;
31539         CHECK((*env)->GetArrayLength(env, val) == 33);
31540         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31541         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
31542 }
31543
31544 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
31545         LDKAcceptChannel this_ptr_conv;
31546         this_ptr_conv.inner = untag_ptr(this_ptr);
31547         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31549         this_ptr_conv.is_owned = false;
31550         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31551         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
31552         return ret_arr;
31553 }
31554
31555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31556         LDKAcceptChannel this_ptr_conv;
31557         this_ptr_conv.inner = untag_ptr(this_ptr);
31558         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31560         this_ptr_conv.is_owned = false;
31561         LDKPublicKey val_ref;
31562         CHECK((*env)->GetArrayLength(env, val) == 33);
31563         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31564         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
31565 }
31566
31567 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
31568         LDKAcceptChannel this_ptr_conv;
31569         this_ptr_conv.inner = untag_ptr(this_ptr);
31570         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31572         this_ptr_conv.is_owned = false;
31573         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31574         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
31575         return ret_arr;
31576 }
31577
31578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31579         LDKAcceptChannel this_ptr_conv;
31580         this_ptr_conv.inner = untag_ptr(this_ptr);
31581         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31583         this_ptr_conv.is_owned = false;
31584         LDKPublicKey val_ref;
31585         CHECK((*env)->GetArrayLength(env, val) == 33);
31586         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31587         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
31588 }
31589
31590 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
31591         LDKAcceptChannel this_ptr_conv;
31592         this_ptr_conv.inner = untag_ptr(this_ptr);
31593         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31595         this_ptr_conv.is_owned = false;
31596         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31597         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
31598         return ret_arr;
31599 }
31600
31601 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) {
31602         LDKAcceptChannel this_ptr_conv;
31603         this_ptr_conv.inner = untag_ptr(this_ptr);
31604         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31606         this_ptr_conv.is_owned = false;
31607         LDKPublicKey val_ref;
31608         CHECK((*env)->GetArrayLength(env, val) == 33);
31609         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31610         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
31611 }
31612
31613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
31614         LDKAcceptChannel this_ptr_conv;
31615         this_ptr_conv.inner = untag_ptr(this_ptr);
31616         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31618         this_ptr_conv.is_owned = false;
31619         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
31620         int64_t ret_ref = 0;
31621         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31622         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31623         return ret_ref;
31624 }
31625
31626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31627         LDKAcceptChannel this_ptr_conv;
31628         this_ptr_conv.inner = untag_ptr(this_ptr);
31629         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31631         this_ptr_conv.is_owned = false;
31632         LDKChannelTypeFeatures val_conv;
31633         val_conv.inner = untag_ptr(val);
31634         val_conv.is_owned = ptr_is_owned(val);
31635         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31636         val_conv = ChannelTypeFeatures_clone(&val_conv);
31637         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
31638 }
31639
31640 static inline uint64_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
31641         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
31642         int64_t ret_ref = 0;
31643         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31644         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31645         return ret_ref;
31646 }
31647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31648         LDKAcceptChannel arg_conv;
31649         arg_conv.inner = untag_ptr(arg);
31650         arg_conv.is_owned = ptr_is_owned(arg);
31651         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31652         arg_conv.is_owned = false;
31653         int64_t ret_conv = AcceptChannel_clone_ptr(&arg_conv);
31654         return ret_conv;
31655 }
31656
31657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31658         LDKAcceptChannel orig_conv;
31659         orig_conv.inner = untag_ptr(orig);
31660         orig_conv.is_owned = ptr_is_owned(orig);
31661         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31662         orig_conv.is_owned = false;
31663         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
31664         int64_t ret_ref = 0;
31665         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31666         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31667         return ret_ref;
31668 }
31669
31670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31671         LDKFundingCreated this_obj_conv;
31672         this_obj_conv.inner = untag_ptr(this_obj);
31673         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31675         FundingCreated_free(this_obj_conv);
31676 }
31677
31678 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31679         LDKFundingCreated this_ptr_conv;
31680         this_ptr_conv.inner = untag_ptr(this_ptr);
31681         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31683         this_ptr_conv.is_owned = false;
31684         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31685         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
31686         return ret_arr;
31687 }
31688
31689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31690         LDKFundingCreated this_ptr_conv;
31691         this_ptr_conv.inner = untag_ptr(this_ptr);
31692         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31694         this_ptr_conv.is_owned = false;
31695         LDKThirtyTwoBytes val_ref;
31696         CHECK((*env)->GetArrayLength(env, val) == 32);
31697         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31698         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
31699 }
31700
31701 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
31702         LDKFundingCreated this_ptr_conv;
31703         this_ptr_conv.inner = untag_ptr(this_ptr);
31704         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31706         this_ptr_conv.is_owned = false;
31707         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31708         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
31709         return ret_arr;
31710 }
31711
31712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31713         LDKFundingCreated this_ptr_conv;
31714         this_ptr_conv.inner = untag_ptr(this_ptr);
31715         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31717         this_ptr_conv.is_owned = false;
31718         LDKThirtyTwoBytes val_ref;
31719         CHECK((*env)->GetArrayLength(env, val) == 32);
31720         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31721         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
31722 }
31723
31724 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
31725         LDKFundingCreated this_ptr_conv;
31726         this_ptr_conv.inner = untag_ptr(this_ptr);
31727         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31729         this_ptr_conv.is_owned = false;
31730         int16_t ret_conv = FundingCreated_get_funding_output_index(&this_ptr_conv);
31731         return ret_conv;
31732 }
31733
31734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31735         LDKFundingCreated this_ptr_conv;
31736         this_ptr_conv.inner = untag_ptr(this_ptr);
31737         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31739         this_ptr_conv.is_owned = false;
31740         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
31741 }
31742
31743 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
31744         LDKFundingCreated this_ptr_conv;
31745         this_ptr_conv.inner = untag_ptr(this_ptr);
31746         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31748         this_ptr_conv.is_owned = false;
31749         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
31750         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
31751         return ret_arr;
31752 }
31753
31754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31755         LDKFundingCreated this_ptr_conv;
31756         this_ptr_conv.inner = untag_ptr(this_ptr);
31757         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31759         this_ptr_conv.is_owned = false;
31760         LDKSignature val_ref;
31761         CHECK((*env)->GetArrayLength(env, val) == 64);
31762         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
31763         FundingCreated_set_signature(&this_ptr_conv, val_ref);
31764 }
31765
31766 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) {
31767         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
31768         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
31769         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
31770         LDKThirtyTwoBytes funding_txid_arg_ref;
31771         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
31772         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
31773         LDKSignature signature_arg_ref;
31774         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
31775         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
31776         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
31777         int64_t ret_ref = 0;
31778         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31779         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31780         return ret_ref;
31781 }
31782
31783 static inline uint64_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
31784         LDKFundingCreated ret_var = FundingCreated_clone(arg);
31785         int64_t ret_ref = 0;
31786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31787         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31788         return ret_ref;
31789 }
31790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31791         LDKFundingCreated arg_conv;
31792         arg_conv.inner = untag_ptr(arg);
31793         arg_conv.is_owned = ptr_is_owned(arg);
31794         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31795         arg_conv.is_owned = false;
31796         int64_t ret_conv = FundingCreated_clone_ptr(&arg_conv);
31797         return ret_conv;
31798 }
31799
31800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31801         LDKFundingCreated orig_conv;
31802         orig_conv.inner = untag_ptr(orig);
31803         orig_conv.is_owned = ptr_is_owned(orig);
31804         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31805         orig_conv.is_owned = false;
31806         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
31807         int64_t ret_ref = 0;
31808         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31809         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31810         return ret_ref;
31811 }
31812
31813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31814         LDKFundingSigned this_obj_conv;
31815         this_obj_conv.inner = untag_ptr(this_obj);
31816         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31818         FundingSigned_free(this_obj_conv);
31819 }
31820
31821 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31822         LDKFundingSigned this_ptr_conv;
31823         this_ptr_conv.inner = untag_ptr(this_ptr);
31824         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31826         this_ptr_conv.is_owned = false;
31827         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31828         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
31829         return ret_arr;
31830 }
31831
31832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31833         LDKFundingSigned this_ptr_conv;
31834         this_ptr_conv.inner = untag_ptr(this_ptr);
31835         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31837         this_ptr_conv.is_owned = false;
31838         LDKThirtyTwoBytes val_ref;
31839         CHECK((*env)->GetArrayLength(env, val) == 32);
31840         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31841         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
31842 }
31843
31844 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
31845         LDKFundingSigned this_ptr_conv;
31846         this_ptr_conv.inner = untag_ptr(this_ptr);
31847         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31849         this_ptr_conv.is_owned = false;
31850         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
31851         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
31852         return ret_arr;
31853 }
31854
31855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31856         LDKFundingSigned this_ptr_conv;
31857         this_ptr_conv.inner = untag_ptr(this_ptr);
31858         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31860         this_ptr_conv.is_owned = false;
31861         LDKSignature val_ref;
31862         CHECK((*env)->GetArrayLength(env, val) == 64);
31863         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
31864         FundingSigned_set_signature(&this_ptr_conv, val_ref);
31865 }
31866
31867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
31868         LDKThirtyTwoBytes channel_id_arg_ref;
31869         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
31870         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
31871         LDKSignature signature_arg_ref;
31872         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
31873         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
31874         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
31875         int64_t ret_ref = 0;
31876         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31877         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31878         return ret_ref;
31879 }
31880
31881 static inline uint64_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
31882         LDKFundingSigned ret_var = FundingSigned_clone(arg);
31883         int64_t ret_ref = 0;
31884         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31885         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31886         return ret_ref;
31887 }
31888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31889         LDKFundingSigned arg_conv;
31890         arg_conv.inner = untag_ptr(arg);
31891         arg_conv.is_owned = ptr_is_owned(arg);
31892         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31893         arg_conv.is_owned = false;
31894         int64_t ret_conv = FundingSigned_clone_ptr(&arg_conv);
31895         return ret_conv;
31896 }
31897
31898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31899         LDKFundingSigned orig_conv;
31900         orig_conv.inner = untag_ptr(orig);
31901         orig_conv.is_owned = ptr_is_owned(orig);
31902         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31903         orig_conv.is_owned = false;
31904         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
31905         int64_t ret_ref = 0;
31906         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31907         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31908         return ret_ref;
31909 }
31910
31911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31912         LDKChannelReady this_obj_conv;
31913         this_obj_conv.inner = untag_ptr(this_obj);
31914         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31916         ChannelReady_free(this_obj_conv);
31917 }
31918
31919 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31920         LDKChannelReady this_ptr_conv;
31921         this_ptr_conv.inner = untag_ptr(this_ptr);
31922         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31924         this_ptr_conv.is_owned = false;
31925         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31926         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReady_get_channel_id(&this_ptr_conv));
31927         return ret_arr;
31928 }
31929
31930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31931         LDKChannelReady this_ptr_conv;
31932         this_ptr_conv.inner = untag_ptr(this_ptr);
31933         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31935         this_ptr_conv.is_owned = false;
31936         LDKThirtyTwoBytes val_ref;
31937         CHECK((*env)->GetArrayLength(env, val) == 32);
31938         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31939         ChannelReady_set_channel_id(&this_ptr_conv, val_ref);
31940 }
31941
31942 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
31943         LDKChannelReady this_ptr_conv;
31944         this_ptr_conv.inner = untag_ptr(this_ptr);
31945         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31947         this_ptr_conv.is_owned = false;
31948         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31949         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelReady_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
31950         return ret_arr;
31951 }
31952
31953 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) {
31954         LDKChannelReady this_ptr_conv;
31955         this_ptr_conv.inner = untag_ptr(this_ptr);
31956         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31958         this_ptr_conv.is_owned = false;
31959         LDKPublicKey val_ref;
31960         CHECK((*env)->GetArrayLength(env, val) == 33);
31961         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31962         ChannelReady_set_next_per_commitment_point(&this_ptr_conv, val_ref);
31963 }
31964
31965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1short_1channel_1id_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
31966         LDKChannelReady this_ptr_conv;
31967         this_ptr_conv.inner = untag_ptr(this_ptr);
31968         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31970         this_ptr_conv.is_owned = false;
31971         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31972         *ret_copy = ChannelReady_get_short_channel_id_alias(&this_ptr_conv);
31973         int64_t ret_ref = tag_ptr(ret_copy, true);
31974         return ret_ref;
31975 }
31976
31977 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) {
31978         LDKChannelReady this_ptr_conv;
31979         this_ptr_conv.inner = untag_ptr(this_ptr);
31980         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31982         this_ptr_conv.is_owned = false;
31983         void* val_ptr = untag_ptr(val);
31984         CHECK_ACCESS(val_ptr);
31985         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
31986         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
31987         ChannelReady_set_short_channel_id_alias(&this_ptr_conv, val_conv);
31988 }
31989
31990 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) {
31991         LDKThirtyTwoBytes channel_id_arg_ref;
31992         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
31993         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
31994         LDKPublicKey next_per_commitment_point_arg_ref;
31995         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
31996         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
31997         void* short_channel_id_alias_arg_ptr = untag_ptr(short_channel_id_alias_arg);
31998         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
31999         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
32000         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id_alias_arg));
32001         LDKChannelReady ret_var = ChannelReady_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
32002         int64_t ret_ref = 0;
32003         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32004         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32005         return ret_ref;
32006 }
32007
32008 static inline uint64_t ChannelReady_clone_ptr(LDKChannelReady *NONNULL_PTR arg) {
32009         LDKChannelReady ret_var = ChannelReady_clone(arg);
32010         int64_t ret_ref = 0;
32011         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32012         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32013         return ret_ref;
32014 }
32015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32016         LDKChannelReady arg_conv;
32017         arg_conv.inner = untag_ptr(arg);
32018         arg_conv.is_owned = ptr_is_owned(arg);
32019         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32020         arg_conv.is_owned = false;
32021         int64_t ret_conv = ChannelReady_clone_ptr(&arg_conv);
32022         return ret_conv;
32023 }
32024
32025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32026         LDKChannelReady orig_conv;
32027         orig_conv.inner = untag_ptr(orig);
32028         orig_conv.is_owned = ptr_is_owned(orig);
32029         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32030         orig_conv.is_owned = false;
32031         LDKChannelReady ret_var = ChannelReady_clone(&orig_conv);
32032         int64_t ret_ref = 0;
32033         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32034         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32035         return ret_ref;
32036 }
32037
32038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32039         LDKShutdown this_obj_conv;
32040         this_obj_conv.inner = untag_ptr(this_obj);
32041         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32043         Shutdown_free(this_obj_conv);
32044 }
32045
32046 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32047         LDKShutdown this_ptr_conv;
32048         this_ptr_conv.inner = untag_ptr(this_ptr);
32049         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32051         this_ptr_conv.is_owned = false;
32052         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32053         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
32054         return ret_arr;
32055 }
32056
32057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32058         LDKShutdown 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         LDKThirtyTwoBytes val_ref;
32064         CHECK((*env)->GetArrayLength(env, val) == 32);
32065         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32066         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
32067 }
32068
32069 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
32070         LDKShutdown this_ptr_conv;
32071         this_ptr_conv.inner = untag_ptr(this_ptr);
32072         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32074         this_ptr_conv.is_owned = false;
32075         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
32076         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32077         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32078         return ret_arr;
32079 }
32080
32081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32082         LDKShutdown this_ptr_conv;
32083         this_ptr_conv.inner = untag_ptr(this_ptr);
32084         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32086         this_ptr_conv.is_owned = false;
32087         LDKCVec_u8Z val_ref;
32088         val_ref.datalen = (*env)->GetArrayLength(env, val);
32089         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
32090         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
32091         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
32092 }
32093
32094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
32095         LDKThirtyTwoBytes channel_id_arg_ref;
32096         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32097         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32098         LDKCVec_u8Z scriptpubkey_arg_ref;
32099         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
32100         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
32101         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
32102         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
32103         int64_t ret_ref = 0;
32104         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32105         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32106         return ret_ref;
32107 }
32108
32109 static inline uint64_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
32110         LDKShutdown ret_var = Shutdown_clone(arg);
32111         int64_t ret_ref = 0;
32112         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32113         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32114         return ret_ref;
32115 }
32116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32117         LDKShutdown arg_conv;
32118         arg_conv.inner = untag_ptr(arg);
32119         arg_conv.is_owned = ptr_is_owned(arg);
32120         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32121         arg_conv.is_owned = false;
32122         int64_t ret_conv = Shutdown_clone_ptr(&arg_conv);
32123         return ret_conv;
32124 }
32125
32126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32127         LDKShutdown orig_conv;
32128         orig_conv.inner = untag_ptr(orig);
32129         orig_conv.is_owned = ptr_is_owned(orig);
32130         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32131         orig_conv.is_owned = false;
32132         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
32133         int64_t ret_ref = 0;
32134         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32135         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32136         return ret_ref;
32137 }
32138
32139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32140         LDKClosingSignedFeeRange this_obj_conv;
32141         this_obj_conv.inner = untag_ptr(this_obj);
32142         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32144         ClosingSignedFeeRange_free(this_obj_conv);
32145 }
32146
32147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32148         LDKClosingSignedFeeRange this_ptr_conv;
32149         this_ptr_conv.inner = untag_ptr(this_ptr);
32150         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32152         this_ptr_conv.is_owned = false;
32153         int64_t ret_conv = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
32154         return ret_conv;
32155 }
32156
32157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32158         LDKClosingSignedFeeRange this_ptr_conv;
32159         this_ptr_conv.inner = untag_ptr(this_ptr);
32160         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32162         this_ptr_conv.is_owned = false;
32163         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
32164 }
32165
32166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32167         LDKClosingSignedFeeRange this_ptr_conv;
32168         this_ptr_conv.inner = untag_ptr(this_ptr);
32169         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32171         this_ptr_conv.is_owned = false;
32172         int64_t ret_conv = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
32173         return ret_conv;
32174 }
32175
32176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32177         LDKClosingSignedFeeRange this_ptr_conv;
32178         this_ptr_conv.inner = untag_ptr(this_ptr);
32179         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32181         this_ptr_conv.is_owned = false;
32182         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
32183 }
32184
32185 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) {
32186         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
32187         int64_t ret_ref = 0;
32188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32189         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32190         return ret_ref;
32191 }
32192
32193 static inline uint64_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
32194         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
32195         int64_t ret_ref = 0;
32196         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32197         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32198         return ret_ref;
32199 }
32200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32201         LDKClosingSignedFeeRange arg_conv;
32202         arg_conv.inner = untag_ptr(arg);
32203         arg_conv.is_owned = ptr_is_owned(arg);
32204         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32205         arg_conv.is_owned = false;
32206         int64_t ret_conv = ClosingSignedFeeRange_clone_ptr(&arg_conv);
32207         return ret_conv;
32208 }
32209
32210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32211         LDKClosingSignedFeeRange orig_conv;
32212         orig_conv.inner = untag_ptr(orig);
32213         orig_conv.is_owned = ptr_is_owned(orig);
32214         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32215         orig_conv.is_owned = false;
32216         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
32217         int64_t ret_ref = 0;
32218         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32219         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32220         return ret_ref;
32221 }
32222
32223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32224         LDKClosingSigned this_obj_conv;
32225         this_obj_conv.inner = untag_ptr(this_obj);
32226         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32228         ClosingSigned_free(this_obj_conv);
32229 }
32230
32231 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32232         LDKClosingSigned this_ptr_conv;
32233         this_ptr_conv.inner = untag_ptr(this_ptr);
32234         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32236         this_ptr_conv.is_owned = false;
32237         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32238         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
32239         return ret_arr;
32240 }
32241
32242 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32243         LDKClosingSigned this_ptr_conv;
32244         this_ptr_conv.inner = untag_ptr(this_ptr);
32245         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32247         this_ptr_conv.is_owned = false;
32248         LDKThirtyTwoBytes val_ref;
32249         CHECK((*env)->GetArrayLength(env, val) == 32);
32250         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32251         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
32252 }
32253
32254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32255         LDKClosingSigned this_ptr_conv;
32256         this_ptr_conv.inner = untag_ptr(this_ptr);
32257         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32259         this_ptr_conv.is_owned = false;
32260         int64_t ret_conv = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
32261         return ret_conv;
32262 }
32263
32264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32265         LDKClosingSigned this_ptr_conv;
32266         this_ptr_conv.inner = untag_ptr(this_ptr);
32267         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32269         this_ptr_conv.is_owned = false;
32270         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
32271 }
32272
32273 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
32274         LDKClosingSigned this_ptr_conv;
32275         this_ptr_conv.inner = untag_ptr(this_ptr);
32276         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32278         this_ptr_conv.is_owned = false;
32279         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
32280         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
32281         return ret_arr;
32282 }
32283
32284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32285         LDKClosingSigned this_ptr_conv;
32286         this_ptr_conv.inner = untag_ptr(this_ptr);
32287         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32289         this_ptr_conv.is_owned = false;
32290         LDKSignature val_ref;
32291         CHECK((*env)->GetArrayLength(env, val) == 64);
32292         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
32293         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
32294 }
32295
32296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
32297         LDKClosingSigned this_ptr_conv;
32298         this_ptr_conv.inner = untag_ptr(this_ptr);
32299         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32301         this_ptr_conv.is_owned = false;
32302         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
32303         int64_t ret_ref = 0;
32304         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32305         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32306         return ret_ref;
32307 }
32308
32309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32310         LDKClosingSigned this_ptr_conv;
32311         this_ptr_conv.inner = untag_ptr(this_ptr);
32312         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32314         this_ptr_conv.is_owned = false;
32315         LDKClosingSignedFeeRange val_conv;
32316         val_conv.inner = untag_ptr(val);
32317         val_conv.is_owned = ptr_is_owned(val);
32318         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32319         val_conv = ClosingSignedFeeRange_clone(&val_conv);
32320         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
32321 }
32322
32323 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) {
32324         LDKThirtyTwoBytes channel_id_arg_ref;
32325         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32326         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32327         LDKSignature signature_arg_ref;
32328         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
32329         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
32330         LDKClosingSignedFeeRange fee_range_arg_conv;
32331         fee_range_arg_conv.inner = untag_ptr(fee_range_arg);
32332         fee_range_arg_conv.is_owned = ptr_is_owned(fee_range_arg);
32333         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
32334         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
32335         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
32336         int64_t ret_ref = 0;
32337         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32338         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32339         return ret_ref;
32340 }
32341
32342 static inline uint64_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
32343         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
32344         int64_t ret_ref = 0;
32345         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32346         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32347         return ret_ref;
32348 }
32349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32350         LDKClosingSigned arg_conv;
32351         arg_conv.inner = untag_ptr(arg);
32352         arg_conv.is_owned = ptr_is_owned(arg);
32353         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32354         arg_conv.is_owned = false;
32355         int64_t ret_conv = ClosingSigned_clone_ptr(&arg_conv);
32356         return ret_conv;
32357 }
32358
32359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32360         LDKClosingSigned orig_conv;
32361         orig_conv.inner = untag_ptr(orig);
32362         orig_conv.is_owned = ptr_is_owned(orig);
32363         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32364         orig_conv.is_owned = false;
32365         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
32366         int64_t ret_ref = 0;
32367         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32368         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32369         return ret_ref;
32370 }
32371
32372 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32373         LDKUpdateAddHTLC this_obj_conv;
32374         this_obj_conv.inner = untag_ptr(this_obj);
32375         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32377         UpdateAddHTLC_free(this_obj_conv);
32378 }
32379
32380 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32381         LDKUpdateAddHTLC this_ptr_conv;
32382         this_ptr_conv.inner = untag_ptr(this_ptr);
32383         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32385         this_ptr_conv.is_owned = false;
32386         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32387         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
32388         return ret_arr;
32389 }
32390
32391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32392         LDKUpdateAddHTLC this_ptr_conv;
32393         this_ptr_conv.inner = untag_ptr(this_ptr);
32394         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32396         this_ptr_conv.is_owned = false;
32397         LDKThirtyTwoBytes val_ref;
32398         CHECK((*env)->GetArrayLength(env, val) == 32);
32399         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32400         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
32401 }
32402
32403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32404         LDKUpdateAddHTLC this_ptr_conv;
32405         this_ptr_conv.inner = untag_ptr(this_ptr);
32406         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32408         this_ptr_conv.is_owned = false;
32409         int64_t ret_conv = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
32410         return ret_conv;
32411 }
32412
32413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32414         LDKUpdateAddHTLC this_ptr_conv;
32415         this_ptr_conv.inner = untag_ptr(this_ptr);
32416         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32418         this_ptr_conv.is_owned = false;
32419         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
32420 }
32421
32422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32423         LDKUpdateAddHTLC this_ptr_conv;
32424         this_ptr_conv.inner = untag_ptr(this_ptr);
32425         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32427         this_ptr_conv.is_owned = false;
32428         int64_t ret_conv = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
32429         return ret_conv;
32430 }
32431
32432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32433         LDKUpdateAddHTLC this_ptr_conv;
32434         this_ptr_conv.inner = untag_ptr(this_ptr);
32435         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32437         this_ptr_conv.is_owned = false;
32438         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
32439 }
32440
32441 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
32442         LDKUpdateAddHTLC this_ptr_conv;
32443         this_ptr_conv.inner = untag_ptr(this_ptr);
32444         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32446         this_ptr_conv.is_owned = false;
32447         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32448         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
32449         return ret_arr;
32450 }
32451
32452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32453         LDKUpdateAddHTLC this_ptr_conv;
32454         this_ptr_conv.inner = untag_ptr(this_ptr);
32455         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32457         this_ptr_conv.is_owned = false;
32458         LDKThirtyTwoBytes val_ref;
32459         CHECK((*env)->GetArrayLength(env, val) == 32);
32460         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32461         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
32462 }
32463
32464 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
32465         LDKUpdateAddHTLC this_ptr_conv;
32466         this_ptr_conv.inner = untag_ptr(this_ptr);
32467         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32469         this_ptr_conv.is_owned = false;
32470         int32_t ret_conv = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
32471         return ret_conv;
32472 }
32473
32474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
32475         LDKUpdateAddHTLC this_ptr_conv;
32476         this_ptr_conv.inner = untag_ptr(this_ptr);
32477         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32479         this_ptr_conv.is_owned = false;
32480         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
32481 }
32482
32483 static inline uint64_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
32484         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
32485         int64_t ret_ref = 0;
32486         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32487         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32488         return ret_ref;
32489 }
32490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32491         LDKUpdateAddHTLC arg_conv;
32492         arg_conv.inner = untag_ptr(arg);
32493         arg_conv.is_owned = ptr_is_owned(arg);
32494         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32495         arg_conv.is_owned = false;
32496         int64_t ret_conv = UpdateAddHTLC_clone_ptr(&arg_conv);
32497         return ret_conv;
32498 }
32499
32500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32501         LDKUpdateAddHTLC orig_conv;
32502         orig_conv.inner = untag_ptr(orig);
32503         orig_conv.is_owned = ptr_is_owned(orig);
32504         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32505         orig_conv.is_owned = false;
32506         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
32507         int64_t ret_ref = 0;
32508         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32509         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32510         return ret_ref;
32511 }
32512
32513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32514         LDKUpdateFulfillHTLC this_obj_conv;
32515         this_obj_conv.inner = untag_ptr(this_obj);
32516         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32518         UpdateFulfillHTLC_free(this_obj_conv);
32519 }
32520
32521 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32522         LDKUpdateFulfillHTLC this_ptr_conv;
32523         this_ptr_conv.inner = untag_ptr(this_ptr);
32524         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32526         this_ptr_conv.is_owned = false;
32527         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32528         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
32529         return ret_arr;
32530 }
32531
32532 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32533         LDKUpdateFulfillHTLC this_ptr_conv;
32534         this_ptr_conv.inner = untag_ptr(this_ptr);
32535         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32537         this_ptr_conv.is_owned = false;
32538         LDKThirtyTwoBytes val_ref;
32539         CHECK((*env)->GetArrayLength(env, val) == 32);
32540         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32541         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
32542 }
32543
32544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32545         LDKUpdateFulfillHTLC this_ptr_conv;
32546         this_ptr_conv.inner = untag_ptr(this_ptr);
32547         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32549         this_ptr_conv.is_owned = false;
32550         int64_t ret_conv = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
32551         return ret_conv;
32552 }
32553
32554 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32555         LDKUpdateFulfillHTLC this_ptr_conv;
32556         this_ptr_conv.inner = untag_ptr(this_ptr);
32557         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32559         this_ptr_conv.is_owned = false;
32560         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
32561 }
32562
32563 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
32564         LDKUpdateFulfillHTLC this_ptr_conv;
32565         this_ptr_conv.inner = untag_ptr(this_ptr);
32566         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32568         this_ptr_conv.is_owned = false;
32569         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32570         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
32571         return ret_arr;
32572 }
32573
32574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32575         LDKUpdateFulfillHTLC this_ptr_conv;
32576         this_ptr_conv.inner = untag_ptr(this_ptr);
32577         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32579         this_ptr_conv.is_owned = false;
32580         LDKThirtyTwoBytes val_ref;
32581         CHECK((*env)->GetArrayLength(env, val) == 32);
32582         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32583         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
32584 }
32585
32586 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) {
32587         LDKThirtyTwoBytes channel_id_arg_ref;
32588         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32589         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32590         LDKThirtyTwoBytes payment_preimage_arg_ref;
32591         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
32592         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
32593         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
32594         int64_t ret_ref = 0;
32595         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32596         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32597         return ret_ref;
32598 }
32599
32600 static inline uint64_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
32601         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
32602         int64_t ret_ref = 0;
32603         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32604         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32605         return ret_ref;
32606 }
32607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32608         LDKUpdateFulfillHTLC arg_conv;
32609         arg_conv.inner = untag_ptr(arg);
32610         arg_conv.is_owned = ptr_is_owned(arg);
32611         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32612         arg_conv.is_owned = false;
32613         int64_t ret_conv = UpdateFulfillHTLC_clone_ptr(&arg_conv);
32614         return ret_conv;
32615 }
32616
32617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32618         LDKUpdateFulfillHTLC orig_conv;
32619         orig_conv.inner = untag_ptr(orig);
32620         orig_conv.is_owned = ptr_is_owned(orig);
32621         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32622         orig_conv.is_owned = false;
32623         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
32624         int64_t ret_ref = 0;
32625         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32626         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32627         return ret_ref;
32628 }
32629
32630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32631         LDKUpdateFailHTLC this_obj_conv;
32632         this_obj_conv.inner = untag_ptr(this_obj);
32633         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32635         UpdateFailHTLC_free(this_obj_conv);
32636 }
32637
32638 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32639         LDKUpdateFailHTLC this_ptr_conv;
32640         this_ptr_conv.inner = untag_ptr(this_ptr);
32641         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32643         this_ptr_conv.is_owned = false;
32644         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32645         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
32646         return ret_arr;
32647 }
32648
32649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32650         LDKUpdateFailHTLC this_ptr_conv;
32651         this_ptr_conv.inner = untag_ptr(this_ptr);
32652         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32654         this_ptr_conv.is_owned = false;
32655         LDKThirtyTwoBytes val_ref;
32656         CHECK((*env)->GetArrayLength(env, val) == 32);
32657         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32658         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
32659 }
32660
32661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32662         LDKUpdateFailHTLC this_ptr_conv;
32663         this_ptr_conv.inner = untag_ptr(this_ptr);
32664         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32666         this_ptr_conv.is_owned = false;
32667         int64_t ret_conv = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
32668         return ret_conv;
32669 }
32670
32671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32672         LDKUpdateFailHTLC this_ptr_conv;
32673         this_ptr_conv.inner = untag_ptr(this_ptr);
32674         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32676         this_ptr_conv.is_owned = false;
32677         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
32678 }
32679
32680 static inline uint64_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
32681         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
32682         int64_t ret_ref = 0;
32683         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32684         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32685         return ret_ref;
32686 }
32687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32688         LDKUpdateFailHTLC arg_conv;
32689         arg_conv.inner = untag_ptr(arg);
32690         arg_conv.is_owned = ptr_is_owned(arg);
32691         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32692         arg_conv.is_owned = false;
32693         int64_t ret_conv = UpdateFailHTLC_clone_ptr(&arg_conv);
32694         return ret_conv;
32695 }
32696
32697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32698         LDKUpdateFailHTLC orig_conv;
32699         orig_conv.inner = untag_ptr(orig);
32700         orig_conv.is_owned = ptr_is_owned(orig);
32701         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32702         orig_conv.is_owned = false;
32703         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
32704         int64_t ret_ref = 0;
32705         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32706         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32707         return ret_ref;
32708 }
32709
32710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32711         LDKUpdateFailMalformedHTLC this_obj_conv;
32712         this_obj_conv.inner = untag_ptr(this_obj);
32713         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32715         UpdateFailMalformedHTLC_free(this_obj_conv);
32716 }
32717
32718 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32719         LDKUpdateFailMalformedHTLC this_ptr_conv;
32720         this_ptr_conv.inner = untag_ptr(this_ptr);
32721         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32723         this_ptr_conv.is_owned = false;
32724         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32725         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
32726         return ret_arr;
32727 }
32728
32729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32730         LDKUpdateFailMalformedHTLC this_ptr_conv;
32731         this_ptr_conv.inner = untag_ptr(this_ptr);
32732         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32734         this_ptr_conv.is_owned = false;
32735         LDKThirtyTwoBytes val_ref;
32736         CHECK((*env)->GetArrayLength(env, val) == 32);
32737         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32738         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
32739 }
32740
32741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32742         LDKUpdateFailMalformedHTLC this_ptr_conv;
32743         this_ptr_conv.inner = untag_ptr(this_ptr);
32744         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32746         this_ptr_conv.is_owned = false;
32747         int64_t ret_conv = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
32748         return ret_conv;
32749 }
32750
32751 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32752         LDKUpdateFailMalformedHTLC this_ptr_conv;
32753         this_ptr_conv.inner = untag_ptr(this_ptr);
32754         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32756         this_ptr_conv.is_owned = false;
32757         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
32758 }
32759
32760 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
32761         LDKUpdateFailMalformedHTLC this_ptr_conv;
32762         this_ptr_conv.inner = untag_ptr(this_ptr);
32763         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32765         this_ptr_conv.is_owned = false;
32766         int16_t ret_conv = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
32767         return ret_conv;
32768 }
32769
32770 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32771         LDKUpdateFailMalformedHTLC this_ptr_conv;
32772         this_ptr_conv.inner = untag_ptr(this_ptr);
32773         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32775         this_ptr_conv.is_owned = false;
32776         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
32777 }
32778
32779 static inline uint64_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
32780         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
32781         int64_t ret_ref = 0;
32782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32783         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32784         return ret_ref;
32785 }
32786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32787         LDKUpdateFailMalformedHTLC arg_conv;
32788         arg_conv.inner = untag_ptr(arg);
32789         arg_conv.is_owned = ptr_is_owned(arg);
32790         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32791         arg_conv.is_owned = false;
32792         int64_t ret_conv = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
32793         return ret_conv;
32794 }
32795
32796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32797         LDKUpdateFailMalformedHTLC orig_conv;
32798         orig_conv.inner = untag_ptr(orig);
32799         orig_conv.is_owned = ptr_is_owned(orig);
32800         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32801         orig_conv.is_owned = false;
32802         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
32803         int64_t ret_ref = 0;
32804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32805         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32806         return ret_ref;
32807 }
32808
32809 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32810         LDKCommitmentSigned this_obj_conv;
32811         this_obj_conv.inner = untag_ptr(this_obj);
32812         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32814         CommitmentSigned_free(this_obj_conv);
32815 }
32816
32817 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32818         LDKCommitmentSigned this_ptr_conv;
32819         this_ptr_conv.inner = untag_ptr(this_ptr);
32820         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32822         this_ptr_conv.is_owned = false;
32823         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32824         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
32825         return ret_arr;
32826 }
32827
32828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32829         LDKCommitmentSigned this_ptr_conv;
32830         this_ptr_conv.inner = untag_ptr(this_ptr);
32831         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32833         this_ptr_conv.is_owned = false;
32834         LDKThirtyTwoBytes val_ref;
32835         CHECK((*env)->GetArrayLength(env, val) == 32);
32836         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32837         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
32838 }
32839
32840 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
32841         LDKCommitmentSigned this_ptr_conv;
32842         this_ptr_conv.inner = untag_ptr(this_ptr);
32843         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32845         this_ptr_conv.is_owned = false;
32846         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
32847         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
32848         return ret_arr;
32849 }
32850
32851 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32852         LDKCommitmentSigned this_ptr_conv;
32853         this_ptr_conv.inner = untag_ptr(this_ptr);
32854         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32856         this_ptr_conv.is_owned = false;
32857         LDKSignature val_ref;
32858         CHECK((*env)->GetArrayLength(env, val) == 64);
32859         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
32860         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
32861 }
32862
32863 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr) {
32864         LDKCommitmentSigned this_ptr_conv;
32865         this_ptr_conv.inner = untag_ptr(this_ptr);
32866         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32868         this_ptr_conv.is_owned = false;
32869         LDKCVec_SignatureZ ret_var = CommitmentSigned_get_htlc_signatures(&this_ptr_conv);
32870         jobjectArray ret_arr = NULL;
32871         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
32872         ;
32873         for (size_t i = 0; i < ret_var.datalen; i++) {
32874                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
32875                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
32876                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
32877         }
32878         
32879         FREE(ret_var.data);
32880         return ret_arr;
32881 }
32882
32883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
32884         LDKCommitmentSigned this_ptr_conv;
32885         this_ptr_conv.inner = untag_ptr(this_ptr);
32886         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32888         this_ptr_conv.is_owned = false;
32889         LDKCVec_SignatureZ val_constr;
32890         val_constr.datalen = (*env)->GetArrayLength(env, val);
32891         if (val_constr.datalen > 0)
32892                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
32893         else
32894                 val_constr.data = NULL;
32895         for (size_t i = 0; i < val_constr.datalen; i++) {
32896                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
32897                 LDKSignature val_conv_8_ref;
32898                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
32899                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
32900                 val_constr.data[i] = val_conv_8_ref;
32901         }
32902         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
32903 }
32904
32905 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) {
32906         LDKThirtyTwoBytes channel_id_arg_ref;
32907         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32908         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32909         LDKSignature signature_arg_ref;
32910         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
32911         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
32912         LDKCVec_SignatureZ htlc_signatures_arg_constr;
32913         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
32914         if (htlc_signatures_arg_constr.datalen > 0)
32915                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
32916         else
32917                 htlc_signatures_arg_constr.data = NULL;
32918         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
32919                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
32920                 LDKSignature htlc_signatures_arg_conv_8_ref;
32921                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
32922                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
32923                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
32924         }
32925         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
32926         int64_t ret_ref = 0;
32927         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32928         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32929         return ret_ref;
32930 }
32931
32932 static inline uint64_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
32933         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
32934         int64_t ret_ref = 0;
32935         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32936         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32937         return ret_ref;
32938 }
32939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32940         LDKCommitmentSigned arg_conv;
32941         arg_conv.inner = untag_ptr(arg);
32942         arg_conv.is_owned = ptr_is_owned(arg);
32943         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32944         arg_conv.is_owned = false;
32945         int64_t ret_conv = CommitmentSigned_clone_ptr(&arg_conv);
32946         return ret_conv;
32947 }
32948
32949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32950         LDKCommitmentSigned orig_conv;
32951         orig_conv.inner = untag_ptr(orig);
32952         orig_conv.is_owned = ptr_is_owned(orig);
32953         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32954         orig_conv.is_owned = false;
32955         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
32956         int64_t ret_ref = 0;
32957         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32958         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32959         return ret_ref;
32960 }
32961
32962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32963         LDKRevokeAndACK this_obj_conv;
32964         this_obj_conv.inner = untag_ptr(this_obj);
32965         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32967         RevokeAndACK_free(this_obj_conv);
32968 }
32969
32970 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32971         LDKRevokeAndACK this_ptr_conv;
32972         this_ptr_conv.inner = untag_ptr(this_ptr);
32973         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32975         this_ptr_conv.is_owned = false;
32976         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32977         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
32978         return ret_arr;
32979 }
32980
32981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32982         LDKRevokeAndACK this_ptr_conv;
32983         this_ptr_conv.inner = untag_ptr(this_ptr);
32984         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32986         this_ptr_conv.is_owned = false;
32987         LDKThirtyTwoBytes val_ref;
32988         CHECK((*env)->GetArrayLength(env, val) == 32);
32989         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32990         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
32991 }
32992
32993 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
32994         LDKRevokeAndACK this_ptr_conv;
32995         this_ptr_conv.inner = untag_ptr(this_ptr);
32996         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32998         this_ptr_conv.is_owned = false;
32999         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33000         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
33001         return ret_arr;
33002 }
33003
33004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33005         LDKRevokeAndACK this_ptr_conv;
33006         this_ptr_conv.inner = untag_ptr(this_ptr);
33007         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33009         this_ptr_conv.is_owned = false;
33010         LDKThirtyTwoBytes val_ref;
33011         CHECK((*env)->GetArrayLength(env, val) == 32);
33012         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33013         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
33014 }
33015
33016 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
33017         LDKRevokeAndACK this_ptr_conv;
33018         this_ptr_conv.inner = untag_ptr(this_ptr);
33019         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33021         this_ptr_conv.is_owned = false;
33022         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33023         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
33024         return ret_arr;
33025 }
33026
33027 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) {
33028         LDKRevokeAndACK this_ptr_conv;
33029         this_ptr_conv.inner = untag_ptr(this_ptr);
33030         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33032         this_ptr_conv.is_owned = false;
33033         LDKPublicKey val_ref;
33034         CHECK((*env)->GetArrayLength(env, val) == 33);
33035         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33036         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
33037 }
33038
33039 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) {
33040         LDKThirtyTwoBytes channel_id_arg_ref;
33041         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33042         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33043         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
33044         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
33045         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
33046         LDKPublicKey next_per_commitment_point_arg_ref;
33047         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
33048         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
33049         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
33050         int64_t ret_ref = 0;
33051         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33052         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33053         return ret_ref;
33054 }
33055
33056 static inline uint64_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
33057         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
33058         int64_t ret_ref = 0;
33059         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33060         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33061         return ret_ref;
33062 }
33063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33064         LDKRevokeAndACK arg_conv;
33065         arg_conv.inner = untag_ptr(arg);
33066         arg_conv.is_owned = ptr_is_owned(arg);
33067         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33068         arg_conv.is_owned = false;
33069         int64_t ret_conv = RevokeAndACK_clone_ptr(&arg_conv);
33070         return ret_conv;
33071 }
33072
33073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33074         LDKRevokeAndACK orig_conv;
33075         orig_conv.inner = untag_ptr(orig);
33076         orig_conv.is_owned = ptr_is_owned(orig);
33077         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33078         orig_conv.is_owned = false;
33079         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
33080         int64_t ret_ref = 0;
33081         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33082         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33083         return ret_ref;
33084 }
33085
33086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33087         LDKUpdateFee this_obj_conv;
33088         this_obj_conv.inner = untag_ptr(this_obj);
33089         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33091         UpdateFee_free(this_obj_conv);
33092 }
33093
33094 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33095         LDKUpdateFee this_ptr_conv;
33096         this_ptr_conv.inner = untag_ptr(this_ptr);
33097         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33099         this_ptr_conv.is_owned = false;
33100         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33101         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
33102         return ret_arr;
33103 }
33104
33105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33106         LDKUpdateFee this_ptr_conv;
33107         this_ptr_conv.inner = untag_ptr(this_ptr);
33108         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33110         this_ptr_conv.is_owned = false;
33111         LDKThirtyTwoBytes val_ref;
33112         CHECK((*env)->GetArrayLength(env, val) == 32);
33113         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33114         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
33115 }
33116
33117 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
33118         LDKUpdateFee this_ptr_conv;
33119         this_ptr_conv.inner = untag_ptr(this_ptr);
33120         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33122         this_ptr_conv.is_owned = false;
33123         int32_t ret_conv = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
33124         return ret_conv;
33125 }
33126
33127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33128         LDKUpdateFee this_ptr_conv;
33129         this_ptr_conv.inner = untag_ptr(this_ptr);
33130         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33132         this_ptr_conv.is_owned = false;
33133         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
33134 }
33135
33136 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) {
33137         LDKThirtyTwoBytes channel_id_arg_ref;
33138         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33139         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33140         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
33141         int64_t ret_ref = 0;
33142         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33143         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33144         return ret_ref;
33145 }
33146
33147 static inline uint64_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
33148         LDKUpdateFee ret_var = UpdateFee_clone(arg);
33149         int64_t ret_ref = 0;
33150         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33151         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33152         return ret_ref;
33153 }
33154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33155         LDKUpdateFee arg_conv;
33156         arg_conv.inner = untag_ptr(arg);
33157         arg_conv.is_owned = ptr_is_owned(arg);
33158         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33159         arg_conv.is_owned = false;
33160         int64_t ret_conv = UpdateFee_clone_ptr(&arg_conv);
33161         return ret_conv;
33162 }
33163
33164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33165         LDKUpdateFee orig_conv;
33166         orig_conv.inner = untag_ptr(orig);
33167         orig_conv.is_owned = ptr_is_owned(orig);
33168         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33169         orig_conv.is_owned = false;
33170         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
33171         int64_t ret_ref = 0;
33172         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33173         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33174         return ret_ref;
33175 }
33176
33177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33178         LDKDataLossProtect this_obj_conv;
33179         this_obj_conv.inner = untag_ptr(this_obj);
33180         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33182         DataLossProtect_free(this_obj_conv);
33183 }
33184
33185 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
33186         LDKDataLossProtect this_ptr_conv;
33187         this_ptr_conv.inner = untag_ptr(this_ptr);
33188         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33190         this_ptr_conv.is_owned = false;
33191         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33192         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
33193         return ret_arr;
33194 }
33195
33196 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) {
33197         LDKDataLossProtect this_ptr_conv;
33198         this_ptr_conv.inner = untag_ptr(this_ptr);
33199         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33201         this_ptr_conv.is_owned = false;
33202         LDKThirtyTwoBytes val_ref;
33203         CHECK((*env)->GetArrayLength(env, val) == 32);
33204         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33205         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
33206 }
33207
33208 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
33209         LDKDataLossProtect this_ptr_conv;
33210         this_ptr_conv.inner = untag_ptr(this_ptr);
33211         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33213         this_ptr_conv.is_owned = false;
33214         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33215         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
33216         return ret_arr;
33217 }
33218
33219 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) {
33220         LDKDataLossProtect this_ptr_conv;
33221         this_ptr_conv.inner = untag_ptr(this_ptr);
33222         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33224         this_ptr_conv.is_owned = false;
33225         LDKPublicKey val_ref;
33226         CHECK((*env)->GetArrayLength(env, val) == 33);
33227         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33228         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
33229 }
33230
33231 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) {
33232         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
33233         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
33234         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
33235         LDKPublicKey my_current_per_commitment_point_arg_ref;
33236         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
33237         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
33238         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
33239         int64_t ret_ref = 0;
33240         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33241         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33242         return ret_ref;
33243 }
33244
33245 static inline uint64_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
33246         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
33247         int64_t ret_ref = 0;
33248         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33249         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33250         return ret_ref;
33251 }
33252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33253         LDKDataLossProtect arg_conv;
33254         arg_conv.inner = untag_ptr(arg);
33255         arg_conv.is_owned = ptr_is_owned(arg);
33256         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33257         arg_conv.is_owned = false;
33258         int64_t ret_conv = DataLossProtect_clone_ptr(&arg_conv);
33259         return ret_conv;
33260 }
33261
33262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33263         LDKDataLossProtect orig_conv;
33264         orig_conv.inner = untag_ptr(orig);
33265         orig_conv.is_owned = ptr_is_owned(orig);
33266         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33267         orig_conv.is_owned = false;
33268         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
33269         int64_t ret_ref = 0;
33270         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33271         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33272         return ret_ref;
33273 }
33274
33275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33276         LDKChannelReestablish this_obj_conv;
33277         this_obj_conv.inner = untag_ptr(this_obj);
33278         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33280         ChannelReestablish_free(this_obj_conv);
33281 }
33282
33283 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33284         LDKChannelReestablish this_ptr_conv;
33285         this_ptr_conv.inner = untag_ptr(this_ptr);
33286         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33288         this_ptr_conv.is_owned = false;
33289         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33290         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
33291         return ret_arr;
33292 }
33293
33294 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33295         LDKChannelReestablish this_ptr_conv;
33296         this_ptr_conv.inner = untag_ptr(this_ptr);
33297         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33299         this_ptr_conv.is_owned = false;
33300         LDKThirtyTwoBytes val_ref;
33301         CHECK((*env)->GetArrayLength(env, val) == 32);
33302         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33303         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
33304 }
33305
33306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
33307         LDKChannelReestablish this_ptr_conv;
33308         this_ptr_conv.inner = untag_ptr(this_ptr);
33309         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33311         this_ptr_conv.is_owned = false;
33312         int64_t ret_conv = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
33313         return ret_conv;
33314 }
33315
33316 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) {
33317         LDKChannelReestablish this_ptr_conv;
33318         this_ptr_conv.inner = untag_ptr(this_ptr);
33319         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33321         this_ptr_conv.is_owned = false;
33322         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
33323 }
33324
33325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
33326         LDKChannelReestablish this_ptr_conv;
33327         this_ptr_conv.inner = untag_ptr(this_ptr);
33328         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33330         this_ptr_conv.is_owned = false;
33331         int64_t ret_conv = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
33332         return ret_conv;
33333 }
33334
33335 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) {
33336         LDKChannelReestablish this_ptr_conv;
33337         this_ptr_conv.inner = untag_ptr(this_ptr);
33338         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33340         this_ptr_conv.is_owned = false;
33341         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
33342 }
33343
33344 static inline uint64_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
33345         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
33346         int64_t ret_ref = 0;
33347         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33348         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33349         return ret_ref;
33350 }
33351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33352         LDKChannelReestablish arg_conv;
33353         arg_conv.inner = untag_ptr(arg);
33354         arg_conv.is_owned = ptr_is_owned(arg);
33355         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33356         arg_conv.is_owned = false;
33357         int64_t ret_conv = ChannelReestablish_clone_ptr(&arg_conv);
33358         return ret_conv;
33359 }
33360
33361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33362         LDKChannelReestablish orig_conv;
33363         orig_conv.inner = untag_ptr(orig);
33364         orig_conv.is_owned = ptr_is_owned(orig);
33365         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33366         orig_conv.is_owned = false;
33367         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
33368         int64_t ret_ref = 0;
33369         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33370         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33371         return ret_ref;
33372 }
33373
33374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33375         LDKAnnouncementSignatures this_obj_conv;
33376         this_obj_conv.inner = untag_ptr(this_obj);
33377         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33379         AnnouncementSignatures_free(this_obj_conv);
33380 }
33381
33382 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33383         LDKAnnouncementSignatures this_ptr_conv;
33384         this_ptr_conv.inner = untag_ptr(this_ptr);
33385         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33387         this_ptr_conv.is_owned = false;
33388         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33389         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
33390         return ret_arr;
33391 }
33392
33393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33394         LDKAnnouncementSignatures this_ptr_conv;
33395         this_ptr_conv.inner = untag_ptr(this_ptr);
33396         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33398         this_ptr_conv.is_owned = false;
33399         LDKThirtyTwoBytes val_ref;
33400         CHECK((*env)->GetArrayLength(env, val) == 32);
33401         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33402         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
33403 }
33404
33405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33406         LDKAnnouncementSignatures this_ptr_conv;
33407         this_ptr_conv.inner = untag_ptr(this_ptr);
33408         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33410         this_ptr_conv.is_owned = false;
33411         int64_t ret_conv = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
33412         return ret_conv;
33413 }
33414
33415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33416         LDKAnnouncementSignatures this_ptr_conv;
33417         this_ptr_conv.inner = untag_ptr(this_ptr);
33418         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33420         this_ptr_conv.is_owned = false;
33421         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
33422 }
33423
33424 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33425         LDKAnnouncementSignatures this_ptr_conv;
33426         this_ptr_conv.inner = untag_ptr(this_ptr);
33427         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33429         this_ptr_conv.is_owned = false;
33430         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33431         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
33432         return ret_arr;
33433 }
33434
33435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33436         LDKAnnouncementSignatures this_ptr_conv;
33437         this_ptr_conv.inner = untag_ptr(this_ptr);
33438         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33440         this_ptr_conv.is_owned = false;
33441         LDKSignature val_ref;
33442         CHECK((*env)->GetArrayLength(env, val) == 64);
33443         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33444         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
33445 }
33446
33447 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33448         LDKAnnouncementSignatures this_ptr_conv;
33449         this_ptr_conv.inner = untag_ptr(this_ptr);
33450         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33452         this_ptr_conv.is_owned = false;
33453         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33454         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
33455         return ret_arr;
33456 }
33457
33458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33459         LDKAnnouncementSignatures this_ptr_conv;
33460         this_ptr_conv.inner = untag_ptr(this_ptr);
33461         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33463         this_ptr_conv.is_owned = false;
33464         LDKSignature val_ref;
33465         CHECK((*env)->GetArrayLength(env, val) == 64);
33466         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33467         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
33468 }
33469
33470 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) {
33471         LDKThirtyTwoBytes channel_id_arg_ref;
33472         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33473         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33474         LDKSignature node_signature_arg_ref;
33475         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
33476         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
33477         LDKSignature bitcoin_signature_arg_ref;
33478         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
33479         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
33480         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
33481         int64_t ret_ref = 0;
33482         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33483         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33484         return ret_ref;
33485 }
33486
33487 static inline uint64_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
33488         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
33489         int64_t ret_ref = 0;
33490         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33491         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33492         return ret_ref;
33493 }
33494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33495         LDKAnnouncementSignatures arg_conv;
33496         arg_conv.inner = untag_ptr(arg);
33497         arg_conv.is_owned = ptr_is_owned(arg);
33498         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33499         arg_conv.is_owned = false;
33500         int64_t ret_conv = AnnouncementSignatures_clone_ptr(&arg_conv);
33501         return ret_conv;
33502 }
33503
33504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33505         LDKAnnouncementSignatures orig_conv;
33506         orig_conv.inner = untag_ptr(orig);
33507         orig_conv.is_owned = ptr_is_owned(orig);
33508         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33509         orig_conv.is_owned = false;
33510         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
33511         int64_t ret_ref = 0;
33512         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33513         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33514         return ret_ref;
33515 }
33516
33517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
33518         if (!ptr_is_owned(this_ptr)) return;
33519         void* this_ptr_ptr = untag_ptr(this_ptr);
33520         CHECK_ACCESS(this_ptr_ptr);
33521         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
33522         FREE(untag_ptr(this_ptr));
33523         NetAddress_free(this_ptr_conv);
33524 }
33525
33526 static inline uint64_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
33527         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
33528         *ret_copy = NetAddress_clone(arg);
33529         int64_t ret_ref = tag_ptr(ret_copy, true);
33530         return ret_ref;
33531 }
33532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33533         LDKNetAddress* arg_conv = (LDKNetAddress*)untag_ptr(arg);
33534         int64_t ret_conv = NetAddress_clone_ptr(arg_conv);
33535         return ret_conv;
33536 }
33537
33538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33539         LDKNetAddress* orig_conv = (LDKNetAddress*)untag_ptr(orig);
33540         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
33541         *ret_copy = NetAddress_clone(orig_conv);
33542         int64_t ret_ref = tag_ptr(ret_copy, true);
33543         return ret_ref;
33544 }
33545
33546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
33547         LDKFourBytes addr_ref;
33548         CHECK((*env)->GetArrayLength(env, addr) == 4);
33549         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
33550         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
33551         *ret_copy = NetAddress_ipv4(addr_ref, port);
33552         int64_t ret_ref = tag_ptr(ret_copy, true);
33553         return ret_ref;
33554 }
33555
33556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
33557         LDKSixteenBytes addr_ref;
33558         CHECK((*env)->GetArrayLength(env, addr) == 16);
33559         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
33560         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
33561         *ret_copy = NetAddress_ipv6(addr_ref, port);
33562         int64_t ret_ref = tag_ptr(ret_copy, true);
33563         return ret_ref;
33564 }
33565
33566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray a) {
33567         LDKTwelveBytes a_ref;
33568         CHECK((*env)->GetArrayLength(env, a) == 12);
33569         (*env)->GetByteArrayRegion(env, a, 0, 12, a_ref.data);
33570         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
33571         *ret_copy = NetAddress_onion_v2(a_ref);
33572         int64_t ret_ref = tag_ptr(ret_copy, true);
33573         return ret_ref;
33574 }
33575
33576 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) {
33577         LDKThirtyTwoBytes ed25519_pubkey_ref;
33578         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
33579         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
33580         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
33581         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
33582         int64_t ret_ref = tag_ptr(ret_copy, true);
33583         return ret_ref;
33584 }
33585
33586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1hostname(JNIEnv *env, jclass clz, int64_t hostname, int16_t port) {
33587         LDKHostname hostname_conv;
33588         hostname_conv.inner = untag_ptr(hostname);
33589         hostname_conv.is_owned = ptr_is_owned(hostname);
33590         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_conv);
33591         hostname_conv = Hostname_clone(&hostname_conv);
33592         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
33593         *ret_copy = NetAddress_hostname(hostname_conv, port);
33594         int64_t ret_ref = tag_ptr(ret_copy, true);
33595         return ret_ref;
33596 }
33597
33598 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
33599         LDKNetAddress* obj_conv = (LDKNetAddress*)untag_ptr(obj);
33600         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
33601         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33602         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33603         CVec_u8Z_free(ret_var);
33604         return ret_arr;
33605 }
33606
33607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33608         LDKu8slice ser_ref;
33609         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33610         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33611         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
33612         *ret_conv = NetAddress_read(ser_ref);
33613         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33614         return tag_ptr(ret_conv, true);
33615 }
33616
33617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33618         LDKUnsignedNodeAnnouncement this_obj_conv;
33619         this_obj_conv.inner = untag_ptr(this_obj);
33620         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33622         UnsignedNodeAnnouncement_free(this_obj_conv);
33623 }
33624
33625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
33626         LDKUnsignedNodeAnnouncement this_ptr_conv;
33627         this_ptr_conv.inner = untag_ptr(this_ptr);
33628         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33630         this_ptr_conv.is_owned = false;
33631         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
33632         int64_t ret_ref = 0;
33633         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33634         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33635         return ret_ref;
33636 }
33637
33638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33639         LDKUnsignedNodeAnnouncement this_ptr_conv;
33640         this_ptr_conv.inner = untag_ptr(this_ptr);
33641         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33643         this_ptr_conv.is_owned = false;
33644         LDKNodeFeatures val_conv;
33645         val_conv.inner = untag_ptr(val);
33646         val_conv.is_owned = ptr_is_owned(val);
33647         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33648         val_conv = NodeFeatures_clone(&val_conv);
33649         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
33650 }
33651
33652 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
33653         LDKUnsignedNodeAnnouncement this_ptr_conv;
33654         this_ptr_conv.inner = untag_ptr(this_ptr);
33655         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33657         this_ptr_conv.is_owned = false;
33658         int32_t ret_conv = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
33659         return ret_conv;
33660 }
33661
33662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33663         LDKUnsignedNodeAnnouncement this_ptr_conv;
33664         this_ptr_conv.inner = untag_ptr(this_ptr);
33665         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33667         this_ptr_conv.is_owned = false;
33668         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
33669 }
33670
33671 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33672         LDKUnsignedNodeAnnouncement this_ptr_conv;
33673         this_ptr_conv.inner = untag_ptr(this_ptr);
33674         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33676         this_ptr_conv.is_owned = false;
33677         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33678         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
33679         return ret_arr;
33680 }
33681
33682 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33683         LDKUnsignedNodeAnnouncement this_ptr_conv;
33684         this_ptr_conv.inner = untag_ptr(this_ptr);
33685         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33687         this_ptr_conv.is_owned = false;
33688         LDKPublicKey val_ref;
33689         CHECK((*env)->GetArrayLength(env, val) == 33);
33690         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33691         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
33692 }
33693
33694 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
33695         LDKUnsignedNodeAnnouncement this_ptr_conv;
33696         this_ptr_conv.inner = untag_ptr(this_ptr);
33697         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33699         this_ptr_conv.is_owned = false;
33700         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
33701         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
33702         return ret_arr;
33703 }
33704
33705 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33706         LDKUnsignedNodeAnnouncement this_ptr_conv;
33707         this_ptr_conv.inner = untag_ptr(this_ptr);
33708         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33710         this_ptr_conv.is_owned = false;
33711         LDKThreeBytes val_ref;
33712         CHECK((*env)->GetArrayLength(env, val) == 3);
33713         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
33714         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
33715 }
33716
33717 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
33718         LDKUnsignedNodeAnnouncement this_ptr_conv;
33719         this_ptr_conv.inner = untag_ptr(this_ptr);
33720         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33722         this_ptr_conv.is_owned = false;
33723         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33724         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
33725         return ret_arr;
33726 }
33727
33728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33729         LDKUnsignedNodeAnnouncement this_ptr_conv;
33730         this_ptr_conv.inner = untag_ptr(this_ptr);
33731         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33733         this_ptr_conv.is_owned = false;
33734         LDKThirtyTwoBytes val_ref;
33735         CHECK((*env)->GetArrayLength(env, val) == 32);
33736         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33737         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
33738 }
33739
33740 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr) {
33741         LDKUnsignedNodeAnnouncement this_ptr_conv;
33742         this_ptr_conv.inner = untag_ptr(this_ptr);
33743         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33745         this_ptr_conv.is_owned = false;
33746         LDKCVec_NetAddressZ ret_var = UnsignedNodeAnnouncement_get_addresses(&this_ptr_conv);
33747         int64_tArray ret_arr = NULL;
33748         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
33749         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
33750         for (size_t m = 0; m < ret_var.datalen; m++) {
33751                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
33752                 *ret_conv_12_copy = ret_var.data[m];
33753                 int64_t ret_conv_12_ref = tag_ptr(ret_conv_12_copy, true);
33754                 ret_arr_ptr[m] = ret_conv_12_ref;
33755         }
33756         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
33757         FREE(ret_var.data);
33758         return ret_arr;
33759 }
33760
33761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
33762         LDKUnsignedNodeAnnouncement this_ptr_conv;
33763         this_ptr_conv.inner = untag_ptr(this_ptr);
33764         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33766         this_ptr_conv.is_owned = false;
33767         LDKCVec_NetAddressZ val_constr;
33768         val_constr.datalen = (*env)->GetArrayLength(env, val);
33769         if (val_constr.datalen > 0)
33770                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
33771         else
33772                 val_constr.data = NULL;
33773         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
33774         for (size_t m = 0; m < val_constr.datalen; m++) {
33775                 int64_t val_conv_12 = val_vals[m];
33776                 void* val_conv_12_ptr = untag_ptr(val_conv_12);
33777                 CHECK_ACCESS(val_conv_12_ptr);
33778                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
33779                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(val_conv_12));
33780                 val_constr.data[m] = val_conv_12_conv;
33781         }
33782         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
33783         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
33784 }
33785
33786 static inline uint64_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
33787         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
33788         int64_t ret_ref = 0;
33789         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33790         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33791         return ret_ref;
33792 }
33793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33794         LDKUnsignedNodeAnnouncement arg_conv;
33795         arg_conv.inner = untag_ptr(arg);
33796         arg_conv.is_owned = ptr_is_owned(arg);
33797         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33798         arg_conv.is_owned = false;
33799         int64_t ret_conv = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
33800         return ret_conv;
33801 }
33802
33803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33804         LDKUnsignedNodeAnnouncement orig_conv;
33805         orig_conv.inner = untag_ptr(orig);
33806         orig_conv.is_owned = ptr_is_owned(orig);
33807         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33808         orig_conv.is_owned = false;
33809         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
33810         int64_t ret_ref = 0;
33811         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33812         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33813         return ret_ref;
33814 }
33815
33816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33817         LDKNodeAnnouncement this_obj_conv;
33818         this_obj_conv.inner = untag_ptr(this_obj);
33819         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33821         NodeAnnouncement_free(this_obj_conv);
33822 }
33823
33824 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33825         LDKNodeAnnouncement this_ptr_conv;
33826         this_ptr_conv.inner = untag_ptr(this_ptr);
33827         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33829         this_ptr_conv.is_owned = false;
33830         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33831         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
33832         return ret_arr;
33833 }
33834
33835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33836         LDKNodeAnnouncement this_ptr_conv;
33837         this_ptr_conv.inner = untag_ptr(this_ptr);
33838         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33840         this_ptr_conv.is_owned = false;
33841         LDKSignature val_ref;
33842         CHECK((*env)->GetArrayLength(env, val) == 64);
33843         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33844         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
33845 }
33846
33847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
33848         LDKNodeAnnouncement this_ptr_conv;
33849         this_ptr_conv.inner = untag_ptr(this_ptr);
33850         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33852         this_ptr_conv.is_owned = false;
33853         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
33854         int64_t ret_ref = 0;
33855         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33856         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33857         return ret_ref;
33858 }
33859
33860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33861         LDKNodeAnnouncement this_ptr_conv;
33862         this_ptr_conv.inner = untag_ptr(this_ptr);
33863         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33865         this_ptr_conv.is_owned = false;
33866         LDKUnsignedNodeAnnouncement val_conv;
33867         val_conv.inner = untag_ptr(val);
33868         val_conv.is_owned = ptr_is_owned(val);
33869         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33870         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
33871         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
33872 }
33873
33874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
33875         LDKSignature signature_arg_ref;
33876         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
33877         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
33878         LDKUnsignedNodeAnnouncement contents_arg_conv;
33879         contents_arg_conv.inner = untag_ptr(contents_arg);
33880         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
33881         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
33882         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
33883         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
33884         int64_t ret_ref = 0;
33885         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33886         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33887         return ret_ref;
33888 }
33889
33890 static inline uint64_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
33891         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
33892         int64_t ret_ref = 0;
33893         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33894         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33895         return ret_ref;
33896 }
33897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33898         LDKNodeAnnouncement arg_conv;
33899         arg_conv.inner = untag_ptr(arg);
33900         arg_conv.is_owned = ptr_is_owned(arg);
33901         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33902         arg_conv.is_owned = false;
33903         int64_t ret_conv = NodeAnnouncement_clone_ptr(&arg_conv);
33904         return ret_conv;
33905 }
33906
33907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33908         LDKNodeAnnouncement orig_conv;
33909         orig_conv.inner = untag_ptr(orig);
33910         orig_conv.is_owned = ptr_is_owned(orig);
33911         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33912         orig_conv.is_owned = false;
33913         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
33914         int64_t ret_ref = 0;
33915         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33916         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33917         return ret_ref;
33918 }
33919
33920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33921         LDKUnsignedChannelAnnouncement this_obj_conv;
33922         this_obj_conv.inner = untag_ptr(this_obj);
33923         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33925         UnsignedChannelAnnouncement_free(this_obj_conv);
33926 }
33927
33928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
33929         LDKUnsignedChannelAnnouncement this_ptr_conv;
33930         this_ptr_conv.inner = untag_ptr(this_ptr);
33931         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33933         this_ptr_conv.is_owned = false;
33934         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
33935         int64_t ret_ref = 0;
33936         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33937         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33938         return ret_ref;
33939 }
33940
33941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33942         LDKUnsignedChannelAnnouncement this_ptr_conv;
33943         this_ptr_conv.inner = untag_ptr(this_ptr);
33944         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33946         this_ptr_conv.is_owned = false;
33947         LDKChannelFeatures val_conv;
33948         val_conv.inner = untag_ptr(val);
33949         val_conv.is_owned = ptr_is_owned(val);
33950         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33951         val_conv = ChannelFeatures_clone(&val_conv);
33952         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
33953 }
33954
33955 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
33956         LDKUnsignedChannelAnnouncement 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33962         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
33963         return ret_arr;
33964 }
33965
33966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33967         LDKUnsignedChannelAnnouncement this_ptr_conv;
33968         this_ptr_conv.inner = untag_ptr(this_ptr);
33969         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33971         this_ptr_conv.is_owned = false;
33972         LDKThirtyTwoBytes val_ref;
33973         CHECK((*env)->GetArrayLength(env, val) == 32);
33974         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33975         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
33976 }
33977
33978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33979         LDKUnsignedChannelAnnouncement this_ptr_conv;
33980         this_ptr_conv.inner = untag_ptr(this_ptr);
33981         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33983         this_ptr_conv.is_owned = false;
33984         int64_t ret_conv = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
33985         return ret_conv;
33986 }
33987
33988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33989         LDKUnsignedChannelAnnouncement this_ptr_conv;
33990         this_ptr_conv.inner = untag_ptr(this_ptr);
33991         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33993         this_ptr_conv.is_owned = false;
33994         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
33995 }
33996
33997 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
33998         LDKUnsignedChannelAnnouncement this_ptr_conv;
33999         this_ptr_conv.inner = untag_ptr(this_ptr);
34000         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34002         this_ptr_conv.is_owned = false;
34003         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34004         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
34005         return ret_arr;
34006 }
34007
34008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34009         LDKUnsignedChannelAnnouncement this_ptr_conv;
34010         this_ptr_conv.inner = untag_ptr(this_ptr);
34011         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34013         this_ptr_conv.is_owned = false;
34014         LDKPublicKey val_ref;
34015         CHECK((*env)->GetArrayLength(env, val) == 33);
34016         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34017         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
34018 }
34019
34020 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
34021         LDKUnsignedChannelAnnouncement this_ptr_conv;
34022         this_ptr_conv.inner = untag_ptr(this_ptr);
34023         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34025         this_ptr_conv.is_owned = false;
34026         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34027         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
34028         return ret_arr;
34029 }
34030
34031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34032         LDKUnsignedChannelAnnouncement this_ptr_conv;
34033         this_ptr_conv.inner = untag_ptr(this_ptr);
34034         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34036         this_ptr_conv.is_owned = false;
34037         LDKPublicKey val_ref;
34038         CHECK((*env)->GetArrayLength(env, val) == 33);
34039         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34040         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
34041 }
34042
34043 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
34044         LDKUnsignedChannelAnnouncement 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34050         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
34051         return ret_arr;
34052 }
34053
34054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34055         LDKUnsignedChannelAnnouncement this_ptr_conv;
34056         this_ptr_conv.inner = untag_ptr(this_ptr);
34057         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34059         this_ptr_conv.is_owned = false;
34060         LDKPublicKey val_ref;
34061         CHECK((*env)->GetArrayLength(env, val) == 33);
34062         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34063         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
34064 }
34065
34066 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
34067         LDKUnsignedChannelAnnouncement this_ptr_conv;
34068         this_ptr_conv.inner = untag_ptr(this_ptr);
34069         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34071         this_ptr_conv.is_owned = false;
34072         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34073         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
34074         return ret_arr;
34075 }
34076
34077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34078         LDKUnsignedChannelAnnouncement this_ptr_conv;
34079         this_ptr_conv.inner = untag_ptr(this_ptr);
34080         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34082         this_ptr_conv.is_owned = false;
34083         LDKPublicKey val_ref;
34084         CHECK((*env)->GetArrayLength(env, val) == 33);
34085         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34086         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
34087 }
34088
34089 static inline uint64_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
34090         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
34091         int64_t ret_ref = 0;
34092         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34093         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34094         return ret_ref;
34095 }
34096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34097         LDKUnsignedChannelAnnouncement arg_conv;
34098         arg_conv.inner = untag_ptr(arg);
34099         arg_conv.is_owned = ptr_is_owned(arg);
34100         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34101         arg_conv.is_owned = false;
34102         int64_t ret_conv = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
34103         return ret_conv;
34104 }
34105
34106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34107         LDKUnsignedChannelAnnouncement orig_conv;
34108         orig_conv.inner = untag_ptr(orig);
34109         orig_conv.is_owned = ptr_is_owned(orig);
34110         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34111         orig_conv.is_owned = false;
34112         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
34113         int64_t ret_ref = 0;
34114         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34115         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34116         return ret_ref;
34117 }
34118
34119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34120         LDKChannelAnnouncement this_obj_conv;
34121         this_obj_conv.inner = untag_ptr(this_obj);
34122         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34124         ChannelAnnouncement_free(this_obj_conv);
34125 }
34126
34127 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
34128         LDKChannelAnnouncement this_ptr_conv;
34129         this_ptr_conv.inner = untag_ptr(this_ptr);
34130         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34132         this_ptr_conv.is_owned = false;
34133         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34134         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
34135         return ret_arr;
34136 }
34137
34138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34139         LDKChannelAnnouncement this_ptr_conv;
34140         this_ptr_conv.inner = untag_ptr(this_ptr);
34141         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34143         this_ptr_conv.is_owned = false;
34144         LDKSignature val_ref;
34145         CHECK((*env)->GetArrayLength(env, val) == 64);
34146         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34147         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
34148 }
34149
34150 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
34151         LDKChannelAnnouncement 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34157         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
34158         return ret_arr;
34159 }
34160
34161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34162         LDKChannelAnnouncement this_ptr_conv;
34163         this_ptr_conv.inner = untag_ptr(this_ptr);
34164         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34166         this_ptr_conv.is_owned = false;
34167         LDKSignature val_ref;
34168         CHECK((*env)->GetArrayLength(env, val) == 64);
34169         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34170         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
34171 }
34172
34173 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
34174         LDKChannelAnnouncement this_ptr_conv;
34175         this_ptr_conv.inner = untag_ptr(this_ptr);
34176         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34178         this_ptr_conv.is_owned = false;
34179         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34180         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
34181         return ret_arr;
34182 }
34183
34184 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34185         LDKChannelAnnouncement this_ptr_conv;
34186         this_ptr_conv.inner = untag_ptr(this_ptr);
34187         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34189         this_ptr_conv.is_owned = false;
34190         LDKSignature val_ref;
34191         CHECK((*env)->GetArrayLength(env, val) == 64);
34192         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34193         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
34194 }
34195
34196 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
34197         LDKChannelAnnouncement this_ptr_conv;
34198         this_ptr_conv.inner = untag_ptr(this_ptr);
34199         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34201         this_ptr_conv.is_owned = false;
34202         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34203         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
34204         return ret_arr;
34205 }
34206
34207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34208         LDKChannelAnnouncement this_ptr_conv;
34209         this_ptr_conv.inner = untag_ptr(this_ptr);
34210         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34212         this_ptr_conv.is_owned = false;
34213         LDKSignature val_ref;
34214         CHECK((*env)->GetArrayLength(env, val) == 64);
34215         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34216         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
34217 }
34218
34219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
34220         LDKChannelAnnouncement this_ptr_conv;
34221         this_ptr_conv.inner = untag_ptr(this_ptr);
34222         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34224         this_ptr_conv.is_owned = false;
34225         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
34226         int64_t ret_ref = 0;
34227         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34228         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34229         return ret_ref;
34230 }
34231
34232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34233         LDKChannelAnnouncement this_ptr_conv;
34234         this_ptr_conv.inner = untag_ptr(this_ptr);
34235         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34237         this_ptr_conv.is_owned = false;
34238         LDKUnsignedChannelAnnouncement val_conv;
34239         val_conv.inner = untag_ptr(val);
34240         val_conv.is_owned = ptr_is_owned(val);
34241         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34242         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
34243         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
34244 }
34245
34246 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) {
34247         LDKSignature node_signature_1_arg_ref;
34248         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
34249         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
34250         LDKSignature node_signature_2_arg_ref;
34251         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
34252         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
34253         LDKSignature bitcoin_signature_1_arg_ref;
34254         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
34255         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
34256         LDKSignature bitcoin_signature_2_arg_ref;
34257         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
34258         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
34259         LDKUnsignedChannelAnnouncement contents_arg_conv;
34260         contents_arg_conv.inner = untag_ptr(contents_arg);
34261         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
34262         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
34263         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
34264         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);
34265         int64_t ret_ref = 0;
34266         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34267         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34268         return ret_ref;
34269 }
34270
34271 static inline uint64_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
34272         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
34273         int64_t ret_ref = 0;
34274         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34275         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34276         return ret_ref;
34277 }
34278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34279         LDKChannelAnnouncement arg_conv;
34280         arg_conv.inner = untag_ptr(arg);
34281         arg_conv.is_owned = ptr_is_owned(arg);
34282         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34283         arg_conv.is_owned = false;
34284         int64_t ret_conv = ChannelAnnouncement_clone_ptr(&arg_conv);
34285         return ret_conv;
34286 }
34287
34288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34289         LDKChannelAnnouncement orig_conv;
34290         orig_conv.inner = untag_ptr(orig);
34291         orig_conv.is_owned = ptr_is_owned(orig);
34292         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34293         orig_conv.is_owned = false;
34294         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
34295         int64_t ret_ref = 0;
34296         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34297         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34298         return ret_ref;
34299 }
34300
34301 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34302         LDKUnsignedChannelUpdate this_obj_conv;
34303         this_obj_conv.inner = untag_ptr(this_obj);
34304         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34306         UnsignedChannelUpdate_free(this_obj_conv);
34307 }
34308
34309 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
34310         LDKUnsignedChannelUpdate this_ptr_conv;
34311         this_ptr_conv.inner = untag_ptr(this_ptr);
34312         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34314         this_ptr_conv.is_owned = false;
34315         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34316         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
34317         return ret_arr;
34318 }
34319
34320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34321         LDKUnsignedChannelUpdate this_ptr_conv;
34322         this_ptr_conv.inner = untag_ptr(this_ptr);
34323         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34325         this_ptr_conv.is_owned = false;
34326         LDKThirtyTwoBytes val_ref;
34327         CHECK((*env)->GetArrayLength(env, val) == 32);
34328         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34329         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
34330 }
34331
34332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34333         LDKUnsignedChannelUpdate this_ptr_conv;
34334         this_ptr_conv.inner = untag_ptr(this_ptr);
34335         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34337         this_ptr_conv.is_owned = false;
34338         int64_t ret_conv = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
34339         return ret_conv;
34340 }
34341
34342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34343         LDKUnsignedChannelUpdate this_ptr_conv;
34344         this_ptr_conv.inner = untag_ptr(this_ptr);
34345         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34347         this_ptr_conv.is_owned = false;
34348         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
34349 }
34350
34351 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
34352         LDKUnsignedChannelUpdate this_ptr_conv;
34353         this_ptr_conv.inner = untag_ptr(this_ptr);
34354         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34356         this_ptr_conv.is_owned = false;
34357         int32_t ret_conv = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
34358         return ret_conv;
34359 }
34360
34361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34362         LDKUnsignedChannelUpdate this_ptr_conv;
34363         this_ptr_conv.inner = untag_ptr(this_ptr);
34364         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34366         this_ptr_conv.is_owned = false;
34367         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
34368 }
34369
34370 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
34371         LDKUnsignedChannelUpdate this_ptr_conv;
34372         this_ptr_conv.inner = untag_ptr(this_ptr);
34373         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34375         this_ptr_conv.is_owned = false;
34376         int8_t ret_conv = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
34377         return ret_conv;
34378 }
34379
34380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
34381         LDKUnsignedChannelUpdate this_ptr_conv;
34382         this_ptr_conv.inner = untag_ptr(this_ptr);
34383         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34385         this_ptr_conv.is_owned = false;
34386         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
34387 }
34388
34389 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
34390         LDKUnsignedChannelUpdate this_ptr_conv;
34391         this_ptr_conv.inner = untag_ptr(this_ptr);
34392         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34394         this_ptr_conv.is_owned = false;
34395         int16_t ret_conv = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
34396         return ret_conv;
34397 }
34398
34399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
34400         LDKUnsignedChannelUpdate this_ptr_conv;
34401         this_ptr_conv.inner = untag_ptr(this_ptr);
34402         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34404         this_ptr_conv.is_owned = false;
34405         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
34406 }
34407
34408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
34409         LDKUnsignedChannelUpdate this_ptr_conv;
34410         this_ptr_conv.inner = untag_ptr(this_ptr);
34411         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34413         this_ptr_conv.is_owned = false;
34414         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
34415         return ret_conv;
34416 }
34417
34418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34419         LDKUnsignedChannelUpdate 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         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
34425 }
34426
34427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
34428         LDKUnsignedChannelUpdate this_ptr_conv;
34429         this_ptr_conv.inner = untag_ptr(this_ptr);
34430         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34432         this_ptr_conv.is_owned = false;
34433         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_maximum_msat(&this_ptr_conv);
34434         return ret_conv;
34435 }
34436
34437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34438         LDKUnsignedChannelUpdate this_ptr_conv;
34439         this_ptr_conv.inner = untag_ptr(this_ptr);
34440         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34442         this_ptr_conv.is_owned = false;
34443         UnsignedChannelUpdate_set_htlc_maximum_msat(&this_ptr_conv, val);
34444 }
34445
34446 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
34447         LDKUnsignedChannelUpdate this_ptr_conv;
34448         this_ptr_conv.inner = untag_ptr(this_ptr);
34449         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34451         this_ptr_conv.is_owned = false;
34452         int32_t ret_conv = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
34453         return ret_conv;
34454 }
34455
34456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34457         LDKUnsignedChannelUpdate this_ptr_conv;
34458         this_ptr_conv.inner = untag_ptr(this_ptr);
34459         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34461         this_ptr_conv.is_owned = false;
34462         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
34463 }
34464
34465 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
34466         LDKUnsignedChannelUpdate this_ptr_conv;
34467         this_ptr_conv.inner = untag_ptr(this_ptr);
34468         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34470         this_ptr_conv.is_owned = false;
34471         int32_t ret_conv = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
34472         return ret_conv;
34473 }
34474
34475 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34476         LDKUnsignedChannelUpdate this_ptr_conv;
34477         this_ptr_conv.inner = untag_ptr(this_ptr);
34478         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34480         this_ptr_conv.is_owned = false;
34481         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
34482 }
34483
34484 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1excess_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
34485         LDKUnsignedChannelUpdate this_ptr_conv;
34486         this_ptr_conv.inner = untag_ptr(this_ptr);
34487         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34489         this_ptr_conv.is_owned = false;
34490         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_get_excess_data(&this_ptr_conv);
34491         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34492         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34493         CVec_u8Z_free(ret_var);
34494         return ret_arr;
34495 }
34496
34497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1excess_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34498         LDKUnsignedChannelUpdate this_ptr_conv;
34499         this_ptr_conv.inner = untag_ptr(this_ptr);
34500         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34502         this_ptr_conv.is_owned = false;
34503         LDKCVec_u8Z val_ref;
34504         val_ref.datalen = (*env)->GetArrayLength(env, val);
34505         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
34506         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
34507         UnsignedChannelUpdate_set_excess_data(&this_ptr_conv, val_ref);
34508 }
34509
34510 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) {
34511         LDKThirtyTwoBytes chain_hash_arg_ref;
34512         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
34513         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
34514         LDKCVec_u8Z excess_data_arg_ref;
34515         excess_data_arg_ref.datalen = (*env)->GetArrayLength(env, excess_data_arg);
34516         excess_data_arg_ref.data = MALLOC(excess_data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
34517         (*env)->GetByteArrayRegion(env, excess_data_arg, 0, excess_data_arg_ref.datalen, excess_data_arg_ref.data);
34518         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);
34519         int64_t ret_ref = 0;
34520         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34521         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34522         return ret_ref;
34523 }
34524
34525 static inline uint64_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
34526         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
34527         int64_t ret_ref = 0;
34528         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34529         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34530         return ret_ref;
34531 }
34532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34533         LDKUnsignedChannelUpdate arg_conv;
34534         arg_conv.inner = untag_ptr(arg);
34535         arg_conv.is_owned = ptr_is_owned(arg);
34536         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34537         arg_conv.is_owned = false;
34538         int64_t ret_conv = UnsignedChannelUpdate_clone_ptr(&arg_conv);
34539         return ret_conv;
34540 }
34541
34542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34543         LDKUnsignedChannelUpdate orig_conv;
34544         orig_conv.inner = untag_ptr(orig);
34545         orig_conv.is_owned = ptr_is_owned(orig);
34546         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34547         orig_conv.is_owned = false;
34548         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
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
34555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34556         LDKChannelUpdate this_obj_conv;
34557         this_obj_conv.inner = untag_ptr(this_obj);
34558         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34560         ChannelUpdate_free(this_obj_conv);
34561 }
34562
34563 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34564         LDKChannelUpdate this_ptr_conv;
34565         this_ptr_conv.inner = untag_ptr(this_ptr);
34566         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34568         this_ptr_conv.is_owned = false;
34569         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34570         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
34571         return ret_arr;
34572 }
34573
34574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34575         LDKChannelUpdate this_ptr_conv;
34576         this_ptr_conv.inner = untag_ptr(this_ptr);
34577         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34579         this_ptr_conv.is_owned = false;
34580         LDKSignature val_ref;
34581         CHECK((*env)->GetArrayLength(env, val) == 64);
34582         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34583         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
34584 }
34585
34586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
34587         LDKChannelUpdate this_ptr_conv;
34588         this_ptr_conv.inner = untag_ptr(this_ptr);
34589         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34591         this_ptr_conv.is_owned = false;
34592         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
34593         int64_t ret_ref = 0;
34594         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34595         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34596         return ret_ref;
34597 }
34598
34599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34600         LDKChannelUpdate this_ptr_conv;
34601         this_ptr_conv.inner = untag_ptr(this_ptr);
34602         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34604         this_ptr_conv.is_owned = false;
34605         LDKUnsignedChannelUpdate val_conv;
34606         val_conv.inner = untag_ptr(val);
34607         val_conv.is_owned = ptr_is_owned(val);
34608         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34609         val_conv = UnsignedChannelUpdate_clone(&val_conv);
34610         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
34611 }
34612
34613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
34614         LDKSignature signature_arg_ref;
34615         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
34616         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
34617         LDKUnsignedChannelUpdate contents_arg_conv;
34618         contents_arg_conv.inner = untag_ptr(contents_arg);
34619         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
34620         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
34621         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
34622         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
34623         int64_t ret_ref = 0;
34624         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34625         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34626         return ret_ref;
34627 }
34628
34629 static inline uint64_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
34630         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
34631         int64_t ret_ref = 0;
34632         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34633         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34634         return ret_ref;
34635 }
34636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34637         LDKChannelUpdate arg_conv;
34638         arg_conv.inner = untag_ptr(arg);
34639         arg_conv.is_owned = ptr_is_owned(arg);
34640         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34641         arg_conv.is_owned = false;
34642         int64_t ret_conv = ChannelUpdate_clone_ptr(&arg_conv);
34643         return ret_conv;
34644 }
34645
34646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34647         LDKChannelUpdate orig_conv;
34648         orig_conv.inner = untag_ptr(orig);
34649         orig_conv.is_owned = ptr_is_owned(orig);
34650         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34651         orig_conv.is_owned = false;
34652         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
34653         int64_t ret_ref = 0;
34654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34655         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34656         return ret_ref;
34657 }
34658
34659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34660         LDKQueryChannelRange this_obj_conv;
34661         this_obj_conv.inner = untag_ptr(this_obj);
34662         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34664         QueryChannelRange_free(this_obj_conv);
34665 }
34666
34667 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
34668         LDKQueryChannelRange this_ptr_conv;
34669         this_ptr_conv.inner = untag_ptr(this_ptr);
34670         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34672         this_ptr_conv.is_owned = false;
34673         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34674         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
34675         return ret_arr;
34676 }
34677
34678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34679         LDKQueryChannelRange this_ptr_conv;
34680         this_ptr_conv.inner = untag_ptr(this_ptr);
34681         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34683         this_ptr_conv.is_owned = false;
34684         LDKThirtyTwoBytes val_ref;
34685         CHECK((*env)->GetArrayLength(env, val) == 32);
34686         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34687         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
34688 }
34689
34690 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
34691         LDKQueryChannelRange this_ptr_conv;
34692         this_ptr_conv.inner = untag_ptr(this_ptr);
34693         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34695         this_ptr_conv.is_owned = false;
34696         int32_t ret_conv = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
34697         return ret_conv;
34698 }
34699
34700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34701         LDKQueryChannelRange this_ptr_conv;
34702         this_ptr_conv.inner = untag_ptr(this_ptr);
34703         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34705         this_ptr_conv.is_owned = false;
34706         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
34707 }
34708
34709 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
34710         LDKQueryChannelRange this_ptr_conv;
34711         this_ptr_conv.inner = untag_ptr(this_ptr);
34712         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34714         this_ptr_conv.is_owned = false;
34715         int32_t ret_conv = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
34716         return ret_conv;
34717 }
34718
34719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34720         LDKQueryChannelRange this_ptr_conv;
34721         this_ptr_conv.inner = untag_ptr(this_ptr);
34722         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34724         this_ptr_conv.is_owned = false;
34725         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
34726 }
34727
34728 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) {
34729         LDKThirtyTwoBytes chain_hash_arg_ref;
34730         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
34731         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
34732         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
34733         int64_t ret_ref = 0;
34734         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34735         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34736         return ret_ref;
34737 }
34738
34739 static inline uint64_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
34740         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
34741         int64_t ret_ref = 0;
34742         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34743         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34744         return ret_ref;
34745 }
34746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34747         LDKQueryChannelRange arg_conv;
34748         arg_conv.inner = untag_ptr(arg);
34749         arg_conv.is_owned = ptr_is_owned(arg);
34750         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34751         arg_conv.is_owned = false;
34752         int64_t ret_conv = QueryChannelRange_clone_ptr(&arg_conv);
34753         return ret_conv;
34754 }
34755
34756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34757         LDKQueryChannelRange orig_conv;
34758         orig_conv.inner = untag_ptr(orig);
34759         orig_conv.is_owned = ptr_is_owned(orig);
34760         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34761         orig_conv.is_owned = false;
34762         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
34763         int64_t ret_ref = 0;
34764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34765         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34766         return ret_ref;
34767 }
34768
34769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34770         LDKReplyChannelRange this_obj_conv;
34771         this_obj_conv.inner = untag_ptr(this_obj);
34772         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34774         ReplyChannelRange_free(this_obj_conv);
34775 }
34776
34777 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
34778         LDKReplyChannelRange this_ptr_conv;
34779         this_ptr_conv.inner = untag_ptr(this_ptr);
34780         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34782         this_ptr_conv.is_owned = false;
34783         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34784         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
34785         return ret_arr;
34786 }
34787
34788 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34789         LDKReplyChannelRange this_ptr_conv;
34790         this_ptr_conv.inner = untag_ptr(this_ptr);
34791         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34793         this_ptr_conv.is_owned = false;
34794         LDKThirtyTwoBytes val_ref;
34795         CHECK((*env)->GetArrayLength(env, val) == 32);
34796         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34797         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
34798 }
34799
34800 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
34801         LDKReplyChannelRange this_ptr_conv;
34802         this_ptr_conv.inner = untag_ptr(this_ptr);
34803         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34805         this_ptr_conv.is_owned = false;
34806         int32_t ret_conv = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
34807         return ret_conv;
34808 }
34809
34810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34811         LDKReplyChannelRange 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         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
34817 }
34818
34819 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
34820         LDKReplyChannelRange this_ptr_conv;
34821         this_ptr_conv.inner = untag_ptr(this_ptr);
34822         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34824         this_ptr_conv.is_owned = false;
34825         int32_t ret_conv = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
34826         return ret_conv;
34827 }
34828
34829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34830         LDKReplyChannelRange this_ptr_conv;
34831         this_ptr_conv.inner = untag_ptr(this_ptr);
34832         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34834         this_ptr_conv.is_owned = false;
34835         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
34836 }
34837
34838 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
34839         LDKReplyChannelRange this_ptr_conv;
34840         this_ptr_conv.inner = untag_ptr(this_ptr);
34841         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34843         this_ptr_conv.is_owned = false;
34844         jboolean ret_conv = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
34845         return ret_conv;
34846 }
34847
34848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
34849         LDKReplyChannelRange this_ptr_conv;
34850         this_ptr_conv.inner = untag_ptr(this_ptr);
34851         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34853         this_ptr_conv.is_owned = false;
34854         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
34855 }
34856
34857 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr) {
34858         LDKReplyChannelRange this_ptr_conv;
34859         this_ptr_conv.inner = untag_ptr(this_ptr);
34860         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34862         this_ptr_conv.is_owned = false;
34863         LDKCVec_u64Z ret_var = ReplyChannelRange_get_short_channel_ids(&this_ptr_conv);
34864         int64_tArray ret_arr = NULL;
34865         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
34866         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
34867         for (size_t g = 0; g < ret_var.datalen; g++) {
34868                 int64_t ret_conv_6_conv = ret_var.data[g];
34869                 ret_arr_ptr[g] = ret_conv_6_conv;
34870         }
34871         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
34872         FREE(ret_var.data);
34873         return ret_arr;
34874 }
34875
34876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
34877         LDKReplyChannelRange this_ptr_conv;
34878         this_ptr_conv.inner = untag_ptr(this_ptr);
34879         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34881         this_ptr_conv.is_owned = false;
34882         LDKCVec_u64Z val_constr;
34883         val_constr.datalen = (*env)->GetArrayLength(env, val);
34884         if (val_constr.datalen > 0)
34885                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
34886         else
34887                 val_constr.data = NULL;
34888         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
34889         for (size_t g = 0; g < val_constr.datalen; g++) {
34890                 int64_t val_conv_6 = val_vals[g];
34891                 val_constr.data[g] = val_conv_6;
34892         }
34893         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
34894         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
34895 }
34896
34897 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) {
34898         LDKThirtyTwoBytes chain_hash_arg_ref;
34899         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
34900         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
34901         LDKCVec_u64Z short_channel_ids_arg_constr;
34902         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
34903         if (short_channel_ids_arg_constr.datalen > 0)
34904                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
34905         else
34906                 short_channel_ids_arg_constr.data = NULL;
34907         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
34908         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
34909                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
34910                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
34911         }
34912         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
34913         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
34914         int64_t ret_ref = 0;
34915         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34916         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34917         return ret_ref;
34918 }
34919
34920 static inline uint64_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
34921         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
34922         int64_t ret_ref = 0;
34923         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34924         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34925         return ret_ref;
34926 }
34927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34928         LDKReplyChannelRange arg_conv;
34929         arg_conv.inner = untag_ptr(arg);
34930         arg_conv.is_owned = ptr_is_owned(arg);
34931         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34932         arg_conv.is_owned = false;
34933         int64_t ret_conv = ReplyChannelRange_clone_ptr(&arg_conv);
34934         return ret_conv;
34935 }
34936
34937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34938         LDKReplyChannelRange orig_conv;
34939         orig_conv.inner = untag_ptr(orig);
34940         orig_conv.is_owned = ptr_is_owned(orig);
34941         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34942         orig_conv.is_owned = false;
34943         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
34944         int64_t ret_ref = 0;
34945         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34946         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34947         return ret_ref;
34948 }
34949
34950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34951         LDKQueryShortChannelIds this_obj_conv;
34952         this_obj_conv.inner = untag_ptr(this_obj);
34953         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34955         QueryShortChannelIds_free(this_obj_conv);
34956 }
34957
34958 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
34959         LDKQueryShortChannelIds this_ptr_conv;
34960         this_ptr_conv.inner = untag_ptr(this_ptr);
34961         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34963         this_ptr_conv.is_owned = false;
34964         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34965         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
34966         return ret_arr;
34967 }
34968
34969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34970         LDKQueryShortChannelIds this_ptr_conv;
34971         this_ptr_conv.inner = untag_ptr(this_ptr);
34972         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34974         this_ptr_conv.is_owned = false;
34975         LDKThirtyTwoBytes val_ref;
34976         CHECK((*env)->GetArrayLength(env, val) == 32);
34977         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34978         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
34979 }
34980
34981 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr) {
34982         LDKQueryShortChannelIds this_ptr_conv;
34983         this_ptr_conv.inner = untag_ptr(this_ptr);
34984         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34986         this_ptr_conv.is_owned = false;
34987         LDKCVec_u64Z ret_var = QueryShortChannelIds_get_short_channel_ids(&this_ptr_conv);
34988         int64_tArray ret_arr = NULL;
34989         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
34990         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
34991         for (size_t g = 0; g < ret_var.datalen; g++) {
34992                 int64_t ret_conv_6_conv = ret_var.data[g];
34993                 ret_arr_ptr[g] = ret_conv_6_conv;
34994         }
34995         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
34996         FREE(ret_var.data);
34997         return ret_arr;
34998 }
34999
35000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
35001         LDKQueryShortChannelIds this_ptr_conv;
35002         this_ptr_conv.inner = untag_ptr(this_ptr);
35003         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35005         this_ptr_conv.is_owned = false;
35006         LDKCVec_u64Z val_constr;
35007         val_constr.datalen = (*env)->GetArrayLength(env, val);
35008         if (val_constr.datalen > 0)
35009                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
35010         else
35011                 val_constr.data = NULL;
35012         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35013         for (size_t g = 0; g < val_constr.datalen; g++) {
35014                 int64_t val_conv_6 = val_vals[g];
35015                 val_constr.data[g] = val_conv_6;
35016         }
35017         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35018         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
35019 }
35020
35021 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) {
35022         LDKThirtyTwoBytes chain_hash_arg_ref;
35023         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
35024         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
35025         LDKCVec_u64Z short_channel_ids_arg_constr;
35026         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
35027         if (short_channel_ids_arg_constr.datalen > 0)
35028                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
35029         else
35030                 short_channel_ids_arg_constr.data = NULL;
35031         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
35032         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
35033                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
35034                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
35035         }
35036         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
35037         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
35038         int64_t ret_ref = 0;
35039         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35040         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35041         return ret_ref;
35042 }
35043
35044 static inline uint64_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
35045         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
35046         int64_t ret_ref = 0;
35047         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35048         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35049         return ret_ref;
35050 }
35051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35052         LDKQueryShortChannelIds arg_conv;
35053         arg_conv.inner = untag_ptr(arg);
35054         arg_conv.is_owned = ptr_is_owned(arg);
35055         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35056         arg_conv.is_owned = false;
35057         int64_t ret_conv = QueryShortChannelIds_clone_ptr(&arg_conv);
35058         return ret_conv;
35059 }
35060
35061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35062         LDKQueryShortChannelIds orig_conv;
35063         orig_conv.inner = untag_ptr(orig);
35064         orig_conv.is_owned = ptr_is_owned(orig);
35065         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35066         orig_conv.is_owned = false;
35067         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
35068         int64_t ret_ref = 0;
35069         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35070         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35071         return ret_ref;
35072 }
35073
35074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35075         LDKReplyShortChannelIdsEnd this_obj_conv;
35076         this_obj_conv.inner = untag_ptr(this_obj);
35077         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35079         ReplyShortChannelIdsEnd_free(this_obj_conv);
35080 }
35081
35082 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35083         LDKReplyShortChannelIdsEnd this_ptr_conv;
35084         this_ptr_conv.inner = untag_ptr(this_ptr);
35085         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35087         this_ptr_conv.is_owned = false;
35088         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35089         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
35090         return ret_arr;
35091 }
35092
35093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35094         LDKReplyShortChannelIdsEnd this_ptr_conv;
35095         this_ptr_conv.inner = untag_ptr(this_ptr);
35096         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35098         this_ptr_conv.is_owned = false;
35099         LDKThirtyTwoBytes val_ref;
35100         CHECK((*env)->GetArrayLength(env, val) == 32);
35101         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35102         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
35103 }
35104
35105 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
35106         LDKReplyShortChannelIdsEnd this_ptr_conv;
35107         this_ptr_conv.inner = untag_ptr(this_ptr);
35108         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35110         this_ptr_conv.is_owned = false;
35111         jboolean ret_conv = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
35112         return ret_conv;
35113 }
35114
35115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
35116         LDKReplyShortChannelIdsEnd this_ptr_conv;
35117         this_ptr_conv.inner = untag_ptr(this_ptr);
35118         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35120         this_ptr_conv.is_owned = false;
35121         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
35122 }
35123
35124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
35125         LDKThirtyTwoBytes chain_hash_arg_ref;
35126         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
35127         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
35128         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
35129         int64_t ret_ref = 0;
35130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35131         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35132         return ret_ref;
35133 }
35134
35135 static inline uint64_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
35136         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
35137         int64_t ret_ref = 0;
35138         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35139         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35140         return ret_ref;
35141 }
35142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35143         LDKReplyShortChannelIdsEnd arg_conv;
35144         arg_conv.inner = untag_ptr(arg);
35145         arg_conv.is_owned = ptr_is_owned(arg);
35146         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35147         arg_conv.is_owned = false;
35148         int64_t ret_conv = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
35149         return ret_conv;
35150 }
35151
35152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35153         LDKReplyShortChannelIdsEnd orig_conv;
35154         orig_conv.inner = untag_ptr(orig);
35155         orig_conv.is_owned = ptr_is_owned(orig);
35156         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35157         orig_conv.is_owned = false;
35158         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
35159         int64_t ret_ref = 0;
35160         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35161         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35162         return ret_ref;
35163 }
35164
35165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35166         LDKGossipTimestampFilter this_obj_conv;
35167         this_obj_conv.inner = untag_ptr(this_obj);
35168         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35170         GossipTimestampFilter_free(this_obj_conv);
35171 }
35172
35173 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35174         LDKGossipTimestampFilter this_ptr_conv;
35175         this_ptr_conv.inner = untag_ptr(this_ptr);
35176         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35178         this_ptr_conv.is_owned = false;
35179         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35180         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
35181         return ret_arr;
35182 }
35183
35184 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35185         LDKGossipTimestampFilter this_ptr_conv;
35186         this_ptr_conv.inner = untag_ptr(this_ptr);
35187         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35189         this_ptr_conv.is_owned = false;
35190         LDKThirtyTwoBytes val_ref;
35191         CHECK((*env)->GetArrayLength(env, val) == 32);
35192         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35193         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
35194 }
35195
35196 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
35197         LDKGossipTimestampFilter this_ptr_conv;
35198         this_ptr_conv.inner = untag_ptr(this_ptr);
35199         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35201         this_ptr_conv.is_owned = false;
35202         int32_t ret_conv = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
35203         return ret_conv;
35204 }
35205
35206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35207         LDKGossipTimestampFilter this_ptr_conv;
35208         this_ptr_conv.inner = untag_ptr(this_ptr);
35209         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35211         this_ptr_conv.is_owned = false;
35212         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
35213 }
35214
35215 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
35216         LDKGossipTimestampFilter this_ptr_conv;
35217         this_ptr_conv.inner = untag_ptr(this_ptr);
35218         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35220         this_ptr_conv.is_owned = false;
35221         int32_t ret_conv = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
35222         return ret_conv;
35223 }
35224
35225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35226         LDKGossipTimestampFilter this_ptr_conv;
35227         this_ptr_conv.inner = untag_ptr(this_ptr);
35228         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35230         this_ptr_conv.is_owned = false;
35231         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
35232 }
35233
35234 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) {
35235         LDKThirtyTwoBytes chain_hash_arg_ref;
35236         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
35237         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
35238         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
35239         int64_t ret_ref = 0;
35240         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35241         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35242         return ret_ref;
35243 }
35244
35245 static inline uint64_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
35246         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
35247         int64_t ret_ref = 0;
35248         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35249         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35250         return ret_ref;
35251 }
35252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35253         LDKGossipTimestampFilter arg_conv;
35254         arg_conv.inner = untag_ptr(arg);
35255         arg_conv.is_owned = ptr_is_owned(arg);
35256         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35257         arg_conv.is_owned = false;
35258         int64_t ret_conv = GossipTimestampFilter_clone_ptr(&arg_conv);
35259         return ret_conv;
35260 }
35261
35262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35263         LDKGossipTimestampFilter orig_conv;
35264         orig_conv.inner = untag_ptr(orig);
35265         orig_conv.is_owned = ptr_is_owned(orig);
35266         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35267         orig_conv.is_owned = false;
35268         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
35269         int64_t ret_ref = 0;
35270         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35271         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35272         return ret_ref;
35273 }
35274
35275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
35276         if (!ptr_is_owned(this_ptr)) return;
35277         void* this_ptr_ptr = untag_ptr(this_ptr);
35278         CHECK_ACCESS(this_ptr_ptr);
35279         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
35280         FREE(untag_ptr(this_ptr));
35281         ErrorAction_free(this_ptr_conv);
35282 }
35283
35284 static inline uint64_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
35285         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
35286         *ret_copy = ErrorAction_clone(arg);
35287         int64_t ret_ref = tag_ptr(ret_copy, true);
35288         return ret_ref;
35289 }
35290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35291         LDKErrorAction* arg_conv = (LDKErrorAction*)untag_ptr(arg);
35292         int64_t ret_conv = ErrorAction_clone_ptr(arg_conv);
35293         return ret_conv;
35294 }
35295
35296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35297         LDKErrorAction* orig_conv = (LDKErrorAction*)untag_ptr(orig);
35298         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
35299         *ret_copy = ErrorAction_clone(orig_conv);
35300         int64_t ret_ref = tag_ptr(ret_copy, true);
35301         return ret_ref;
35302 }
35303
35304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
35305         LDKErrorMessage msg_conv;
35306         msg_conv.inner = untag_ptr(msg);
35307         msg_conv.is_owned = ptr_is_owned(msg);
35308         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
35309         msg_conv = ErrorMessage_clone(&msg_conv);
35310         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
35311         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
35312         int64_t ret_ref = tag_ptr(ret_copy, true);
35313         return ret_ref;
35314 }
35315
35316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
35317         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
35318         *ret_copy = ErrorAction_ignore_error();
35319         int64_t ret_ref = tag_ptr(ret_copy, true);
35320         return ret_ref;
35321 }
35322
35323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
35324         LDKLevel a_conv = LDKLevel_from_java(env, a);
35325         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
35326         *ret_copy = ErrorAction_ignore_and_log(a_conv);
35327         int64_t ret_ref = tag_ptr(ret_copy, true);
35328         return ret_ref;
35329 }
35330
35331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1duplicate_1gossip(JNIEnv *env, jclass clz) {
35332         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
35333         *ret_copy = ErrorAction_ignore_duplicate_gossip();
35334         int64_t ret_ref = tag_ptr(ret_copy, true);
35335         return ret_ref;
35336 }
35337
35338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
35339         LDKErrorMessage msg_conv;
35340         msg_conv.inner = untag_ptr(msg);
35341         msg_conv.is_owned = ptr_is_owned(msg);
35342         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
35343         msg_conv = ErrorMessage_clone(&msg_conv);
35344         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
35345         *ret_copy = ErrorAction_send_error_message(msg_conv);
35346         int64_t ret_ref = tag_ptr(ret_copy, true);
35347         return ret_ref;
35348 }
35349
35350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1warning_1message(JNIEnv *env, jclass clz, int64_t msg, jclass log_level) {
35351         LDKWarningMessage msg_conv;
35352         msg_conv.inner = untag_ptr(msg);
35353         msg_conv.is_owned = ptr_is_owned(msg);
35354         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
35355         msg_conv = WarningMessage_clone(&msg_conv);
35356         LDKLevel log_level_conv = LDKLevel_from_java(env, log_level);
35357         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
35358         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
35359         int64_t ret_ref = tag_ptr(ret_copy, true);
35360         return ret_ref;
35361 }
35362
35363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35364         LDKLightningError this_obj_conv;
35365         this_obj_conv.inner = untag_ptr(this_obj);
35366         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35368         LightningError_free(this_obj_conv);
35369 }
35370
35371 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
35372         LDKLightningError 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         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
35378         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
35379         Str_free(ret_str);
35380         return ret_conv;
35381 }
35382
35383 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
35384         LDKLightningError this_ptr_conv;
35385         this_ptr_conv.inner = untag_ptr(this_ptr);
35386         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35388         this_ptr_conv.is_owned = false;
35389         LDKStr val_conv = java_to_owned_str(env, val);
35390         LightningError_set_err(&this_ptr_conv, val_conv);
35391 }
35392
35393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
35394         LDKLightningError this_ptr_conv;
35395         this_ptr_conv.inner = untag_ptr(this_ptr);
35396         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35398         this_ptr_conv.is_owned = false;
35399         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
35400         *ret_copy = LightningError_get_action(&this_ptr_conv);
35401         int64_t ret_ref = tag_ptr(ret_copy, true);
35402         return ret_ref;
35403 }
35404
35405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35406         LDKLightningError 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         void* val_ptr = untag_ptr(val);
35412         CHECK_ACCESS(val_ptr);
35413         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
35414         val_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(val));
35415         LightningError_set_action(&this_ptr_conv, val_conv);
35416 }
35417
35418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
35419         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
35420         void* action_arg_ptr = untag_ptr(action_arg);
35421         CHECK_ACCESS(action_arg_ptr);
35422         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
35423         action_arg_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(action_arg));
35424         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
35425         int64_t ret_ref = 0;
35426         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35427         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35428         return ret_ref;
35429 }
35430
35431 static inline uint64_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
35432         LDKLightningError ret_var = LightningError_clone(arg);
35433         int64_t ret_ref = 0;
35434         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35435         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35436         return ret_ref;
35437 }
35438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35439         LDKLightningError arg_conv;
35440         arg_conv.inner = untag_ptr(arg);
35441         arg_conv.is_owned = ptr_is_owned(arg);
35442         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35443         arg_conv.is_owned = false;
35444         int64_t ret_conv = LightningError_clone_ptr(&arg_conv);
35445         return ret_conv;
35446 }
35447
35448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35449         LDKLightningError orig_conv;
35450         orig_conv.inner = untag_ptr(orig);
35451         orig_conv.is_owned = ptr_is_owned(orig);
35452         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35453         orig_conv.is_owned = false;
35454         LDKLightningError ret_var = LightningError_clone(&orig_conv);
35455         int64_t ret_ref = 0;
35456         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35457         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35458         return ret_ref;
35459 }
35460
35461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35462         LDKCommitmentUpdate this_obj_conv;
35463         this_obj_conv.inner = untag_ptr(this_obj);
35464         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35466         CommitmentUpdate_free(this_obj_conv);
35467 }
35468
35469 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
35470         LDKCommitmentUpdate this_ptr_conv;
35471         this_ptr_conv.inner = untag_ptr(this_ptr);
35472         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35474         this_ptr_conv.is_owned = false;
35475         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
35476         int64_tArray ret_arr = NULL;
35477         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
35478         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
35479         for (size_t p = 0; p < ret_var.datalen; p++) {
35480                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
35481                 int64_t ret_conv_15_ref = 0;
35482                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
35483                 ret_conv_15_ref = tag_ptr(ret_conv_15_var.inner, ret_conv_15_var.is_owned);
35484                 ret_arr_ptr[p] = ret_conv_15_ref;
35485         }
35486         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
35487         FREE(ret_var.data);
35488         return ret_arr;
35489 }
35490
35491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
35492         LDKCommitmentUpdate this_ptr_conv;
35493         this_ptr_conv.inner = untag_ptr(this_ptr);
35494         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35496         this_ptr_conv.is_owned = false;
35497         LDKCVec_UpdateAddHTLCZ val_constr;
35498         val_constr.datalen = (*env)->GetArrayLength(env, val);
35499         if (val_constr.datalen > 0)
35500                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
35501         else
35502                 val_constr.data = NULL;
35503         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35504         for (size_t p = 0; p < val_constr.datalen; p++) {
35505                 int64_t val_conv_15 = val_vals[p];
35506                 LDKUpdateAddHTLC val_conv_15_conv;
35507                 val_conv_15_conv.inner = untag_ptr(val_conv_15);
35508                 val_conv_15_conv.is_owned = ptr_is_owned(val_conv_15);
35509                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
35510                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
35511                 val_constr.data[p] = val_conv_15_conv;
35512         }
35513         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35514         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
35515 }
35516
35517 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
35518         LDKCommitmentUpdate this_ptr_conv;
35519         this_ptr_conv.inner = untag_ptr(this_ptr);
35520         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35522         this_ptr_conv.is_owned = false;
35523         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
35524         int64_tArray ret_arr = NULL;
35525         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
35526         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
35527         for (size_t t = 0; t < ret_var.datalen; t++) {
35528                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
35529                 int64_t ret_conv_19_ref = 0;
35530                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
35531                 ret_conv_19_ref = tag_ptr(ret_conv_19_var.inner, ret_conv_19_var.is_owned);
35532                 ret_arr_ptr[t] = ret_conv_19_ref;
35533         }
35534         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
35535         FREE(ret_var.data);
35536         return ret_arr;
35537 }
35538
35539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
35540         LDKCommitmentUpdate this_ptr_conv;
35541         this_ptr_conv.inner = untag_ptr(this_ptr);
35542         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35544         this_ptr_conv.is_owned = false;
35545         LDKCVec_UpdateFulfillHTLCZ val_constr;
35546         val_constr.datalen = (*env)->GetArrayLength(env, val);
35547         if (val_constr.datalen > 0)
35548                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
35549         else
35550                 val_constr.data = NULL;
35551         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35552         for (size_t t = 0; t < val_constr.datalen; t++) {
35553                 int64_t val_conv_19 = val_vals[t];
35554                 LDKUpdateFulfillHTLC val_conv_19_conv;
35555                 val_conv_19_conv.inner = untag_ptr(val_conv_19);
35556                 val_conv_19_conv.is_owned = ptr_is_owned(val_conv_19);
35557                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
35558                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
35559                 val_constr.data[t] = val_conv_19_conv;
35560         }
35561         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35562         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
35563 }
35564
35565 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
35566         LDKCommitmentUpdate this_ptr_conv;
35567         this_ptr_conv.inner = untag_ptr(this_ptr);
35568         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35570         this_ptr_conv.is_owned = false;
35571         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
35572         int64_tArray ret_arr = NULL;
35573         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
35574         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
35575         for (size_t q = 0; q < ret_var.datalen; q++) {
35576                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
35577                 int64_t ret_conv_16_ref = 0;
35578                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
35579                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
35580                 ret_arr_ptr[q] = ret_conv_16_ref;
35581         }
35582         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
35583         FREE(ret_var.data);
35584         return ret_arr;
35585 }
35586
35587 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
35588         LDKCommitmentUpdate this_ptr_conv;
35589         this_ptr_conv.inner = untag_ptr(this_ptr);
35590         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35592         this_ptr_conv.is_owned = false;
35593         LDKCVec_UpdateFailHTLCZ val_constr;
35594         val_constr.datalen = (*env)->GetArrayLength(env, val);
35595         if (val_constr.datalen > 0)
35596                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
35597         else
35598                 val_constr.data = NULL;
35599         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35600         for (size_t q = 0; q < val_constr.datalen; q++) {
35601                 int64_t val_conv_16 = val_vals[q];
35602                 LDKUpdateFailHTLC val_conv_16_conv;
35603                 val_conv_16_conv.inner = untag_ptr(val_conv_16);
35604                 val_conv_16_conv.is_owned = ptr_is_owned(val_conv_16);
35605                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
35606                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
35607                 val_constr.data[q] = val_conv_16_conv;
35608         }
35609         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35610         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
35611 }
35612
35613 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
35614         LDKCommitmentUpdate this_ptr_conv;
35615         this_ptr_conv.inner = untag_ptr(this_ptr);
35616         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35618         this_ptr_conv.is_owned = false;
35619         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
35620         int64_tArray ret_arr = NULL;
35621         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
35622         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
35623         for (size_t z = 0; z < ret_var.datalen; z++) {
35624                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
35625                 int64_t ret_conv_25_ref = 0;
35626                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
35627                 ret_conv_25_ref = tag_ptr(ret_conv_25_var.inner, ret_conv_25_var.is_owned);
35628                 ret_arr_ptr[z] = ret_conv_25_ref;
35629         }
35630         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
35631         FREE(ret_var.data);
35632         return ret_arr;
35633 }
35634
35635 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) {
35636         LDKCommitmentUpdate this_ptr_conv;
35637         this_ptr_conv.inner = untag_ptr(this_ptr);
35638         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35640         this_ptr_conv.is_owned = false;
35641         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
35642         val_constr.datalen = (*env)->GetArrayLength(env, val);
35643         if (val_constr.datalen > 0)
35644                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
35645         else
35646                 val_constr.data = NULL;
35647         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35648         for (size_t z = 0; z < val_constr.datalen; z++) {
35649                 int64_t val_conv_25 = val_vals[z];
35650                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
35651                 val_conv_25_conv.inner = untag_ptr(val_conv_25);
35652                 val_conv_25_conv.is_owned = ptr_is_owned(val_conv_25);
35653                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
35654                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
35655                 val_constr.data[z] = val_conv_25_conv;
35656         }
35657         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35658         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
35659 }
35660
35661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
35662         LDKCommitmentUpdate this_ptr_conv;
35663         this_ptr_conv.inner = untag_ptr(this_ptr);
35664         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35666         this_ptr_conv.is_owned = false;
35667         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
35668         int64_t ret_ref = 0;
35669         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35670         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35671         return ret_ref;
35672 }
35673
35674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35675         LDKCommitmentUpdate this_ptr_conv;
35676         this_ptr_conv.inner = untag_ptr(this_ptr);
35677         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35679         this_ptr_conv.is_owned = false;
35680         LDKUpdateFee val_conv;
35681         val_conv.inner = untag_ptr(val);
35682         val_conv.is_owned = ptr_is_owned(val);
35683         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35684         val_conv = UpdateFee_clone(&val_conv);
35685         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
35686 }
35687
35688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
35689         LDKCommitmentUpdate this_ptr_conv;
35690         this_ptr_conv.inner = untag_ptr(this_ptr);
35691         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35693         this_ptr_conv.is_owned = false;
35694         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
35695         int64_t ret_ref = 0;
35696         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35697         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35698         return ret_ref;
35699 }
35700
35701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35702         LDKCommitmentUpdate this_ptr_conv;
35703         this_ptr_conv.inner = untag_ptr(this_ptr);
35704         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35706         this_ptr_conv.is_owned = false;
35707         LDKCommitmentSigned val_conv;
35708         val_conv.inner = untag_ptr(val);
35709         val_conv.is_owned = ptr_is_owned(val);
35710         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35711         val_conv = CommitmentSigned_clone(&val_conv);
35712         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
35713 }
35714
35715 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) {
35716         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
35717         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
35718         if (update_add_htlcs_arg_constr.datalen > 0)
35719                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
35720         else
35721                 update_add_htlcs_arg_constr.data = NULL;
35722         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
35723         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
35724                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
35725                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
35726                 update_add_htlcs_arg_conv_15_conv.inner = untag_ptr(update_add_htlcs_arg_conv_15);
35727                 update_add_htlcs_arg_conv_15_conv.is_owned = ptr_is_owned(update_add_htlcs_arg_conv_15);
35728                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
35729                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
35730                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
35731         }
35732         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
35733         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
35734         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
35735         if (update_fulfill_htlcs_arg_constr.datalen > 0)
35736                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
35737         else
35738                 update_fulfill_htlcs_arg_constr.data = NULL;
35739         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
35740         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
35741                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
35742                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
35743                 update_fulfill_htlcs_arg_conv_19_conv.inner = untag_ptr(update_fulfill_htlcs_arg_conv_19);
35744                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = ptr_is_owned(update_fulfill_htlcs_arg_conv_19);
35745                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
35746                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
35747                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
35748         }
35749         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
35750         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
35751         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
35752         if (update_fail_htlcs_arg_constr.datalen > 0)
35753                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
35754         else
35755                 update_fail_htlcs_arg_constr.data = NULL;
35756         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
35757         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
35758                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
35759                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
35760                 update_fail_htlcs_arg_conv_16_conv.inner = untag_ptr(update_fail_htlcs_arg_conv_16);
35761                 update_fail_htlcs_arg_conv_16_conv.is_owned = ptr_is_owned(update_fail_htlcs_arg_conv_16);
35762                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
35763                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
35764                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
35765         }
35766         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
35767         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
35768         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
35769         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
35770                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
35771         else
35772                 update_fail_malformed_htlcs_arg_constr.data = NULL;
35773         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
35774         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
35775                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
35776                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
35777                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = untag_ptr(update_fail_malformed_htlcs_arg_conv_25);
35778                 update_fail_malformed_htlcs_arg_conv_25_conv.is_owned = ptr_is_owned(update_fail_malformed_htlcs_arg_conv_25);
35779                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
35780                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
35781                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
35782         }
35783         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
35784         LDKUpdateFee update_fee_arg_conv;
35785         update_fee_arg_conv.inner = untag_ptr(update_fee_arg);
35786         update_fee_arg_conv.is_owned = ptr_is_owned(update_fee_arg);
35787         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
35788         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
35789         LDKCommitmentSigned commitment_signed_arg_conv;
35790         commitment_signed_arg_conv.inner = untag_ptr(commitment_signed_arg);
35791         commitment_signed_arg_conv.is_owned = ptr_is_owned(commitment_signed_arg);
35792         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
35793         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
35794         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);
35795         int64_t ret_ref = 0;
35796         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35797         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35798         return ret_ref;
35799 }
35800
35801 static inline uint64_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
35802         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
35803         int64_t ret_ref = 0;
35804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35805         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35806         return ret_ref;
35807 }
35808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35809         LDKCommitmentUpdate arg_conv;
35810         arg_conv.inner = untag_ptr(arg);
35811         arg_conv.is_owned = ptr_is_owned(arg);
35812         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35813         arg_conv.is_owned = false;
35814         int64_t ret_conv = CommitmentUpdate_clone_ptr(&arg_conv);
35815         return ret_conv;
35816 }
35817
35818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35819         LDKCommitmentUpdate orig_conv;
35820         orig_conv.inner = untag_ptr(orig);
35821         orig_conv.is_owned = ptr_is_owned(orig);
35822         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35823         orig_conv.is_owned = false;
35824         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
35825         int64_t ret_ref = 0;
35826         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35827         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35828         return ret_ref;
35829 }
35830
35831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
35832         if (!ptr_is_owned(this_ptr)) return;
35833         void* this_ptr_ptr = untag_ptr(this_ptr);
35834         CHECK_ACCESS(this_ptr_ptr);
35835         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
35836         FREE(untag_ptr(this_ptr));
35837         ChannelMessageHandler_free(this_ptr_conv);
35838 }
35839
35840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
35841         if (!ptr_is_owned(this_ptr)) return;
35842         void* this_ptr_ptr = untag_ptr(this_ptr);
35843         CHECK_ACCESS(this_ptr_ptr);
35844         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
35845         FREE(untag_ptr(this_ptr));
35846         RoutingMessageHandler_free(this_ptr_conv);
35847 }
35848
35849 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
35850         LDKAcceptChannel obj_conv;
35851         obj_conv.inner = untag_ptr(obj);
35852         obj_conv.is_owned = ptr_is_owned(obj);
35853         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35854         obj_conv.is_owned = false;
35855         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
35856         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35857         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35858         CVec_u8Z_free(ret_var);
35859         return ret_arr;
35860 }
35861
35862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35863         LDKu8slice ser_ref;
35864         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35865         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35866         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
35867         *ret_conv = AcceptChannel_read(ser_ref);
35868         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35869         return tag_ptr(ret_conv, true);
35870 }
35871
35872 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
35873         LDKAnnouncementSignatures obj_conv;
35874         obj_conv.inner = untag_ptr(obj);
35875         obj_conv.is_owned = ptr_is_owned(obj);
35876         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35877         obj_conv.is_owned = false;
35878         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
35879         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35880         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35881         CVec_u8Z_free(ret_var);
35882         return ret_arr;
35883 }
35884
35885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35886         LDKu8slice ser_ref;
35887         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35888         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35889         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
35890         *ret_conv = AnnouncementSignatures_read(ser_ref);
35891         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35892         return tag_ptr(ret_conv, true);
35893 }
35894
35895 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
35896         LDKChannelReestablish obj_conv;
35897         obj_conv.inner = untag_ptr(obj);
35898         obj_conv.is_owned = ptr_is_owned(obj);
35899         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35900         obj_conv.is_owned = false;
35901         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
35902         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35903         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35904         CVec_u8Z_free(ret_var);
35905         return ret_arr;
35906 }
35907
35908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35909         LDKu8slice ser_ref;
35910         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35911         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35912         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
35913         *ret_conv = ChannelReestablish_read(ser_ref);
35914         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35915         return tag_ptr(ret_conv, true);
35916 }
35917
35918 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
35919         LDKClosingSigned obj_conv;
35920         obj_conv.inner = untag_ptr(obj);
35921         obj_conv.is_owned = ptr_is_owned(obj);
35922         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35923         obj_conv.is_owned = false;
35924         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
35925         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35926         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35927         CVec_u8Z_free(ret_var);
35928         return ret_arr;
35929 }
35930
35931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35932         LDKu8slice ser_ref;
35933         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35934         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35935         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
35936         *ret_conv = ClosingSigned_read(ser_ref);
35937         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35938         return tag_ptr(ret_conv, true);
35939 }
35940
35941 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
35942         LDKClosingSignedFeeRange obj_conv;
35943         obj_conv.inner = untag_ptr(obj);
35944         obj_conv.is_owned = ptr_is_owned(obj);
35945         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35946         obj_conv.is_owned = false;
35947         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
35948         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35949         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35950         CVec_u8Z_free(ret_var);
35951         return ret_arr;
35952 }
35953
35954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35955         LDKu8slice ser_ref;
35956         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35957         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35958         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
35959         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
35960         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35961         return tag_ptr(ret_conv, true);
35962 }
35963
35964 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
35965         LDKCommitmentSigned obj_conv;
35966         obj_conv.inner = untag_ptr(obj);
35967         obj_conv.is_owned = ptr_is_owned(obj);
35968         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35969         obj_conv.is_owned = false;
35970         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
35971         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35972         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35973         CVec_u8Z_free(ret_var);
35974         return ret_arr;
35975 }
35976
35977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35978         LDKu8slice ser_ref;
35979         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35980         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35981         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
35982         *ret_conv = CommitmentSigned_read(ser_ref);
35983         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35984         return tag_ptr(ret_conv, true);
35985 }
35986
35987 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
35988         LDKFundingCreated obj_conv;
35989         obj_conv.inner = untag_ptr(obj);
35990         obj_conv.is_owned = ptr_is_owned(obj);
35991         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35992         obj_conv.is_owned = false;
35993         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
35994         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35995         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35996         CVec_u8Z_free(ret_var);
35997         return ret_arr;
35998 }
35999
36000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36001         LDKu8slice ser_ref;
36002         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36003         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36004         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
36005         *ret_conv = FundingCreated_read(ser_ref);
36006         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36007         return tag_ptr(ret_conv, true);
36008 }
36009
36010 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
36011         LDKFundingSigned obj_conv;
36012         obj_conv.inner = untag_ptr(obj);
36013         obj_conv.is_owned = ptr_is_owned(obj);
36014         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36015         obj_conv.is_owned = false;
36016         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
36017         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36018         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36019         CVec_u8Z_free(ret_var);
36020         return ret_arr;
36021 }
36022
36023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36024         LDKu8slice ser_ref;
36025         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36026         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36027         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
36028         *ret_conv = FundingSigned_read(ser_ref);
36029         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36030         return tag_ptr(ret_conv, true);
36031 }
36032
36033 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1write(JNIEnv *env, jclass clz, int64_t obj) {
36034         LDKChannelReady obj_conv;
36035         obj_conv.inner = untag_ptr(obj);
36036         obj_conv.is_owned = ptr_is_owned(obj);
36037         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36038         obj_conv.is_owned = false;
36039         LDKCVec_u8Z ret_var = ChannelReady_write(&obj_conv);
36040         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36041         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36042         CVec_u8Z_free(ret_var);
36043         return ret_arr;
36044 }
36045
36046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36047         LDKu8slice ser_ref;
36048         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36049         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36050         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
36051         *ret_conv = ChannelReady_read(ser_ref);
36052         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36053         return tag_ptr(ret_conv, true);
36054 }
36055
36056 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
36057         LDKInit obj_conv;
36058         obj_conv.inner = untag_ptr(obj);
36059         obj_conv.is_owned = ptr_is_owned(obj);
36060         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36061         obj_conv.is_owned = false;
36062         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
36063         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36064         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36065         CVec_u8Z_free(ret_var);
36066         return ret_arr;
36067 }
36068
36069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36070         LDKu8slice ser_ref;
36071         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36072         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36073         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
36074         *ret_conv = Init_read(ser_ref);
36075         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36076         return tag_ptr(ret_conv, true);
36077 }
36078
36079 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
36080         LDKOpenChannel obj_conv;
36081         obj_conv.inner = untag_ptr(obj);
36082         obj_conv.is_owned = ptr_is_owned(obj);
36083         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36084         obj_conv.is_owned = false;
36085         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
36086         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36087         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36088         CVec_u8Z_free(ret_var);
36089         return ret_arr;
36090 }
36091
36092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36093         LDKu8slice ser_ref;
36094         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36095         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36096         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
36097         *ret_conv = OpenChannel_read(ser_ref);
36098         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36099         return tag_ptr(ret_conv, true);
36100 }
36101
36102 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
36103         LDKRevokeAndACK obj_conv;
36104         obj_conv.inner = untag_ptr(obj);
36105         obj_conv.is_owned = ptr_is_owned(obj);
36106         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36107         obj_conv.is_owned = false;
36108         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
36109         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36110         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36111         CVec_u8Z_free(ret_var);
36112         return ret_arr;
36113 }
36114
36115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36116         LDKu8slice ser_ref;
36117         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36118         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36119         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
36120         *ret_conv = RevokeAndACK_read(ser_ref);
36121         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36122         return tag_ptr(ret_conv, true);
36123 }
36124
36125 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
36126         LDKShutdown obj_conv;
36127         obj_conv.inner = untag_ptr(obj);
36128         obj_conv.is_owned = ptr_is_owned(obj);
36129         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36130         obj_conv.is_owned = false;
36131         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
36132         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36133         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36134         CVec_u8Z_free(ret_var);
36135         return ret_arr;
36136 }
36137
36138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36139         LDKu8slice ser_ref;
36140         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36141         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36142         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
36143         *ret_conv = Shutdown_read(ser_ref);
36144         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36145         return tag_ptr(ret_conv, true);
36146 }
36147
36148 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
36149         LDKUpdateFailHTLC obj_conv;
36150         obj_conv.inner = untag_ptr(obj);
36151         obj_conv.is_owned = ptr_is_owned(obj);
36152         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36153         obj_conv.is_owned = false;
36154         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
36155         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36156         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36157         CVec_u8Z_free(ret_var);
36158         return ret_arr;
36159 }
36160
36161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36162         LDKu8slice ser_ref;
36163         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36164         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36165         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
36166         *ret_conv = UpdateFailHTLC_read(ser_ref);
36167         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36168         return tag_ptr(ret_conv, true);
36169 }
36170
36171 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
36172         LDKUpdateFailMalformedHTLC obj_conv;
36173         obj_conv.inner = untag_ptr(obj);
36174         obj_conv.is_owned = ptr_is_owned(obj);
36175         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36176         obj_conv.is_owned = false;
36177         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
36178         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36179         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36180         CVec_u8Z_free(ret_var);
36181         return ret_arr;
36182 }
36183
36184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36185         LDKu8slice ser_ref;
36186         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36187         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36188         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
36189         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
36190         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36191         return tag_ptr(ret_conv, true);
36192 }
36193
36194 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
36195         LDKUpdateFee obj_conv;
36196         obj_conv.inner = untag_ptr(obj);
36197         obj_conv.is_owned = ptr_is_owned(obj);
36198         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36199         obj_conv.is_owned = false;
36200         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
36201         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36202         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36203         CVec_u8Z_free(ret_var);
36204         return ret_arr;
36205 }
36206
36207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36208         LDKu8slice ser_ref;
36209         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36210         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36211         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
36212         *ret_conv = UpdateFee_read(ser_ref);
36213         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36214         return tag_ptr(ret_conv, true);
36215 }
36216
36217 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
36218         LDKUpdateFulfillHTLC obj_conv;
36219         obj_conv.inner = untag_ptr(obj);
36220         obj_conv.is_owned = ptr_is_owned(obj);
36221         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36222         obj_conv.is_owned = false;
36223         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
36224         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36225         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36226         CVec_u8Z_free(ret_var);
36227         return ret_arr;
36228 }
36229
36230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36231         LDKu8slice ser_ref;
36232         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36233         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36234         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
36235         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
36236         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36237         return tag_ptr(ret_conv, true);
36238 }
36239
36240 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
36241         LDKUpdateAddHTLC obj_conv;
36242         obj_conv.inner = untag_ptr(obj);
36243         obj_conv.is_owned = ptr_is_owned(obj);
36244         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36245         obj_conv.is_owned = false;
36246         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
36247         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36248         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36249         CVec_u8Z_free(ret_var);
36250         return ret_arr;
36251 }
36252
36253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36254         LDKu8slice ser_ref;
36255         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36256         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36257         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
36258         *ret_conv = UpdateAddHTLC_read(ser_ref);
36259         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36260         return tag_ptr(ret_conv, true);
36261 }
36262
36263 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
36264         LDKPing obj_conv;
36265         obj_conv.inner = untag_ptr(obj);
36266         obj_conv.is_owned = ptr_is_owned(obj);
36267         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36268         obj_conv.is_owned = false;
36269         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
36270         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36271         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36272         CVec_u8Z_free(ret_var);
36273         return ret_arr;
36274 }
36275
36276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36277         LDKu8slice ser_ref;
36278         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36279         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36280         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
36281         *ret_conv = Ping_read(ser_ref);
36282         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36283         return tag_ptr(ret_conv, true);
36284 }
36285
36286 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
36287         LDKPong obj_conv;
36288         obj_conv.inner = untag_ptr(obj);
36289         obj_conv.is_owned = ptr_is_owned(obj);
36290         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36291         obj_conv.is_owned = false;
36292         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
36293         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36294         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36295         CVec_u8Z_free(ret_var);
36296         return ret_arr;
36297 }
36298
36299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36300         LDKu8slice ser_ref;
36301         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36302         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36303         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
36304         *ret_conv = Pong_read(ser_ref);
36305         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36306         return tag_ptr(ret_conv, true);
36307 }
36308
36309 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
36310         LDKUnsignedChannelAnnouncement obj_conv;
36311         obj_conv.inner = untag_ptr(obj);
36312         obj_conv.is_owned = ptr_is_owned(obj);
36313         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36314         obj_conv.is_owned = false;
36315         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
36316         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36317         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36318         CVec_u8Z_free(ret_var);
36319         return ret_arr;
36320 }
36321
36322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36323         LDKu8slice ser_ref;
36324         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36325         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36326         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
36327         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
36328         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36329         return tag_ptr(ret_conv, true);
36330 }
36331
36332 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
36333         LDKChannelAnnouncement obj_conv;
36334         obj_conv.inner = untag_ptr(obj);
36335         obj_conv.is_owned = ptr_is_owned(obj);
36336         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36337         obj_conv.is_owned = false;
36338         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
36339         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36340         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36341         CVec_u8Z_free(ret_var);
36342         return ret_arr;
36343 }
36344
36345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36346         LDKu8slice ser_ref;
36347         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36348         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36349         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
36350         *ret_conv = ChannelAnnouncement_read(ser_ref);
36351         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36352         return tag_ptr(ret_conv, true);
36353 }
36354
36355 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
36356         LDKUnsignedChannelUpdate obj_conv;
36357         obj_conv.inner = untag_ptr(obj);
36358         obj_conv.is_owned = ptr_is_owned(obj);
36359         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36360         obj_conv.is_owned = false;
36361         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
36362         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36363         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36364         CVec_u8Z_free(ret_var);
36365         return ret_arr;
36366 }
36367
36368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36369         LDKu8slice ser_ref;
36370         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36371         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36372         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
36373         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
36374         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36375         return tag_ptr(ret_conv, true);
36376 }
36377
36378 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
36379         LDKChannelUpdate obj_conv;
36380         obj_conv.inner = untag_ptr(obj);
36381         obj_conv.is_owned = ptr_is_owned(obj);
36382         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36383         obj_conv.is_owned = false;
36384         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
36385         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36386         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36387         CVec_u8Z_free(ret_var);
36388         return ret_arr;
36389 }
36390
36391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36392         LDKu8slice ser_ref;
36393         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36394         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36395         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
36396         *ret_conv = ChannelUpdate_read(ser_ref);
36397         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36398         return tag_ptr(ret_conv, true);
36399 }
36400
36401 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
36402         LDKErrorMessage obj_conv;
36403         obj_conv.inner = untag_ptr(obj);
36404         obj_conv.is_owned = ptr_is_owned(obj);
36405         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36406         obj_conv.is_owned = false;
36407         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
36408         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36409         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36410         CVec_u8Z_free(ret_var);
36411         return ret_arr;
36412 }
36413
36414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36415         LDKu8slice ser_ref;
36416         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36417         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36418         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
36419         *ret_conv = ErrorMessage_read(ser_ref);
36420         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36421         return tag_ptr(ret_conv, true);
36422 }
36423
36424 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
36425         LDKWarningMessage obj_conv;
36426         obj_conv.inner = untag_ptr(obj);
36427         obj_conv.is_owned = ptr_is_owned(obj);
36428         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36429         obj_conv.is_owned = false;
36430         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
36431         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36432         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36433         CVec_u8Z_free(ret_var);
36434         return ret_arr;
36435 }
36436
36437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36438         LDKu8slice ser_ref;
36439         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36440         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36441         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
36442         *ret_conv = WarningMessage_read(ser_ref);
36443         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36444         return tag_ptr(ret_conv, true);
36445 }
36446
36447 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
36448         LDKUnsignedNodeAnnouncement obj_conv;
36449         obj_conv.inner = untag_ptr(obj);
36450         obj_conv.is_owned = ptr_is_owned(obj);
36451         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36452         obj_conv.is_owned = false;
36453         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
36454         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36455         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36456         CVec_u8Z_free(ret_var);
36457         return ret_arr;
36458 }
36459
36460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36461         LDKu8slice ser_ref;
36462         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36463         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36464         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
36465         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
36466         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36467         return tag_ptr(ret_conv, true);
36468 }
36469
36470 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
36471         LDKNodeAnnouncement obj_conv;
36472         obj_conv.inner = untag_ptr(obj);
36473         obj_conv.is_owned = ptr_is_owned(obj);
36474         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36475         obj_conv.is_owned = false;
36476         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
36477         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36478         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36479         CVec_u8Z_free(ret_var);
36480         return ret_arr;
36481 }
36482
36483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36484         LDKu8slice ser_ref;
36485         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36486         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36487         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
36488         *ret_conv = NodeAnnouncement_read(ser_ref);
36489         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36490         return tag_ptr(ret_conv, true);
36491 }
36492
36493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36494         LDKu8slice ser_ref;
36495         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36496         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36497         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
36498         *ret_conv = QueryShortChannelIds_read(ser_ref);
36499         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36500         return tag_ptr(ret_conv, true);
36501 }
36502
36503 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
36504         LDKQueryShortChannelIds obj_conv;
36505         obj_conv.inner = untag_ptr(obj);
36506         obj_conv.is_owned = ptr_is_owned(obj);
36507         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36508         obj_conv.is_owned = false;
36509         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
36510         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36511         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36512         CVec_u8Z_free(ret_var);
36513         return ret_arr;
36514 }
36515
36516 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
36517         LDKReplyShortChannelIdsEnd obj_conv;
36518         obj_conv.inner = untag_ptr(obj);
36519         obj_conv.is_owned = ptr_is_owned(obj);
36520         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36521         obj_conv.is_owned = false;
36522         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
36523         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36524         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36525         CVec_u8Z_free(ret_var);
36526         return ret_arr;
36527 }
36528
36529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36530         LDKu8slice ser_ref;
36531         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36532         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36533         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
36534         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
36535         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36536         return tag_ptr(ret_conv, true);
36537 }
36538
36539 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
36540         LDKQueryChannelRange this_arg_conv;
36541         this_arg_conv.inner = untag_ptr(this_arg);
36542         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36544         this_arg_conv.is_owned = false;
36545         int32_t ret_conv = QueryChannelRange_end_blocknum(&this_arg_conv);
36546         return ret_conv;
36547 }
36548
36549 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
36550         LDKQueryChannelRange obj_conv;
36551         obj_conv.inner = untag_ptr(obj);
36552         obj_conv.is_owned = ptr_is_owned(obj);
36553         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36554         obj_conv.is_owned = false;
36555         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
36556         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36557         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36558         CVec_u8Z_free(ret_var);
36559         return ret_arr;
36560 }
36561
36562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36563         LDKu8slice ser_ref;
36564         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36565         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36566         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
36567         *ret_conv = QueryChannelRange_read(ser_ref);
36568         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36569         return tag_ptr(ret_conv, true);
36570 }
36571
36572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36573         LDKu8slice ser_ref;
36574         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36575         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36576         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
36577         *ret_conv = ReplyChannelRange_read(ser_ref);
36578         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36579         return tag_ptr(ret_conv, true);
36580 }
36581
36582 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
36583         LDKReplyChannelRange obj_conv;
36584         obj_conv.inner = untag_ptr(obj);
36585         obj_conv.is_owned = ptr_is_owned(obj);
36586         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36587         obj_conv.is_owned = false;
36588         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
36589         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36590         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36591         CVec_u8Z_free(ret_var);
36592         return ret_arr;
36593 }
36594
36595 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
36596         LDKGossipTimestampFilter obj_conv;
36597         obj_conv.inner = untag_ptr(obj);
36598         obj_conv.is_owned = ptr_is_owned(obj);
36599         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36600         obj_conv.is_owned = false;
36601         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
36602         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36603         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36604         CVec_u8Z_free(ret_var);
36605         return ret_arr;
36606 }
36607
36608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36609         LDKu8slice ser_ref;
36610         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36611         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36612         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
36613         *ret_conv = GossipTimestampFilter_read(ser_ref);
36614         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36615         return tag_ptr(ret_conv, true);
36616 }
36617
36618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
36619         if (!ptr_is_owned(this_ptr)) return;
36620         void* this_ptr_ptr = untag_ptr(this_ptr);
36621         CHECK_ACCESS(this_ptr_ptr);
36622         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
36623         FREE(untag_ptr(this_ptr));
36624         CustomMessageHandler_free(this_ptr_conv);
36625 }
36626
36627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36628         LDKIgnoringMessageHandler this_obj_conv;
36629         this_obj_conv.inner = untag_ptr(this_obj);
36630         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36632         IgnoringMessageHandler_free(this_obj_conv);
36633 }
36634
36635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
36636         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
36637         int64_t ret_ref = 0;
36638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36639         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36640         return ret_ref;
36641 }
36642
36643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
36644         LDKIgnoringMessageHandler this_arg_conv;
36645         this_arg_conv.inner = untag_ptr(this_arg);
36646         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36648         this_arg_conv.is_owned = false;
36649         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
36650         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
36651         return tag_ptr(ret_ret, true);
36652 }
36653
36654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
36655         LDKIgnoringMessageHandler this_arg_conv;
36656         this_arg_conv.inner = untag_ptr(this_arg);
36657         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36659         this_arg_conv.is_owned = false;
36660         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
36661         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
36662         return tag_ptr(ret_ret, true);
36663 }
36664
36665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) {
36666         LDKIgnoringMessageHandler this_arg_conv;
36667         this_arg_conv.inner = untag_ptr(this_arg);
36668         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36670         this_arg_conv.is_owned = false;
36671         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
36672         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
36673         return tag_ptr(ret_ret, true);
36674 }
36675
36676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
36677         LDKIgnoringMessageHandler this_arg_conv;
36678         this_arg_conv.inner = untag_ptr(this_arg);
36679         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36681         this_arg_conv.is_owned = false;
36682         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
36683         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
36684         return tag_ptr(ret_ret, true);
36685 }
36686
36687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36688         LDKErroringMessageHandler this_obj_conv;
36689         this_obj_conv.inner = untag_ptr(this_obj);
36690         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36692         ErroringMessageHandler_free(this_obj_conv);
36693 }
36694
36695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
36696         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
36697         int64_t ret_ref = 0;
36698         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36699         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36700         return ret_ref;
36701 }
36702
36703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
36704         LDKErroringMessageHandler this_arg_conv;
36705         this_arg_conv.inner = untag_ptr(this_arg);
36706         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36708         this_arg_conv.is_owned = false;
36709         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
36710         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
36711         return tag_ptr(ret_ret, true);
36712 }
36713
36714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
36715         LDKErroringMessageHandler this_arg_conv;
36716         this_arg_conv.inner = untag_ptr(this_arg);
36717         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36719         this_arg_conv.is_owned = false;
36720         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
36721         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
36722         return tag_ptr(ret_ret, true);
36723 }
36724
36725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36726         LDKMessageHandler this_obj_conv;
36727         this_obj_conv.inner = untag_ptr(this_obj);
36728         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36730         MessageHandler_free(this_obj_conv);
36731 }
36732
36733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
36734         LDKMessageHandler this_ptr_conv;
36735         this_ptr_conv.inner = untag_ptr(this_ptr);
36736         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36738         this_ptr_conv.is_owned = false;
36739         // WARNING: This object doesn't live past this scope, needs clone!
36740         int64_t ret_ret = tag_ptr(MessageHandler_get_chan_handler(&this_ptr_conv), false);
36741         return ret_ret;
36742 }
36743
36744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36745         LDKMessageHandler this_ptr_conv;
36746         this_ptr_conv.inner = untag_ptr(this_ptr);
36747         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36749         this_ptr_conv.is_owned = false;
36750         void* val_ptr = untag_ptr(val);
36751         CHECK_ACCESS(val_ptr);
36752         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
36753         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
36754                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36755                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
36756         }
36757         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
36758 }
36759
36760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
36761         LDKMessageHandler this_ptr_conv;
36762         this_ptr_conv.inner = untag_ptr(this_ptr);
36763         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36765         this_ptr_conv.is_owned = false;
36766         // WARNING: This object doesn't live past this scope, needs clone!
36767         int64_t ret_ret = tag_ptr(MessageHandler_get_route_handler(&this_ptr_conv), false);
36768         return ret_ret;
36769 }
36770
36771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36772         LDKMessageHandler this_ptr_conv;
36773         this_ptr_conv.inner = untag_ptr(this_ptr);
36774         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36776         this_ptr_conv.is_owned = false;
36777         void* val_ptr = untag_ptr(val);
36778         CHECK_ACCESS(val_ptr);
36779         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
36780         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
36781                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36782                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
36783         }
36784         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
36785 }
36786
36787 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) {
36788         void* chan_handler_arg_ptr = untag_ptr(chan_handler_arg);
36789         CHECK_ACCESS(chan_handler_arg_ptr);
36790         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
36791         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
36792                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36793                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
36794         }
36795         void* route_handler_arg_ptr = untag_ptr(route_handler_arg);
36796         CHECK_ACCESS(route_handler_arg_ptr);
36797         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
36798         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
36799                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36800                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
36801         }
36802         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
36803         int64_t ret_ref = 0;
36804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36805         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36806         return ret_ref;
36807 }
36808
36809 static inline uint64_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
36810         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
36811         *ret_ret = SocketDescriptor_clone(arg);
36812         return tag_ptr(ret_ret, true);
36813 }
36814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36815         void* arg_ptr = untag_ptr(arg);
36816         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
36817         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
36818         int64_t ret_conv = SocketDescriptor_clone_ptr(arg_conv);
36819         return ret_conv;
36820 }
36821
36822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36823         void* orig_ptr = untag_ptr(orig);
36824         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
36825         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
36826         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
36827         *ret_ret = SocketDescriptor_clone(orig_conv);
36828         return tag_ptr(ret_ret, true);
36829 }
36830
36831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
36832         if (!ptr_is_owned(this_ptr)) return;
36833         void* this_ptr_ptr = untag_ptr(this_ptr);
36834         CHECK_ACCESS(this_ptr_ptr);
36835         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
36836         FREE(untag_ptr(this_ptr));
36837         SocketDescriptor_free(this_ptr_conv);
36838 }
36839
36840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36841         LDKPeerHandleError this_obj_conv;
36842         this_obj_conv.inner = untag_ptr(this_obj);
36843         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36845         PeerHandleError_free(this_obj_conv);
36846 }
36847
36848 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
36849         LDKPeerHandleError this_ptr_conv;
36850         this_ptr_conv.inner = untag_ptr(this_ptr);
36851         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36853         this_ptr_conv.is_owned = false;
36854         jboolean ret_conv = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
36855         return ret_conv;
36856 }
36857
36858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
36859         LDKPeerHandleError this_ptr_conv;
36860         this_ptr_conv.inner = untag_ptr(this_ptr);
36861         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36863         this_ptr_conv.is_owned = false;
36864         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
36865 }
36866
36867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
36868         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_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
36875 static inline uint64_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
36876         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
36877         int64_t ret_ref = 0;
36878         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36879         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36880         return ret_ref;
36881 }
36882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36883         LDKPeerHandleError arg_conv;
36884         arg_conv.inner = untag_ptr(arg);
36885         arg_conv.is_owned = ptr_is_owned(arg);
36886         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36887         arg_conv.is_owned = false;
36888         int64_t ret_conv = PeerHandleError_clone_ptr(&arg_conv);
36889         return ret_conv;
36890 }
36891
36892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36893         LDKPeerHandleError orig_conv;
36894         orig_conv.inner = untag_ptr(orig);
36895         orig_conv.is_owned = ptr_is_owned(orig);
36896         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36897         orig_conv.is_owned = false;
36898         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
36899         int64_t ret_ref = 0;
36900         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36901         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36902         return ret_ref;
36903 }
36904
36905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36906         LDKPeerManager this_obj_conv;
36907         this_obj_conv.inner = untag_ptr(this_obj);
36908         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36910         PeerManager_free(this_obj_conv);
36911 }
36912
36913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new(JNIEnv *env, jclass clz, int64_t message_handler, int8_tArray our_node_secret, int8_tArray ephemeral_random_data, int64_t logger, int64_t custom_message_handler) {
36914         LDKMessageHandler message_handler_conv;
36915         message_handler_conv.inner = untag_ptr(message_handler);
36916         message_handler_conv.is_owned = ptr_is_owned(message_handler);
36917         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
36918         // WARNING: we need a move here but no clone is available for LDKMessageHandler
36919         
36920         LDKSecretKey our_node_secret_ref;
36921         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
36922         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
36923         unsigned char ephemeral_random_data_arr[32];
36924         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
36925         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
36926         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
36927         void* logger_ptr = untag_ptr(logger);
36928         CHECK_ACCESS(logger_ptr);
36929         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
36930         if (logger_conv.free == LDKLogger_JCalls_free) {
36931                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36932                 LDKLogger_JCalls_cloned(&logger_conv);
36933         }
36934         void* custom_message_handler_ptr = untag_ptr(custom_message_handler);
36935         CHECK_ACCESS(custom_message_handler_ptr);
36936         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
36937         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
36938                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36939                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
36940         }
36941         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
36942         int64_t ret_ref = 0;
36943         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36944         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36945         return ret_ref;
36946 }
36947
36948 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
36949         LDKPeerManager this_arg_conv;
36950         this_arg_conv.inner = untag_ptr(this_arg);
36951         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36953         this_arg_conv.is_owned = false;
36954         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
36955         jobjectArray ret_arr = NULL;
36956         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
36957         ;
36958         for (size_t i = 0; i < ret_var.datalen; i++) {
36959                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
36960                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
36961                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
36962         }
36963         
36964         FREE(ret_var.data);
36965         return ret_arr;
36966 }
36967
36968 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) {
36969         LDKPeerManager this_arg_conv;
36970         this_arg_conv.inner = untag_ptr(this_arg);
36971         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36973         this_arg_conv.is_owned = false;
36974         LDKPublicKey their_node_id_ref;
36975         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
36976         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
36977         void* descriptor_ptr = untag_ptr(descriptor);
36978         CHECK_ACCESS(descriptor_ptr);
36979         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
36980         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
36981                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36982                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
36983         }
36984         void* remote_network_address_ptr = untag_ptr(remote_network_address);
36985         CHECK_ACCESS(remote_network_address_ptr);
36986         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
36987         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
36988         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
36989         return tag_ptr(ret_conv, true);
36990 }
36991
36992 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) {
36993         LDKPeerManager this_arg_conv;
36994         this_arg_conv.inner = untag_ptr(this_arg);
36995         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36997         this_arg_conv.is_owned = false;
36998         void* descriptor_ptr = untag_ptr(descriptor);
36999         CHECK_ACCESS(descriptor_ptr);
37000         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
37001         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
37002                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37003                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
37004         }
37005         void* remote_network_address_ptr = untag_ptr(remote_network_address);
37006         CHECK_ACCESS(remote_network_address_ptr);
37007         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
37008         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
37009         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
37010         return tag_ptr(ret_conv, true);
37011 }
37012
37013 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) {
37014         LDKPeerManager this_arg_conv;
37015         this_arg_conv.inner = untag_ptr(this_arg);
37016         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37018         this_arg_conv.is_owned = false;
37019         void* descriptor_ptr = untag_ptr(descriptor);
37020         if (ptr_is_owned(descriptor)) { CHECK_ACCESS(descriptor_ptr); }
37021         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
37022         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
37023         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
37024         return tag_ptr(ret_conv, true);
37025 }
37026
37027 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) {
37028         LDKPeerManager this_arg_conv;
37029         this_arg_conv.inner = untag_ptr(this_arg);
37030         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37032         this_arg_conv.is_owned = false;
37033         void* peer_descriptor_ptr = untag_ptr(peer_descriptor);
37034         if (ptr_is_owned(peer_descriptor)) { CHECK_ACCESS(peer_descriptor_ptr); }
37035         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
37036         LDKu8slice data_ref;
37037         data_ref.datalen = (*env)->GetArrayLength(env, data);
37038         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
37039         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
37040         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
37041         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
37042         return tag_ptr(ret_conv, true);
37043 }
37044
37045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
37046         LDKPeerManager this_arg_conv;
37047         this_arg_conv.inner = untag_ptr(this_arg);
37048         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37050         this_arg_conv.is_owned = false;
37051         PeerManager_process_events(&this_arg_conv);
37052 }
37053
37054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
37055         LDKPeerManager this_arg_conv;
37056         this_arg_conv.inner = untag_ptr(this_arg);
37057         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37059         this_arg_conv.is_owned = false;
37060         void* descriptor_ptr = untag_ptr(descriptor);
37061         if (ptr_is_owned(descriptor)) { CHECK_ACCESS(descriptor_ptr); }
37062         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
37063         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
37064 }
37065
37066 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) {
37067         LDKPeerManager this_arg_conv;
37068         this_arg_conv.inner = untag_ptr(this_arg);
37069         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37071         this_arg_conv.is_owned = false;
37072         LDKPublicKey node_id_ref;
37073         CHECK((*env)->GetArrayLength(env, node_id) == 33);
37074         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
37075         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
37076 }
37077
37078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1all_1peers(JNIEnv *env, jclass clz, int64_t this_arg) {
37079         LDKPeerManager this_arg_conv;
37080         this_arg_conv.inner = untag_ptr(this_arg);
37081         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37083         this_arg_conv.is_owned = false;
37084         PeerManager_disconnect_all_peers(&this_arg_conv);
37085 }
37086
37087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
37088         LDKPeerManager this_arg_conv;
37089         this_arg_conv.inner = untag_ptr(this_arg);
37090         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37092         this_arg_conv.is_owned = false;
37093         PeerManager_timer_tick_occurred(&this_arg_conv);
37094 }
37095
37096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1success_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
37097         int64_t ret_conv = htlc_success_tx_weight(opt_anchors);
37098         return ret_conv;
37099 }
37100
37101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1timeout_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
37102         int64_t ret_conv = htlc_timeout_tx_weight(opt_anchors);
37103         return ret_conv;
37104 }
37105
37106 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
37107         unsigned char commitment_seed_arr[32];
37108         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
37109         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
37110         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
37111         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37112         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
37113         return ret_arr;
37114 }
37115
37116 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) {
37117         LDKCVec_u8Z to_holder_script_ref;
37118         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
37119         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
37120         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
37121         LDKCVec_u8Z to_counterparty_script_ref;
37122         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
37123         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
37124         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
37125         LDKOutPoint funding_outpoint_conv;
37126         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
37127         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
37128         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
37129         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
37130         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);
37131         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37132         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37133         Transaction_free(ret_var);
37134         return ret_arr;
37135 }
37136
37137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37138         LDKCounterpartyCommitmentSecrets this_obj_conv;
37139         this_obj_conv.inner = untag_ptr(this_obj);
37140         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37142         CounterpartyCommitmentSecrets_free(this_obj_conv);
37143 }
37144
37145 static inline uint64_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
37146         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
37147         int64_t ret_ref = 0;
37148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37149         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37150         return ret_ref;
37151 }
37152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37153         LDKCounterpartyCommitmentSecrets arg_conv;
37154         arg_conv.inner = untag_ptr(arg);
37155         arg_conv.is_owned = ptr_is_owned(arg);
37156         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37157         arg_conv.is_owned = false;
37158         int64_t ret_conv = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
37159         return ret_conv;
37160 }
37161
37162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37163         LDKCounterpartyCommitmentSecrets orig_conv;
37164         orig_conv.inner = untag_ptr(orig);
37165         orig_conv.is_owned = ptr_is_owned(orig);
37166         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37167         orig_conv.is_owned = false;
37168         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
37169         int64_t ret_ref = 0;
37170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37171         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37172         return ret_ref;
37173 }
37174
37175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1new(JNIEnv *env, jclass clz) {
37176         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
37177         int64_t ret_ref = 0;
37178         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37179         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37180         return ret_ref;
37181 }
37182
37183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1min_1seen_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
37184         LDKCounterpartyCommitmentSecrets this_arg_conv;
37185         this_arg_conv.inner = untag_ptr(this_arg);
37186         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37188         this_arg_conv.is_owned = false;
37189         int64_t ret_conv = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
37190         return ret_conv;
37191 }
37192
37193 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) {
37194         LDKCounterpartyCommitmentSecrets this_arg_conv;
37195         this_arg_conv.inner = untag_ptr(this_arg);
37196         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37198         this_arg_conv.is_owned = false;
37199         LDKThirtyTwoBytes secret_ref;
37200         CHECK((*env)->GetArrayLength(env, secret) == 32);
37201         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_ref.data);
37202         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
37203         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
37204         return tag_ptr(ret_conv, true);
37205 }
37206
37207 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
37208         LDKCounterpartyCommitmentSecrets this_arg_conv;
37209         this_arg_conv.inner = untag_ptr(this_arg);
37210         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37212         this_arg_conv.is_owned = false;
37213         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37214         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data);
37215         return ret_arr;
37216 }
37217
37218 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1write(JNIEnv *env, jclass clz, int64_t obj) {
37219         LDKCounterpartyCommitmentSecrets obj_conv;
37220         obj_conv.inner = untag_ptr(obj);
37221         obj_conv.is_owned = ptr_is_owned(obj);
37222         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37223         obj_conv.is_owned = false;
37224         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
37225         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37226         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37227         CVec_u8Z_free(ret_var);
37228         return ret_arr;
37229 }
37230
37231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37232         LDKu8slice ser_ref;
37233         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37234         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37235         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
37236         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
37237         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37238         return tag_ptr(ret_conv, true);
37239 }
37240
37241 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) {
37242         LDKPublicKey per_commitment_point_ref;
37243         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
37244         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
37245         unsigned char base_secret_arr[32];
37246         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
37247         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
37248         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
37249         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
37250         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
37251         return tag_ptr(ret_conv, true);
37252 }
37253
37254 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) {
37255         LDKPublicKey per_commitment_point_ref;
37256         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
37257         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
37258         LDKPublicKey base_point_ref;
37259         CHECK((*env)->GetArrayLength(env, base_point) == 33);
37260         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
37261         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
37262         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
37263         return tag_ptr(ret_conv, true);
37264 }
37265
37266 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) {
37267         unsigned char per_commitment_secret_arr[32];
37268         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
37269         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
37270         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
37271         unsigned char countersignatory_revocation_base_secret_arr[32];
37272         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
37273         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
37274         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
37275         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
37276         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
37277         return tag_ptr(ret_conv, true);
37278 }
37279
37280 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) {
37281         LDKPublicKey per_commitment_point_ref;
37282         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
37283         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
37284         LDKPublicKey countersignatory_revocation_base_point_ref;
37285         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
37286         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
37287         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
37288         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
37289         return tag_ptr(ret_conv, true);
37290 }
37291
37292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37293         LDKTxCreationKeys this_obj_conv;
37294         this_obj_conv.inner = untag_ptr(this_obj);
37295         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37297         TxCreationKeys_free(this_obj_conv);
37298 }
37299
37300 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
37301         LDKTxCreationKeys this_ptr_conv;
37302         this_ptr_conv.inner = untag_ptr(this_ptr);
37303         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37305         this_ptr_conv.is_owned = false;
37306         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37307         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
37308         return ret_arr;
37309 }
37310
37311 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37312         LDKTxCreationKeys this_ptr_conv;
37313         this_ptr_conv.inner = untag_ptr(this_ptr);
37314         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37316         this_ptr_conv.is_owned = false;
37317         LDKPublicKey val_ref;
37318         CHECK((*env)->GetArrayLength(env, val) == 33);
37319         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37320         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
37321 }
37322
37323 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
37324         LDKTxCreationKeys this_ptr_conv;
37325         this_ptr_conv.inner = untag_ptr(this_ptr);
37326         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37328         this_ptr_conv.is_owned = false;
37329         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37330         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
37331         return ret_arr;
37332 }
37333
37334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37335         LDKTxCreationKeys this_ptr_conv;
37336         this_ptr_conv.inner = untag_ptr(this_ptr);
37337         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37339         this_ptr_conv.is_owned = false;
37340         LDKPublicKey val_ref;
37341         CHECK((*env)->GetArrayLength(env, val) == 33);
37342         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37343         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
37344 }
37345
37346 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
37347         LDKTxCreationKeys this_ptr_conv;
37348         this_ptr_conv.inner = untag_ptr(this_ptr);
37349         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37351         this_ptr_conv.is_owned = false;
37352         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37353         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
37354         return ret_arr;
37355 }
37356
37357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37358         LDKTxCreationKeys this_ptr_conv;
37359         this_ptr_conv.inner = untag_ptr(this_ptr);
37360         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37362         this_ptr_conv.is_owned = false;
37363         LDKPublicKey val_ref;
37364         CHECK((*env)->GetArrayLength(env, val) == 33);
37365         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37366         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
37367 }
37368
37369 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
37370         LDKTxCreationKeys this_ptr_conv;
37371         this_ptr_conv.inner = untag_ptr(this_ptr);
37372         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37374         this_ptr_conv.is_owned = false;
37375         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37376         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
37377         return ret_arr;
37378 }
37379
37380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37381         LDKTxCreationKeys this_ptr_conv;
37382         this_ptr_conv.inner = untag_ptr(this_ptr);
37383         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37385         this_ptr_conv.is_owned = false;
37386         LDKPublicKey val_ref;
37387         CHECK((*env)->GetArrayLength(env, val) == 33);
37388         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37389         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
37390 }
37391
37392 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
37393         LDKTxCreationKeys this_ptr_conv;
37394         this_ptr_conv.inner = untag_ptr(this_ptr);
37395         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37397         this_ptr_conv.is_owned = false;
37398         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37399         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
37400         return ret_arr;
37401 }
37402
37403 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) {
37404         LDKTxCreationKeys this_ptr_conv;
37405         this_ptr_conv.inner = untag_ptr(this_ptr);
37406         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37408         this_ptr_conv.is_owned = false;
37409         LDKPublicKey val_ref;
37410         CHECK((*env)->GetArrayLength(env, val) == 33);
37411         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37412         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
37413 }
37414
37415 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) {
37416         LDKPublicKey per_commitment_point_arg_ref;
37417         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
37418         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
37419         LDKPublicKey revocation_key_arg_ref;
37420         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
37421         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
37422         LDKPublicKey broadcaster_htlc_key_arg_ref;
37423         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
37424         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
37425         LDKPublicKey countersignatory_htlc_key_arg_ref;
37426         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
37427         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
37428         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
37429         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
37430         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
37431         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);
37432         int64_t ret_ref = 0;
37433         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37434         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37435         return ret_ref;
37436 }
37437
37438 static inline uint64_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
37439         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
37440         int64_t ret_ref = 0;
37441         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37442         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37443         return ret_ref;
37444 }
37445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37446         LDKTxCreationKeys arg_conv;
37447         arg_conv.inner = untag_ptr(arg);
37448         arg_conv.is_owned = ptr_is_owned(arg);
37449         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37450         arg_conv.is_owned = false;
37451         int64_t ret_conv = TxCreationKeys_clone_ptr(&arg_conv);
37452         return ret_conv;
37453 }
37454
37455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37456         LDKTxCreationKeys orig_conv;
37457         orig_conv.inner = untag_ptr(orig);
37458         orig_conv.is_owned = ptr_is_owned(orig);
37459         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37460         orig_conv.is_owned = false;
37461         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
37462         int64_t ret_ref = 0;
37463         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37464         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37465         return ret_ref;
37466 }
37467
37468 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
37469         LDKTxCreationKeys obj_conv;
37470         obj_conv.inner = untag_ptr(obj);
37471         obj_conv.is_owned = ptr_is_owned(obj);
37472         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37473         obj_conv.is_owned = false;
37474         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
37475         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37476         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37477         CVec_u8Z_free(ret_var);
37478         return ret_arr;
37479 }
37480
37481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37482         LDKu8slice ser_ref;
37483         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37484         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37485         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
37486         *ret_conv = TxCreationKeys_read(ser_ref);
37487         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37488         return tag_ptr(ret_conv, true);
37489 }
37490
37491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37492         LDKChannelPublicKeys this_obj_conv;
37493         this_obj_conv.inner = untag_ptr(this_obj);
37494         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37496         ChannelPublicKeys_free(this_obj_conv);
37497 }
37498
37499 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
37500         LDKChannelPublicKeys this_ptr_conv;
37501         this_ptr_conv.inner = untag_ptr(this_ptr);
37502         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37504         this_ptr_conv.is_owned = false;
37505         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37506         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
37507         return ret_arr;
37508 }
37509
37510 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37511         LDKChannelPublicKeys this_ptr_conv;
37512         this_ptr_conv.inner = untag_ptr(this_ptr);
37513         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37515         this_ptr_conv.is_owned = false;
37516         LDKPublicKey val_ref;
37517         CHECK((*env)->GetArrayLength(env, val) == 33);
37518         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37519         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
37520 }
37521
37522 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
37523         LDKChannelPublicKeys this_ptr_conv;
37524         this_ptr_conv.inner = untag_ptr(this_ptr);
37525         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37527         this_ptr_conv.is_owned = false;
37528         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37529         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
37530         return ret_arr;
37531 }
37532
37533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37534         LDKChannelPublicKeys this_ptr_conv;
37535         this_ptr_conv.inner = untag_ptr(this_ptr);
37536         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37538         this_ptr_conv.is_owned = false;
37539         LDKPublicKey val_ref;
37540         CHECK((*env)->GetArrayLength(env, val) == 33);
37541         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37542         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
37543 }
37544
37545 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
37546         LDKChannelPublicKeys this_ptr_conv;
37547         this_ptr_conv.inner = untag_ptr(this_ptr);
37548         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37550         this_ptr_conv.is_owned = false;
37551         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37552         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
37553         return ret_arr;
37554 }
37555
37556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37557         LDKChannelPublicKeys this_ptr_conv;
37558         this_ptr_conv.inner = untag_ptr(this_ptr);
37559         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37561         this_ptr_conv.is_owned = false;
37562         LDKPublicKey val_ref;
37563         CHECK((*env)->GetArrayLength(env, val) == 33);
37564         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37565         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
37566 }
37567
37568 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
37569         LDKChannelPublicKeys this_ptr_conv;
37570         this_ptr_conv.inner = untag_ptr(this_ptr);
37571         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37573         this_ptr_conv.is_owned = false;
37574         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37575         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
37576         return ret_arr;
37577 }
37578
37579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37580         LDKChannelPublicKeys this_ptr_conv;
37581         this_ptr_conv.inner = untag_ptr(this_ptr);
37582         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37584         this_ptr_conv.is_owned = false;
37585         LDKPublicKey val_ref;
37586         CHECK((*env)->GetArrayLength(env, val) == 33);
37587         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37588         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
37589 }
37590
37591 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
37592         LDKChannelPublicKeys this_ptr_conv;
37593         this_ptr_conv.inner = untag_ptr(this_ptr);
37594         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37596         this_ptr_conv.is_owned = false;
37597         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37598         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
37599         return ret_arr;
37600 }
37601
37602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37603         LDKChannelPublicKeys this_ptr_conv;
37604         this_ptr_conv.inner = untag_ptr(this_ptr);
37605         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37607         this_ptr_conv.is_owned = false;
37608         LDKPublicKey val_ref;
37609         CHECK((*env)->GetArrayLength(env, val) == 33);
37610         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37611         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
37612 }
37613
37614 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) {
37615         LDKPublicKey funding_pubkey_arg_ref;
37616         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
37617         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
37618         LDKPublicKey revocation_basepoint_arg_ref;
37619         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
37620         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
37621         LDKPublicKey payment_point_arg_ref;
37622         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
37623         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
37624         LDKPublicKey delayed_payment_basepoint_arg_ref;
37625         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
37626         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
37627         LDKPublicKey htlc_basepoint_arg_ref;
37628         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
37629         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
37630         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);
37631         int64_t ret_ref = 0;
37632         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37633         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37634         return ret_ref;
37635 }
37636
37637 static inline uint64_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
37638         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
37639         int64_t ret_ref = 0;
37640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37641         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37642         return ret_ref;
37643 }
37644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37645         LDKChannelPublicKeys arg_conv;
37646         arg_conv.inner = untag_ptr(arg);
37647         arg_conv.is_owned = ptr_is_owned(arg);
37648         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37649         arg_conv.is_owned = false;
37650         int64_t ret_conv = ChannelPublicKeys_clone_ptr(&arg_conv);
37651         return ret_conv;
37652 }
37653
37654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37655         LDKChannelPublicKeys orig_conv;
37656         orig_conv.inner = untag_ptr(orig);
37657         orig_conv.is_owned = ptr_is_owned(orig);
37658         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37659         orig_conv.is_owned = false;
37660         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
37661         int64_t ret_ref = 0;
37662         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37663         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37664         return ret_ref;
37665 }
37666
37667 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
37668         LDKChannelPublicKeys obj_conv;
37669         obj_conv.inner = untag_ptr(obj);
37670         obj_conv.is_owned = ptr_is_owned(obj);
37671         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37672         obj_conv.is_owned = false;
37673         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
37674         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37675         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37676         CVec_u8Z_free(ret_var);
37677         return ret_arr;
37678 }
37679
37680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37681         LDKu8slice ser_ref;
37682         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37683         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37684         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
37685         *ret_conv = ChannelPublicKeys_read(ser_ref);
37686         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37687         return tag_ptr(ret_conv, true);
37688 }
37689
37690 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) {
37691         LDKPublicKey per_commitment_point_ref;
37692         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
37693         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
37694         LDKPublicKey broadcaster_delayed_payment_base_ref;
37695         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
37696         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
37697         LDKPublicKey broadcaster_htlc_base_ref;
37698         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
37699         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
37700         LDKPublicKey countersignatory_revocation_base_ref;
37701         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
37702         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
37703         LDKPublicKey countersignatory_htlc_base_ref;
37704         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
37705         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
37706         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
37707         *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);
37708         return tag_ptr(ret_conv, true);
37709 }
37710
37711 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) {
37712         LDKPublicKey per_commitment_point_ref;
37713         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
37714         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
37715         LDKChannelPublicKeys broadcaster_keys_conv;
37716         broadcaster_keys_conv.inner = untag_ptr(broadcaster_keys);
37717         broadcaster_keys_conv.is_owned = ptr_is_owned(broadcaster_keys);
37718         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
37719         broadcaster_keys_conv.is_owned = false;
37720         LDKChannelPublicKeys countersignatory_keys_conv;
37721         countersignatory_keys_conv.inner = untag_ptr(countersignatory_keys);
37722         countersignatory_keys_conv.is_owned = ptr_is_owned(countersignatory_keys);
37723         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
37724         countersignatory_keys_conv.is_owned = false;
37725         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
37726         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
37727         return tag_ptr(ret_conv, true);
37728 }
37729
37730 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) {
37731         LDKPublicKey revocation_key_ref;
37732         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
37733         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
37734         LDKPublicKey broadcaster_delayed_payment_key_ref;
37735         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
37736         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
37737         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
37738         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37739         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37740         CVec_u8Z_free(ret_var);
37741         return ret_arr;
37742 }
37743
37744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37745         LDKHTLCOutputInCommitment this_obj_conv;
37746         this_obj_conv.inner = untag_ptr(this_obj);
37747         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37749         HTLCOutputInCommitment_free(this_obj_conv);
37750 }
37751
37752 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
37753         LDKHTLCOutputInCommitment this_ptr_conv;
37754         this_ptr_conv.inner = untag_ptr(this_ptr);
37755         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37757         this_ptr_conv.is_owned = false;
37758         jboolean ret_conv = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
37759         return ret_conv;
37760 }
37761
37762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
37763         LDKHTLCOutputInCommitment this_ptr_conv;
37764         this_ptr_conv.inner = untag_ptr(this_ptr);
37765         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37767         this_ptr_conv.is_owned = false;
37768         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
37769 }
37770
37771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
37772         LDKHTLCOutputInCommitment this_ptr_conv;
37773         this_ptr_conv.inner = untag_ptr(this_ptr);
37774         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37776         this_ptr_conv.is_owned = false;
37777         int64_t ret_conv = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
37778         return ret_conv;
37779 }
37780
37781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37782         LDKHTLCOutputInCommitment this_ptr_conv;
37783         this_ptr_conv.inner = untag_ptr(this_ptr);
37784         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37786         this_ptr_conv.is_owned = false;
37787         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
37788 }
37789
37790 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
37791         LDKHTLCOutputInCommitment this_ptr_conv;
37792         this_ptr_conv.inner = untag_ptr(this_ptr);
37793         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37795         this_ptr_conv.is_owned = false;
37796         int32_t ret_conv = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
37797         return ret_conv;
37798 }
37799
37800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
37801         LDKHTLCOutputInCommitment this_ptr_conv;
37802         this_ptr_conv.inner = untag_ptr(this_ptr);
37803         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37805         this_ptr_conv.is_owned = false;
37806         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
37807 }
37808
37809 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
37810         LDKHTLCOutputInCommitment this_ptr_conv;
37811         this_ptr_conv.inner = untag_ptr(this_ptr);
37812         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37814         this_ptr_conv.is_owned = false;
37815         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37816         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
37817         return ret_arr;
37818 }
37819
37820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37821         LDKHTLCOutputInCommitment this_ptr_conv;
37822         this_ptr_conv.inner = untag_ptr(this_ptr);
37823         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37825         this_ptr_conv.is_owned = false;
37826         LDKThirtyTwoBytes val_ref;
37827         CHECK((*env)->GetArrayLength(env, val) == 32);
37828         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37829         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
37830 }
37831
37832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
37833         LDKHTLCOutputInCommitment this_ptr_conv;
37834         this_ptr_conv.inner = untag_ptr(this_ptr);
37835         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37837         this_ptr_conv.is_owned = false;
37838         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
37839         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
37840         int64_t ret_ref = tag_ptr(ret_copy, true);
37841         return ret_ref;
37842 }
37843
37844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37845         LDKHTLCOutputInCommitment this_ptr_conv;
37846         this_ptr_conv.inner = untag_ptr(this_ptr);
37847         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37849         this_ptr_conv.is_owned = false;
37850         void* val_ptr = untag_ptr(val);
37851         CHECK_ACCESS(val_ptr);
37852         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
37853         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
37854         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
37855 }
37856
37857 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) {
37858         LDKThirtyTwoBytes payment_hash_arg_ref;
37859         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
37860         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
37861         void* transaction_output_index_arg_ptr = untag_ptr(transaction_output_index_arg);
37862         CHECK_ACCESS(transaction_output_index_arg_ptr);
37863         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
37864         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(transaction_output_index_arg));
37865         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
37866         int64_t ret_ref = 0;
37867         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37868         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37869         return ret_ref;
37870 }
37871
37872 static inline uint64_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
37873         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
37874         int64_t ret_ref = 0;
37875         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37876         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37877         return ret_ref;
37878 }
37879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37880         LDKHTLCOutputInCommitment arg_conv;
37881         arg_conv.inner = untag_ptr(arg);
37882         arg_conv.is_owned = ptr_is_owned(arg);
37883         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37884         arg_conv.is_owned = false;
37885         int64_t ret_conv = HTLCOutputInCommitment_clone_ptr(&arg_conv);
37886         return ret_conv;
37887 }
37888
37889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37890         LDKHTLCOutputInCommitment orig_conv;
37891         orig_conv.inner = untag_ptr(orig);
37892         orig_conv.is_owned = ptr_is_owned(orig);
37893         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37894         orig_conv.is_owned = false;
37895         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
37896         int64_t ret_ref = 0;
37897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37898         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37899         return ret_ref;
37900 }
37901
37902 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
37903         LDKHTLCOutputInCommitment obj_conv;
37904         obj_conv.inner = untag_ptr(obj);
37905         obj_conv.is_owned = ptr_is_owned(obj);
37906         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37907         obj_conv.is_owned = false;
37908         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
37909         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37910         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37911         CVec_u8Z_free(ret_var);
37912         return ret_arr;
37913 }
37914
37915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37916         LDKu8slice ser_ref;
37917         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37918         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37919         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
37920         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
37921         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37922         return tag_ptr(ret_conv, true);
37923 }
37924
37925 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) {
37926         LDKHTLCOutputInCommitment htlc_conv;
37927         htlc_conv.inner = untag_ptr(htlc);
37928         htlc_conv.is_owned = ptr_is_owned(htlc);
37929         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
37930         htlc_conv.is_owned = false;
37931         LDKTxCreationKeys keys_conv;
37932         keys_conv.inner = untag_ptr(keys);
37933         keys_conv.is_owned = ptr_is_owned(keys);
37934         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
37935         keys_conv.is_owned = false;
37936         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
37937         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37938         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37939         CVec_u8Z_free(ret_var);
37940         return ret_arr;
37941 }
37942
37943 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
37944         LDKPublicKey broadcaster_ref;
37945         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
37946         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
37947         LDKPublicKey countersignatory_ref;
37948         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
37949         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
37950         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
37951         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37952         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37953         CVec_u8Z_free(ret_var);
37954         return ret_arr;
37955 }
37956
37957 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) {
37958         unsigned char commitment_txid_arr[32];
37959         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
37960         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
37961         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
37962         LDKHTLCOutputInCommitment htlc_conv;
37963         htlc_conv.inner = untag_ptr(htlc);
37964         htlc_conv.is_owned = ptr_is_owned(htlc);
37965         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
37966         htlc_conv.is_owned = false;
37967         LDKPublicKey broadcaster_delayed_payment_key_ref;
37968         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
37969         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
37970         LDKPublicKey revocation_key_ref;
37971         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
37972         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
37973         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);
37974         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37975         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37976         Transaction_free(ret_var);
37977         return ret_arr;
37978 }
37979
37980 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1anchor_1redeemscript(JNIEnv *env, jclass clz, int8_tArray funding_pubkey) {
37981         LDKPublicKey funding_pubkey_ref;
37982         CHECK((*env)->GetArrayLength(env, funding_pubkey) == 33);
37983         (*env)->GetByteArrayRegion(env, funding_pubkey, 0, 33, funding_pubkey_ref.compressed_form);
37984         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
37985         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37986         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37987         CVec_u8Z_free(ret_var);
37988         return ret_arr;
37989 }
37990
37991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37992         LDKChannelTransactionParameters this_obj_conv;
37993         this_obj_conv.inner = untag_ptr(this_obj);
37994         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37996         ChannelTransactionParameters_free(this_obj_conv);
37997 }
37998
37999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
38000         LDKChannelTransactionParameters this_ptr_conv;
38001         this_ptr_conv.inner = untag_ptr(this_ptr);
38002         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38004         this_ptr_conv.is_owned = false;
38005         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
38006         int64_t ret_ref = 0;
38007         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38008         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38009         return ret_ref;
38010 }
38011
38012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38013         LDKChannelTransactionParameters this_ptr_conv;
38014         this_ptr_conv.inner = untag_ptr(this_ptr);
38015         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38017         this_ptr_conv.is_owned = false;
38018         LDKChannelPublicKeys val_conv;
38019         val_conv.inner = untag_ptr(val);
38020         val_conv.is_owned = ptr_is_owned(val);
38021         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38022         val_conv = ChannelPublicKeys_clone(&val_conv);
38023         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
38024 }
38025
38026 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
38027         LDKChannelTransactionParameters this_ptr_conv;
38028         this_ptr_conv.inner = untag_ptr(this_ptr);
38029         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38031         this_ptr_conv.is_owned = false;
38032         int16_t ret_conv = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
38033         return ret_conv;
38034 }
38035
38036 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) {
38037         LDKChannelTransactionParameters this_ptr_conv;
38038         this_ptr_conv.inner = untag_ptr(this_ptr);
38039         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38041         this_ptr_conv.is_owned = false;
38042         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
38043 }
38044
38045 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
38046         LDKChannelTransactionParameters this_ptr_conv;
38047         this_ptr_conv.inner = untag_ptr(this_ptr);
38048         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38050         this_ptr_conv.is_owned = false;
38051         jboolean ret_conv = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
38052         return ret_conv;
38053 }
38054
38055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
38056         LDKChannelTransactionParameters this_ptr_conv;
38057         this_ptr_conv.inner = untag_ptr(this_ptr);
38058         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38060         this_ptr_conv.is_owned = false;
38061         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
38062 }
38063
38064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
38065         LDKChannelTransactionParameters this_ptr_conv;
38066         this_ptr_conv.inner = untag_ptr(this_ptr);
38067         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38069         this_ptr_conv.is_owned = false;
38070         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
38071         int64_t ret_ref = 0;
38072         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38073         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38074         return ret_ref;
38075 }
38076
38077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38078         LDKChannelTransactionParameters this_ptr_conv;
38079         this_ptr_conv.inner = untag_ptr(this_ptr);
38080         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38082         this_ptr_conv.is_owned = false;
38083         LDKCounterpartyChannelTransactionParameters val_conv;
38084         val_conv.inner = untag_ptr(val);
38085         val_conv.is_owned = ptr_is_owned(val);
38086         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38087         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
38088         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
38089 }
38090
38091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
38092         LDKChannelTransactionParameters this_ptr_conv;
38093         this_ptr_conv.inner = untag_ptr(this_ptr);
38094         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38096         this_ptr_conv.is_owned = false;
38097         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
38098         int64_t ret_ref = 0;
38099         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38100         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38101         return ret_ref;
38102 }
38103
38104 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38105         LDKChannelTransactionParameters this_ptr_conv;
38106         this_ptr_conv.inner = untag_ptr(this_ptr);
38107         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38109         this_ptr_conv.is_owned = false;
38110         LDKOutPoint val_conv;
38111         val_conv.inner = untag_ptr(val);
38112         val_conv.is_owned = ptr_is_owned(val);
38113         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38114         val_conv = OutPoint_clone(&val_conv);
38115         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
38116 }
38117
38118 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr) {
38119         LDKChannelTransactionParameters this_ptr_conv;
38120         this_ptr_conv.inner = untag_ptr(this_ptr);
38121         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38123         this_ptr_conv.is_owned = false;
38124         jclass ret_conv = LDKCOption_NoneZ_to_java(env, ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
38125         return ret_conv;
38126 }
38127
38128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
38129         LDKChannelTransactionParameters this_ptr_conv;
38130         this_ptr_conv.inner = untag_ptr(this_ptr);
38131         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38133         this_ptr_conv.is_owned = false;
38134         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_java(env, val);
38135         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
38136 }
38137
38138 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) {
38139         LDKChannelPublicKeys holder_pubkeys_arg_conv;
38140         holder_pubkeys_arg_conv.inner = untag_ptr(holder_pubkeys_arg);
38141         holder_pubkeys_arg_conv.is_owned = ptr_is_owned(holder_pubkeys_arg);
38142         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
38143         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
38144         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
38145         counterparty_parameters_arg_conv.inner = untag_ptr(counterparty_parameters_arg);
38146         counterparty_parameters_arg_conv.is_owned = ptr_is_owned(counterparty_parameters_arg);
38147         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
38148         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
38149         LDKOutPoint funding_outpoint_arg_conv;
38150         funding_outpoint_arg_conv.inner = untag_ptr(funding_outpoint_arg);
38151         funding_outpoint_arg_conv.is_owned = ptr_is_owned(funding_outpoint_arg);
38152         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
38153         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
38154         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_anchors_arg);
38155         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);
38156         int64_t ret_ref = 0;
38157         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38158         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38159         return ret_ref;
38160 }
38161
38162 static inline uint64_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
38163         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
38164         int64_t ret_ref = 0;
38165         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38166         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38167         return ret_ref;
38168 }
38169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38170         LDKChannelTransactionParameters arg_conv;
38171         arg_conv.inner = untag_ptr(arg);
38172         arg_conv.is_owned = ptr_is_owned(arg);
38173         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38174         arg_conv.is_owned = false;
38175         int64_t ret_conv = ChannelTransactionParameters_clone_ptr(&arg_conv);
38176         return ret_conv;
38177 }
38178
38179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38180         LDKChannelTransactionParameters orig_conv;
38181         orig_conv.inner = untag_ptr(orig);
38182         orig_conv.is_owned = ptr_is_owned(orig);
38183         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38184         orig_conv.is_owned = false;
38185         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
38186         int64_t ret_ref = 0;
38187         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38188         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38189         return ret_ref;
38190 }
38191
38192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38193         LDKCounterpartyChannelTransactionParameters this_obj_conv;
38194         this_obj_conv.inner = untag_ptr(this_obj);
38195         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38197         CounterpartyChannelTransactionParameters_free(this_obj_conv);
38198 }
38199
38200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
38201         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
38202         this_ptr_conv.inner = untag_ptr(this_ptr);
38203         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38205         this_ptr_conv.is_owned = false;
38206         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
38207         int64_t ret_ref = 0;
38208         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38209         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38210         return ret_ref;
38211 }
38212
38213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38214         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
38215         this_ptr_conv.inner = untag_ptr(this_ptr);
38216         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38218         this_ptr_conv.is_owned = false;
38219         LDKChannelPublicKeys val_conv;
38220         val_conv.inner = untag_ptr(val);
38221         val_conv.is_owned = ptr_is_owned(val);
38222         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38223         val_conv = ChannelPublicKeys_clone(&val_conv);
38224         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
38225 }
38226
38227 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
38228         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
38229         this_ptr_conv.inner = untag_ptr(this_ptr);
38230         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38232         this_ptr_conv.is_owned = false;
38233         int16_t ret_conv = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
38234         return ret_conv;
38235 }
38236
38237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
38238         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
38239         this_ptr_conv.inner = untag_ptr(this_ptr);
38240         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38242         this_ptr_conv.is_owned = false;
38243         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
38244 }
38245
38246 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) {
38247         LDKChannelPublicKeys pubkeys_arg_conv;
38248         pubkeys_arg_conv.inner = untag_ptr(pubkeys_arg);
38249         pubkeys_arg_conv.is_owned = ptr_is_owned(pubkeys_arg);
38250         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
38251         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
38252         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
38253         int64_t ret_ref = 0;
38254         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38255         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38256         return ret_ref;
38257 }
38258
38259 static inline uint64_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
38260         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
38261         int64_t ret_ref = 0;
38262         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38263         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38264         return ret_ref;
38265 }
38266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38267         LDKCounterpartyChannelTransactionParameters arg_conv;
38268         arg_conv.inner = untag_ptr(arg);
38269         arg_conv.is_owned = ptr_is_owned(arg);
38270         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38271         arg_conv.is_owned = false;
38272         int64_t ret_conv = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
38273         return ret_conv;
38274 }
38275
38276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38277         LDKCounterpartyChannelTransactionParameters orig_conv;
38278         orig_conv.inner = untag_ptr(orig);
38279         orig_conv.is_owned = ptr_is_owned(orig);
38280         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38281         orig_conv.is_owned = false;
38282         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
38283         int64_t ret_ref = 0;
38284         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38285         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38286         return ret_ref;
38287 }
38288
38289 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
38290         LDKChannelTransactionParameters this_arg_conv;
38291         this_arg_conv.inner = untag_ptr(this_arg);
38292         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38294         this_arg_conv.is_owned = false;
38295         jboolean ret_conv = ChannelTransactionParameters_is_populated(&this_arg_conv);
38296         return ret_conv;
38297 }
38298
38299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
38300         LDKChannelTransactionParameters this_arg_conv;
38301         this_arg_conv.inner = untag_ptr(this_arg);
38302         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38304         this_arg_conv.is_owned = false;
38305         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
38306         int64_t ret_ref = 0;
38307         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38308         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38309         return ret_ref;
38310 }
38311
38312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
38313         LDKChannelTransactionParameters this_arg_conv;
38314         this_arg_conv.inner = untag_ptr(this_arg);
38315         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38317         this_arg_conv.is_owned = false;
38318         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
38319         int64_t ret_ref = 0;
38320         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38321         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38322         return ret_ref;
38323 }
38324
38325 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
38326         LDKCounterpartyChannelTransactionParameters obj_conv;
38327         obj_conv.inner = untag_ptr(obj);
38328         obj_conv.is_owned = ptr_is_owned(obj);
38329         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38330         obj_conv.is_owned = false;
38331         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
38332         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38333         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38334         CVec_u8Z_free(ret_var);
38335         return ret_arr;
38336 }
38337
38338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38339         LDKu8slice ser_ref;
38340         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38341         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38342         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
38343         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
38344         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38345         return tag_ptr(ret_conv, true);
38346 }
38347
38348 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
38349         LDKChannelTransactionParameters obj_conv;
38350         obj_conv.inner = untag_ptr(obj);
38351         obj_conv.is_owned = ptr_is_owned(obj);
38352         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38353         obj_conv.is_owned = false;
38354         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
38355         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38356         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38357         CVec_u8Z_free(ret_var);
38358         return ret_arr;
38359 }
38360
38361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38362         LDKu8slice ser_ref;
38363         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38364         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38365         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
38366         *ret_conv = ChannelTransactionParameters_read(ser_ref);
38367         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38368         return tag_ptr(ret_conv, true);
38369 }
38370
38371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38372         LDKDirectedChannelTransactionParameters this_obj_conv;
38373         this_obj_conv.inner = untag_ptr(this_obj);
38374         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38376         DirectedChannelTransactionParameters_free(this_obj_conv);
38377 }
38378
38379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
38380         LDKDirectedChannelTransactionParameters this_arg_conv;
38381         this_arg_conv.inner = untag_ptr(this_arg);
38382         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38384         this_arg_conv.is_owned = false;
38385         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
38386         int64_t ret_ref = 0;
38387         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38388         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38389         return ret_ref;
38390 }
38391
38392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
38393         LDKDirectedChannelTransactionParameters this_arg_conv;
38394         this_arg_conv.inner = untag_ptr(this_arg);
38395         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38397         this_arg_conv.is_owned = false;
38398         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
38399         int64_t ret_ref = 0;
38400         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38401         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38402         return ret_ref;
38403 }
38404
38405 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
38406         LDKDirectedChannelTransactionParameters this_arg_conv;
38407         this_arg_conv.inner = untag_ptr(this_arg);
38408         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38410         this_arg_conv.is_owned = false;
38411         int16_t ret_conv = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
38412         return ret_conv;
38413 }
38414
38415 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
38416         LDKDirectedChannelTransactionParameters this_arg_conv;
38417         this_arg_conv.inner = untag_ptr(this_arg);
38418         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38420         this_arg_conv.is_owned = false;
38421         jboolean ret_conv = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
38422         return ret_conv;
38423 }
38424
38425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
38426         LDKDirectedChannelTransactionParameters this_arg_conv;
38427         this_arg_conv.inner = untag_ptr(this_arg);
38428         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38430         this_arg_conv.is_owned = false;
38431         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
38432         int64_t ret_ref = 0;
38433         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38434         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38435         return ret_ref;
38436 }
38437
38438 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
38439         LDKDirectedChannelTransactionParameters this_arg_conv;
38440         this_arg_conv.inner = untag_ptr(this_arg);
38441         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38443         this_arg_conv.is_owned = false;
38444         jboolean ret_conv = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
38445         return ret_conv;
38446 }
38447
38448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38449         LDKHolderCommitmentTransaction this_obj_conv;
38450         this_obj_conv.inner = untag_ptr(this_obj);
38451         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38453         HolderCommitmentTransaction_free(this_obj_conv);
38454 }
38455
38456 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
38457         LDKHolderCommitmentTransaction this_ptr_conv;
38458         this_ptr_conv.inner = untag_ptr(this_ptr);
38459         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38461         this_ptr_conv.is_owned = false;
38462         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38463         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
38464         return ret_arr;
38465 }
38466
38467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38468         LDKHolderCommitmentTransaction this_ptr_conv;
38469         this_ptr_conv.inner = untag_ptr(this_ptr);
38470         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38472         this_ptr_conv.is_owned = false;
38473         LDKSignature val_ref;
38474         CHECK((*env)->GetArrayLength(env, val) == 64);
38475         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38476         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
38477 }
38478
38479 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr) {
38480         LDKHolderCommitmentTransaction this_ptr_conv;
38481         this_ptr_conv.inner = untag_ptr(this_ptr);
38482         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38484         this_ptr_conv.is_owned = false;
38485         LDKCVec_SignatureZ ret_var = HolderCommitmentTransaction_get_counterparty_htlc_sigs(&this_ptr_conv);
38486         jobjectArray ret_arr = NULL;
38487         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
38488         ;
38489         for (size_t i = 0; i < ret_var.datalen; i++) {
38490                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
38491                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
38492                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
38493         }
38494         
38495         FREE(ret_var.data);
38496         return ret_arr;
38497 }
38498
38499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
38500         LDKHolderCommitmentTransaction this_ptr_conv;
38501         this_ptr_conv.inner = untag_ptr(this_ptr);
38502         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38504         this_ptr_conv.is_owned = false;
38505         LDKCVec_SignatureZ val_constr;
38506         val_constr.datalen = (*env)->GetArrayLength(env, val);
38507         if (val_constr.datalen > 0)
38508                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
38509         else
38510                 val_constr.data = NULL;
38511         for (size_t i = 0; i < val_constr.datalen; i++) {
38512                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
38513                 LDKSignature val_conv_8_ref;
38514                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
38515                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
38516                 val_constr.data[i] = val_conv_8_ref;
38517         }
38518         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
38519 }
38520
38521 static inline uint64_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
38522         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
38523         int64_t ret_ref = 0;
38524         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38525         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38526         return ret_ref;
38527 }
38528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38529         LDKHolderCommitmentTransaction arg_conv;
38530         arg_conv.inner = untag_ptr(arg);
38531         arg_conv.is_owned = ptr_is_owned(arg);
38532         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38533         arg_conv.is_owned = false;
38534         int64_t ret_conv = HolderCommitmentTransaction_clone_ptr(&arg_conv);
38535         return ret_conv;
38536 }
38537
38538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38539         LDKHolderCommitmentTransaction orig_conv;
38540         orig_conv.inner = untag_ptr(orig);
38541         orig_conv.is_owned = ptr_is_owned(orig);
38542         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38543         orig_conv.is_owned = false;
38544         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
38545         int64_t ret_ref = 0;
38546         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38547         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38548         return ret_ref;
38549 }
38550
38551 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
38552         LDKHolderCommitmentTransaction obj_conv;
38553         obj_conv.inner = untag_ptr(obj);
38554         obj_conv.is_owned = ptr_is_owned(obj);
38555         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38556         obj_conv.is_owned = false;
38557         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
38558         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38559         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38560         CVec_u8Z_free(ret_var);
38561         return ret_arr;
38562 }
38563
38564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38565         LDKu8slice ser_ref;
38566         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38567         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38568         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
38569         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
38570         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38571         return tag_ptr(ret_conv, true);
38572 }
38573
38574 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) {
38575         LDKCommitmentTransaction commitment_tx_conv;
38576         commitment_tx_conv.inner = untag_ptr(commitment_tx);
38577         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
38578         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
38579         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
38580         LDKSignature counterparty_sig_ref;
38581         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
38582         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
38583         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
38584         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
38585         if (counterparty_htlc_sigs_constr.datalen > 0)
38586                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
38587         else
38588                 counterparty_htlc_sigs_constr.data = NULL;
38589         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
38590                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
38591                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
38592                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
38593                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
38594                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
38595         }
38596         LDKPublicKey holder_funding_key_ref;
38597         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
38598         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
38599         LDKPublicKey counterparty_funding_key_ref;
38600         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
38601         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
38602         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
38603         int64_t ret_ref = 0;
38604         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38605         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38606         return ret_ref;
38607 }
38608
38609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38610         LDKBuiltCommitmentTransaction this_obj_conv;
38611         this_obj_conv.inner = untag_ptr(this_obj);
38612         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38614         BuiltCommitmentTransaction_free(this_obj_conv);
38615 }
38616
38617 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
38618         LDKBuiltCommitmentTransaction this_ptr_conv;
38619         this_ptr_conv.inner = untag_ptr(this_ptr);
38620         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38622         this_ptr_conv.is_owned = false;
38623         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
38624         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38625         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38626         Transaction_free(ret_var);
38627         return ret_arr;
38628 }
38629
38630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38631         LDKBuiltCommitmentTransaction this_ptr_conv;
38632         this_ptr_conv.inner = untag_ptr(this_ptr);
38633         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38635         this_ptr_conv.is_owned = false;
38636         LDKTransaction val_ref;
38637         val_ref.datalen = (*env)->GetArrayLength(env, val);
38638         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
38639         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
38640         val_ref.data_is_owned = true;
38641         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
38642 }
38643
38644 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
38645         LDKBuiltCommitmentTransaction this_ptr_conv;
38646         this_ptr_conv.inner = untag_ptr(this_ptr);
38647         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38649         this_ptr_conv.is_owned = false;
38650         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38651         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
38652         return ret_arr;
38653 }
38654
38655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38656         LDKBuiltCommitmentTransaction this_ptr_conv;
38657         this_ptr_conv.inner = untag_ptr(this_ptr);
38658         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38660         this_ptr_conv.is_owned = false;
38661         LDKThirtyTwoBytes val_ref;
38662         CHECK((*env)->GetArrayLength(env, val) == 32);
38663         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
38664         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
38665 }
38666
38667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
38668         LDKTransaction transaction_arg_ref;
38669         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
38670         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
38671         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
38672         transaction_arg_ref.data_is_owned = true;
38673         LDKThirtyTwoBytes txid_arg_ref;
38674         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
38675         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
38676         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
38677         int64_t ret_ref = 0;
38678         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38679         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38680         return ret_ref;
38681 }
38682
38683 static inline uint64_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
38684         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
38685         int64_t ret_ref = 0;
38686         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38687         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38688         return ret_ref;
38689 }
38690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38691         LDKBuiltCommitmentTransaction arg_conv;
38692         arg_conv.inner = untag_ptr(arg);
38693         arg_conv.is_owned = ptr_is_owned(arg);
38694         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38695         arg_conv.is_owned = false;
38696         int64_t ret_conv = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
38697         return ret_conv;
38698 }
38699
38700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38701         LDKBuiltCommitmentTransaction orig_conv;
38702         orig_conv.inner = untag_ptr(orig);
38703         orig_conv.is_owned = ptr_is_owned(orig);
38704         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38705         orig_conv.is_owned = false;
38706         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
38707         int64_t ret_ref = 0;
38708         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38709         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38710         return ret_ref;
38711 }
38712
38713 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
38714         LDKBuiltCommitmentTransaction obj_conv;
38715         obj_conv.inner = untag_ptr(obj);
38716         obj_conv.is_owned = ptr_is_owned(obj);
38717         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38718         obj_conv.is_owned = false;
38719         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
38720         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38721         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38722         CVec_u8Z_free(ret_var);
38723         return ret_arr;
38724 }
38725
38726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38727         LDKu8slice ser_ref;
38728         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38729         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38730         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
38731         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
38732         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38733         return tag_ptr(ret_conv, true);
38734 }
38735
38736 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) {
38737         LDKBuiltCommitmentTransaction this_arg_conv;
38738         this_arg_conv.inner = untag_ptr(this_arg);
38739         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38741         this_arg_conv.is_owned = false;
38742         LDKu8slice funding_redeemscript_ref;
38743         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
38744         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
38745         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38746         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
38747         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
38748         return ret_arr;
38749 }
38750
38751 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) {
38752         LDKBuiltCommitmentTransaction this_arg_conv;
38753         this_arg_conv.inner = untag_ptr(this_arg);
38754         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38756         this_arg_conv.is_owned = false;
38757         unsigned char funding_key_arr[32];
38758         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
38759         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
38760         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
38761         LDKu8slice funding_redeemscript_ref;
38762         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
38763         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
38764         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38765         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
38766         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
38767         return ret_arr;
38768 }
38769
38770 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38771         LDKClosingTransaction this_obj_conv;
38772         this_obj_conv.inner = untag_ptr(this_obj);
38773         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38775         ClosingTransaction_free(this_obj_conv);
38776 }
38777
38778 static inline uint64_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
38779         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
38780         int64_t ret_ref = 0;
38781         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38782         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38783         return ret_ref;
38784 }
38785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38786         LDKClosingTransaction arg_conv;
38787         arg_conv.inner = untag_ptr(arg);
38788         arg_conv.is_owned = ptr_is_owned(arg);
38789         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38790         arg_conv.is_owned = false;
38791         int64_t ret_conv = ClosingTransaction_clone_ptr(&arg_conv);
38792         return ret_conv;
38793 }
38794
38795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38796         LDKClosingTransaction orig_conv;
38797         orig_conv.inner = untag_ptr(orig);
38798         orig_conv.is_owned = ptr_is_owned(orig);
38799         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38800         orig_conv.is_owned = false;
38801         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
38802         int64_t ret_ref = 0;
38803         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38804         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38805         return ret_ref;
38806 }
38807
38808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1hash(JNIEnv *env, jclass clz, int64_t o) {
38809         LDKClosingTransaction o_conv;
38810         o_conv.inner = untag_ptr(o);
38811         o_conv.is_owned = ptr_is_owned(o);
38812         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38813         o_conv.is_owned = false;
38814         int64_t ret_conv = ClosingTransaction_hash(&o_conv);
38815         return ret_conv;
38816 }
38817
38818 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) {
38819         LDKCVec_u8Z to_holder_script_ref;
38820         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
38821         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
38822         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
38823         LDKCVec_u8Z to_counterparty_script_ref;
38824         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
38825         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
38826         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
38827         LDKOutPoint funding_outpoint_conv;
38828         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
38829         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
38830         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
38831         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
38832         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
38833         int64_t ret_ref = 0;
38834         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38835         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38836         return ret_ref;
38837 }
38838
38839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
38840         LDKClosingTransaction this_arg_conv;
38841         this_arg_conv.inner = untag_ptr(this_arg);
38842         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38844         this_arg_conv.is_owned = false;
38845         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
38846         int64_t ret_ref = 0;
38847         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38848         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38849         return ret_ref;
38850 }
38851
38852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) {
38853         LDKClosingTransaction this_arg_conv;
38854         this_arg_conv.inner = untag_ptr(this_arg);
38855         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38857         this_arg_conv.is_owned = false;
38858         LDKOutPoint funding_outpoint_conv;
38859         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
38860         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
38861         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
38862         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
38863         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
38864         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
38865         return tag_ptr(ret_conv, true);
38866 }
38867
38868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
38869         LDKClosingTransaction this_arg_conv;
38870         this_arg_conv.inner = untag_ptr(this_arg);
38871         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38873         this_arg_conv.is_owned = false;
38874         int64_t ret_conv = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
38875         return ret_conv;
38876 }
38877
38878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
38879         LDKClosingTransaction this_arg_conv;
38880         this_arg_conv.inner = untag_ptr(this_arg);
38881         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38883         this_arg_conv.is_owned = false;
38884         int64_t ret_conv = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
38885         return ret_conv;
38886 }
38887
38888 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
38889         LDKClosingTransaction this_arg_conv;
38890         this_arg_conv.inner = untag_ptr(this_arg);
38891         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38893         this_arg_conv.is_owned = false;
38894         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
38895         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38896         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38897         return ret_arr;
38898 }
38899
38900 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
38901         LDKClosingTransaction this_arg_conv;
38902         this_arg_conv.inner = untag_ptr(this_arg);
38903         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38905         this_arg_conv.is_owned = false;
38906         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
38907         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38908         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38909         return ret_arr;
38910 }
38911
38912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38913         LDKTrustedClosingTransaction this_obj_conv;
38914         this_obj_conv.inner = untag_ptr(this_obj);
38915         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38917         TrustedClosingTransaction_free(this_obj_conv);
38918 }
38919
38920 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
38921         LDKTrustedClosingTransaction this_arg_conv;
38922         this_arg_conv.inner = untag_ptr(this_arg);
38923         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38925         this_arg_conv.is_owned = false;
38926         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
38927         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38928         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38929         Transaction_free(ret_var);
38930         return ret_arr;
38931 }
38932
38933 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) {
38934         LDKTrustedClosingTransaction this_arg_conv;
38935         this_arg_conv.inner = untag_ptr(this_arg);
38936         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38938         this_arg_conv.is_owned = false;
38939         LDKu8slice funding_redeemscript_ref;
38940         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
38941         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
38942         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38943         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
38944         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
38945         return ret_arr;
38946 }
38947
38948 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) {
38949         LDKTrustedClosingTransaction this_arg_conv;
38950         this_arg_conv.inner = untag_ptr(this_arg);
38951         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38953         this_arg_conv.is_owned = false;
38954         unsigned char funding_key_arr[32];
38955         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
38956         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
38957         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
38958         LDKu8slice funding_redeemscript_ref;
38959         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
38960         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
38961         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38962         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
38963         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
38964         return ret_arr;
38965 }
38966
38967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38968         LDKCommitmentTransaction this_obj_conv;
38969         this_obj_conv.inner = untag_ptr(this_obj);
38970         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38972         CommitmentTransaction_free(this_obj_conv);
38973 }
38974
38975 static inline uint64_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
38976         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
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 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38983         LDKCommitmentTransaction arg_conv;
38984         arg_conv.inner = untag_ptr(arg);
38985         arg_conv.is_owned = ptr_is_owned(arg);
38986         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38987         arg_conv.is_owned = false;
38988         int64_t ret_conv = CommitmentTransaction_clone_ptr(&arg_conv);
38989         return ret_conv;
38990 }
38991
38992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38993         LDKCommitmentTransaction orig_conv;
38994         orig_conv.inner = untag_ptr(orig);
38995         orig_conv.is_owned = ptr_is_owned(orig);
38996         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38997         orig_conv.is_owned = false;
38998         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
38999         int64_t ret_ref = 0;
39000         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39001         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39002         return ret_ref;
39003 }
39004
39005 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
39006         LDKCommitmentTransaction obj_conv;
39007         obj_conv.inner = untag_ptr(obj);
39008         obj_conv.is_owned = ptr_is_owned(obj);
39009         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39010         obj_conv.is_owned = false;
39011         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
39012         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39013         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39014         CVec_u8Z_free(ret_var);
39015         return ret_arr;
39016 }
39017
39018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39019         LDKu8slice ser_ref;
39020         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39021         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39022         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
39023         *ret_conv = CommitmentTransaction_read(ser_ref);
39024         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39025         return tag_ptr(ret_conv, true);
39026 }
39027
39028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
39029         LDKCommitmentTransaction this_arg_conv;
39030         this_arg_conv.inner = untag_ptr(this_arg);
39031         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39033         this_arg_conv.is_owned = false;
39034         int64_t ret_conv = CommitmentTransaction_commitment_number(&this_arg_conv);
39035         return ret_conv;
39036 }
39037
39038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
39039         LDKCommitmentTransaction this_arg_conv;
39040         this_arg_conv.inner = untag_ptr(this_arg);
39041         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39043         this_arg_conv.is_owned = false;
39044         int64_t ret_conv = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
39045         return ret_conv;
39046 }
39047
39048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
39049         LDKCommitmentTransaction 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         int64_t ret_conv = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
39055         return ret_conv;
39056 }
39057
39058 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
39059         LDKCommitmentTransaction this_arg_conv;
39060         this_arg_conv.inner = untag_ptr(this_arg);
39061         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39063         this_arg_conv.is_owned = false;
39064         int32_t ret_conv = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
39065         return ret_conv;
39066 }
39067
39068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
39069         LDKCommitmentTransaction this_arg_conv;
39070         this_arg_conv.inner = untag_ptr(this_arg);
39071         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39073         this_arg_conv.is_owned = false;
39074         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
39075         int64_t ret_ref = 0;
39076         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39077         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39078         return ret_ref;
39079 }
39080
39081 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) {
39082         LDKCommitmentTransaction this_arg_conv;
39083         this_arg_conv.inner = untag_ptr(this_arg);
39084         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39086         this_arg_conv.is_owned = false;
39087         LDKDirectedChannelTransactionParameters channel_parameters_conv;
39088         channel_parameters_conv.inner = untag_ptr(channel_parameters);
39089         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
39090         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
39091         channel_parameters_conv.is_owned = false;
39092         LDKChannelPublicKeys broadcaster_keys_conv;
39093         broadcaster_keys_conv.inner = untag_ptr(broadcaster_keys);
39094         broadcaster_keys_conv.is_owned = ptr_is_owned(broadcaster_keys);
39095         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
39096         broadcaster_keys_conv.is_owned = false;
39097         LDKChannelPublicKeys countersignatory_keys_conv;
39098         countersignatory_keys_conv.inner = untag_ptr(countersignatory_keys);
39099         countersignatory_keys_conv.is_owned = ptr_is_owned(countersignatory_keys);
39100         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
39101         countersignatory_keys_conv.is_owned = false;
39102         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
39103         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
39104         return tag_ptr(ret_conv, true);
39105 }
39106
39107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39108         LDKTrustedCommitmentTransaction this_obj_conv;
39109         this_obj_conv.inner = untag_ptr(this_obj);
39110         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39112         TrustedCommitmentTransaction_free(this_obj_conv);
39113 }
39114
39115 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
39116         LDKTrustedCommitmentTransaction this_arg_conv;
39117         this_arg_conv.inner = untag_ptr(this_arg);
39118         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39120         this_arg_conv.is_owned = false;
39121         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39122         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
39123         return ret_arr;
39124 }
39125
39126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
39127         LDKTrustedCommitmentTransaction this_arg_conv;
39128         this_arg_conv.inner = untag_ptr(this_arg);
39129         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39131         this_arg_conv.is_owned = false;
39132         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
39133         int64_t ret_ref = 0;
39134         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39135         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39136         return ret_ref;
39137 }
39138
39139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
39140         LDKTrustedCommitmentTransaction this_arg_conv;
39141         this_arg_conv.inner = untag_ptr(this_arg);
39142         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39144         this_arg_conv.is_owned = false;
39145         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
39146         int64_t ret_ref = 0;
39147         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39148         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39149         return ret_ref;
39150 }
39151
39152 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
39153         LDKTrustedCommitmentTransaction this_arg_conv;
39154         this_arg_conv.inner = untag_ptr(this_arg);
39155         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39157         this_arg_conv.is_owned = false;
39158         jboolean ret_conv = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
39159         return ret_conv;
39160 }
39161
39162 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) {
39163         LDKTrustedCommitmentTransaction this_arg_conv;
39164         this_arg_conv.inner = untag_ptr(this_arg);
39165         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39167         this_arg_conv.is_owned = false;
39168         unsigned char htlc_base_key_arr[32];
39169         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
39170         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
39171         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
39172         LDKDirectedChannelTransactionParameters channel_parameters_conv;
39173         channel_parameters_conv.inner = untag_ptr(channel_parameters);
39174         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
39175         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
39176         channel_parameters_conv.is_owned = false;
39177         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
39178         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
39179         return tag_ptr(ret_conv, true);
39180 }
39181
39182 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) {
39183         LDKPublicKey broadcaster_payment_basepoint_ref;
39184         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
39185         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
39186         LDKPublicKey countersignatory_payment_basepoint_ref;
39187         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
39188         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
39189         int64_t ret_conv = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
39190         return ret_conv;
39191 }
39192
39193 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39194         LDKInitFeatures a_conv;
39195         a_conv.inner = untag_ptr(a);
39196         a_conv.is_owned = ptr_is_owned(a);
39197         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39198         a_conv.is_owned = false;
39199         LDKInitFeatures b_conv;
39200         b_conv.inner = untag_ptr(b);
39201         b_conv.is_owned = ptr_is_owned(b);
39202         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39203         b_conv.is_owned = false;
39204         jboolean ret_conv = InitFeatures_eq(&a_conv, &b_conv);
39205         return ret_conv;
39206 }
39207
39208 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39209         LDKNodeFeatures a_conv;
39210         a_conv.inner = untag_ptr(a);
39211         a_conv.is_owned = ptr_is_owned(a);
39212         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39213         a_conv.is_owned = false;
39214         LDKNodeFeatures b_conv;
39215         b_conv.inner = untag_ptr(b);
39216         b_conv.is_owned = ptr_is_owned(b);
39217         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39218         b_conv.is_owned = false;
39219         jboolean ret_conv = NodeFeatures_eq(&a_conv, &b_conv);
39220         return ret_conv;
39221 }
39222
39223 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39224         LDKChannelFeatures a_conv;
39225         a_conv.inner = untag_ptr(a);
39226         a_conv.is_owned = ptr_is_owned(a);
39227         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39228         a_conv.is_owned = false;
39229         LDKChannelFeatures b_conv;
39230         b_conv.inner = untag_ptr(b);
39231         b_conv.is_owned = ptr_is_owned(b);
39232         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39233         b_conv.is_owned = false;
39234         jboolean ret_conv = ChannelFeatures_eq(&a_conv, &b_conv);
39235         return ret_conv;
39236 }
39237
39238 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39239         LDKInvoiceFeatures a_conv;
39240         a_conv.inner = untag_ptr(a);
39241         a_conv.is_owned = ptr_is_owned(a);
39242         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39243         a_conv.is_owned = false;
39244         LDKInvoiceFeatures b_conv;
39245         b_conv.inner = untag_ptr(b);
39246         b_conv.is_owned = ptr_is_owned(b);
39247         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39248         b_conv.is_owned = false;
39249         jboolean ret_conv = InvoiceFeatures_eq(&a_conv, &b_conv);
39250         return ret_conv;
39251 }
39252
39253 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39254         LDKChannelTypeFeatures a_conv;
39255         a_conv.inner = untag_ptr(a);
39256         a_conv.is_owned = ptr_is_owned(a);
39257         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39258         a_conv.is_owned = false;
39259         LDKChannelTypeFeatures b_conv;
39260         b_conv.inner = untag_ptr(b);
39261         b_conv.is_owned = ptr_is_owned(b);
39262         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39263         b_conv.is_owned = false;
39264         jboolean ret_conv = ChannelTypeFeatures_eq(&a_conv, &b_conv);
39265         return ret_conv;
39266 }
39267
39268 static inline uint64_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
39269         LDKInitFeatures ret_var = InitFeatures_clone(arg);
39270         int64_t ret_ref = 0;
39271         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39272         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39273         return ret_ref;
39274 }
39275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39276         LDKInitFeatures arg_conv;
39277         arg_conv.inner = untag_ptr(arg);
39278         arg_conv.is_owned = ptr_is_owned(arg);
39279         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39280         arg_conv.is_owned = false;
39281         int64_t ret_conv = InitFeatures_clone_ptr(&arg_conv);
39282         return ret_conv;
39283 }
39284
39285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39286         LDKInitFeatures orig_conv;
39287         orig_conv.inner = untag_ptr(orig);
39288         orig_conv.is_owned = ptr_is_owned(orig);
39289         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39290         orig_conv.is_owned = false;
39291         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
39292         int64_t ret_ref = 0;
39293         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39294         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39295         return ret_ref;
39296 }
39297
39298 static inline uint64_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
39299         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
39300         int64_t ret_ref = 0;
39301         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39302         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39303         return ret_ref;
39304 }
39305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39306         LDKNodeFeatures arg_conv;
39307         arg_conv.inner = untag_ptr(arg);
39308         arg_conv.is_owned = ptr_is_owned(arg);
39309         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39310         arg_conv.is_owned = false;
39311         int64_t ret_conv = NodeFeatures_clone_ptr(&arg_conv);
39312         return ret_conv;
39313 }
39314
39315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39316         LDKNodeFeatures orig_conv;
39317         orig_conv.inner = untag_ptr(orig);
39318         orig_conv.is_owned = ptr_is_owned(orig);
39319         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39320         orig_conv.is_owned = false;
39321         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
39322         int64_t ret_ref = 0;
39323         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39324         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39325         return ret_ref;
39326 }
39327
39328 static inline uint64_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
39329         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
39330         int64_t ret_ref = 0;
39331         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39332         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39333         return ret_ref;
39334 }
39335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39336         LDKChannelFeatures arg_conv;
39337         arg_conv.inner = untag_ptr(arg);
39338         arg_conv.is_owned = ptr_is_owned(arg);
39339         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39340         arg_conv.is_owned = false;
39341         int64_t ret_conv = ChannelFeatures_clone_ptr(&arg_conv);
39342         return ret_conv;
39343 }
39344
39345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39346         LDKChannelFeatures orig_conv;
39347         orig_conv.inner = untag_ptr(orig);
39348         orig_conv.is_owned = ptr_is_owned(orig);
39349         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39350         orig_conv.is_owned = false;
39351         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
39352         int64_t ret_ref = 0;
39353         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39354         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39355         return ret_ref;
39356 }
39357
39358 static inline uint64_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
39359         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
39360         int64_t ret_ref = 0;
39361         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39362         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39363         return ret_ref;
39364 }
39365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39366         LDKInvoiceFeatures arg_conv;
39367         arg_conv.inner = untag_ptr(arg);
39368         arg_conv.is_owned = ptr_is_owned(arg);
39369         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39370         arg_conv.is_owned = false;
39371         int64_t ret_conv = InvoiceFeatures_clone_ptr(&arg_conv);
39372         return ret_conv;
39373 }
39374
39375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39376         LDKInvoiceFeatures orig_conv;
39377         orig_conv.inner = untag_ptr(orig);
39378         orig_conv.is_owned = ptr_is_owned(orig);
39379         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39380         orig_conv.is_owned = false;
39381         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
39382         int64_t ret_ref = 0;
39383         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39384         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39385         return ret_ref;
39386 }
39387
39388 static inline uint64_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
39389         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
39390         int64_t ret_ref = 0;
39391         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39392         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39393         return ret_ref;
39394 }
39395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39396         LDKChannelTypeFeatures arg_conv;
39397         arg_conv.inner = untag_ptr(arg);
39398         arg_conv.is_owned = ptr_is_owned(arg);
39399         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39400         arg_conv.is_owned = false;
39401         int64_t ret_conv = ChannelTypeFeatures_clone_ptr(&arg_conv);
39402         return ret_conv;
39403 }
39404
39405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39406         LDKChannelTypeFeatures orig_conv;
39407         orig_conv.inner = untag_ptr(orig);
39408         orig_conv.is_owned = ptr_is_owned(orig);
39409         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39410         orig_conv.is_owned = false;
39411         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
39412         int64_t ret_ref = 0;
39413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39414         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39415         return ret_ref;
39416 }
39417
39418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39419         LDKInitFeatures this_obj_conv;
39420         this_obj_conv.inner = untag_ptr(this_obj);
39421         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39423         InitFeatures_free(this_obj_conv);
39424 }
39425
39426 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39427         LDKNodeFeatures this_obj_conv;
39428         this_obj_conv.inner = untag_ptr(this_obj);
39429         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39431         NodeFeatures_free(this_obj_conv);
39432 }
39433
39434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39435         LDKChannelFeatures this_obj_conv;
39436         this_obj_conv.inner = untag_ptr(this_obj);
39437         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39439         ChannelFeatures_free(this_obj_conv);
39440 }
39441
39442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39443         LDKInvoiceFeatures this_obj_conv;
39444         this_obj_conv.inner = untag_ptr(this_obj);
39445         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39447         InvoiceFeatures_free(this_obj_conv);
39448 }
39449
39450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39451         LDKChannelTypeFeatures this_obj_conv;
39452         this_obj_conv.inner = untag_ptr(this_obj);
39453         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39455         ChannelTypeFeatures_free(this_obj_conv);
39456 }
39457
39458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
39459         LDKInitFeatures ret_var = InitFeatures_empty();
39460         int64_t ret_ref = 0;
39461         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39462         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39463         return ret_ref;
39464 }
39465
39466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
39467         LDKInitFeatures ret_var = InitFeatures_known();
39468         int64_t ret_ref = 0;
39469         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39470         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39471         return ret_ref;
39472 }
39473
39474 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
39475         LDKInitFeatures this_arg_conv;
39476         this_arg_conv.inner = untag_ptr(this_arg);
39477         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39479         this_arg_conv.is_owned = false;
39480         jboolean ret_conv = InitFeatures_requires_unknown_bits(&this_arg_conv);
39481         return ret_conv;
39482 }
39483
39484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
39485         LDKNodeFeatures ret_var = NodeFeatures_empty();
39486         int64_t ret_ref = 0;
39487         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39488         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39489         return ret_ref;
39490 }
39491
39492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
39493         LDKNodeFeatures ret_var = NodeFeatures_known();
39494         int64_t ret_ref = 0;
39495         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39496         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39497         return ret_ref;
39498 }
39499
39500 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
39501         LDKNodeFeatures this_arg_conv;
39502         this_arg_conv.inner = untag_ptr(this_arg);
39503         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39505         this_arg_conv.is_owned = false;
39506         jboolean ret_conv = NodeFeatures_requires_unknown_bits(&this_arg_conv);
39507         return ret_conv;
39508 }
39509
39510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
39511         LDKChannelFeatures ret_var = ChannelFeatures_empty();
39512         int64_t ret_ref = 0;
39513         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39514         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39515         return ret_ref;
39516 }
39517
39518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
39519         LDKChannelFeatures ret_var = ChannelFeatures_known();
39520         int64_t ret_ref = 0;
39521         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39522         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39523         return ret_ref;
39524 }
39525
39526 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
39527         LDKChannelFeatures this_arg_conv;
39528         this_arg_conv.inner = untag_ptr(this_arg);
39529         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39531         this_arg_conv.is_owned = false;
39532         jboolean ret_conv = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
39533         return ret_conv;
39534 }
39535
39536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
39537         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
39538         int64_t ret_ref = 0;
39539         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39540         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39541         return ret_ref;
39542 }
39543
39544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
39545         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
39546         int64_t ret_ref = 0;
39547         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39548         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39549         return ret_ref;
39550 }
39551
39552 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
39553         LDKInvoiceFeatures this_arg_conv;
39554         this_arg_conv.inner = untag_ptr(this_arg);
39555         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39557         this_arg_conv.is_owned = false;
39558         jboolean ret_conv = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
39559         return ret_conv;
39560 }
39561
39562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1empty(JNIEnv *env, jclass clz) {
39563         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
39564         int64_t ret_ref = 0;
39565         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39566         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39567         return ret_ref;
39568 }
39569
39570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1known(JNIEnv *env, jclass clz) {
39571         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
39572         int64_t ret_ref = 0;
39573         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39574         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39575         return ret_ref;
39576 }
39577
39578 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
39579         LDKChannelTypeFeatures this_arg_conv;
39580         this_arg_conv.inner = untag_ptr(this_arg);
39581         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39583         this_arg_conv.is_owned = false;
39584         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
39585         return ret_conv;
39586 }
39587
39588 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
39589         LDKInitFeatures obj_conv;
39590         obj_conv.inner = untag_ptr(obj);
39591         obj_conv.is_owned = ptr_is_owned(obj);
39592         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39593         obj_conv.is_owned = false;
39594         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
39595         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39596         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39597         CVec_u8Z_free(ret_var);
39598         return ret_arr;
39599 }
39600
39601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39602         LDKu8slice ser_ref;
39603         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39604         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39605         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
39606         *ret_conv = InitFeatures_read(ser_ref);
39607         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39608         return tag_ptr(ret_conv, true);
39609 }
39610
39611 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
39612         LDKChannelFeatures obj_conv;
39613         obj_conv.inner = untag_ptr(obj);
39614         obj_conv.is_owned = ptr_is_owned(obj);
39615         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39616         obj_conv.is_owned = false;
39617         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
39618         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39619         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39620         CVec_u8Z_free(ret_var);
39621         return ret_arr;
39622 }
39623
39624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39625         LDKu8slice ser_ref;
39626         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39627         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39628         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
39629         *ret_conv = ChannelFeatures_read(ser_ref);
39630         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39631         return tag_ptr(ret_conv, true);
39632 }
39633
39634 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
39635         LDKNodeFeatures obj_conv;
39636         obj_conv.inner = untag_ptr(obj);
39637         obj_conv.is_owned = ptr_is_owned(obj);
39638         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39639         obj_conv.is_owned = false;
39640         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
39641         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39642         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39643         CVec_u8Z_free(ret_var);
39644         return ret_arr;
39645 }
39646
39647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39648         LDKu8slice ser_ref;
39649         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39650         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39651         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
39652         *ret_conv = NodeFeatures_read(ser_ref);
39653         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39654         return tag_ptr(ret_conv, true);
39655 }
39656
39657 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
39658         LDKInvoiceFeatures obj_conv;
39659         obj_conv.inner = untag_ptr(obj);
39660         obj_conv.is_owned = ptr_is_owned(obj);
39661         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39662         obj_conv.is_owned = false;
39663         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
39664         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39665         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39666         CVec_u8Z_free(ret_var);
39667         return ret_arr;
39668 }
39669
39670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39671         LDKu8slice ser_ref;
39672         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39673         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39674         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
39675         *ret_conv = InvoiceFeatures_read(ser_ref);
39676         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39677         return tag_ptr(ret_conv, true);
39678 }
39679
39680 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
39681         LDKChannelTypeFeatures obj_conv;
39682         obj_conv.inner = untag_ptr(obj);
39683         obj_conv.is_owned = ptr_is_owned(obj);
39684         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39685         obj_conv.is_owned = false;
39686         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
39687         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39688         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39689         CVec_u8Z_free(ret_var);
39690         return ret_arr;
39691 }
39692
39693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39694         LDKu8slice ser_ref;
39695         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39696         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39697         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
39698         *ret_conv = ChannelTypeFeatures_read(ser_ref);
39699         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39700         return tag_ptr(ret_conv, true);
39701 }
39702
39703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
39704         LDKInitFeatures this_arg_conv;
39705         this_arg_conv.inner = untag_ptr(this_arg);
39706         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39708         this_arg_conv.is_owned = false;
39709         InitFeatures_set_data_loss_protect_optional(&this_arg_conv);
39710 }
39711
39712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
39713         LDKInitFeatures this_arg_conv;
39714         this_arg_conv.inner = untag_ptr(this_arg);
39715         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39717         this_arg_conv.is_owned = false;
39718         InitFeatures_set_data_loss_protect_required(&this_arg_conv);
39719 }
39720
39721 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
39722         LDKInitFeatures this_arg_conv;
39723         this_arg_conv.inner = untag_ptr(this_arg);
39724         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39726         this_arg_conv.is_owned = false;
39727         jboolean ret_conv = InitFeatures_supports_data_loss_protect(&this_arg_conv);
39728         return ret_conv;
39729 }
39730
39731 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
39732         LDKNodeFeatures this_arg_conv;
39733         this_arg_conv.inner = untag_ptr(this_arg);
39734         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39736         this_arg_conv.is_owned = false;
39737         NodeFeatures_set_data_loss_protect_optional(&this_arg_conv);
39738 }
39739
39740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
39741         LDKNodeFeatures this_arg_conv;
39742         this_arg_conv.inner = untag_ptr(this_arg);
39743         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39745         this_arg_conv.is_owned = false;
39746         NodeFeatures_set_data_loss_protect_required(&this_arg_conv);
39747 }
39748
39749 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
39750         LDKNodeFeatures this_arg_conv;
39751         this_arg_conv.inner = untag_ptr(this_arg);
39752         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39754         this_arg_conv.is_owned = false;
39755         jboolean ret_conv = NodeFeatures_supports_data_loss_protect(&this_arg_conv);
39756         return ret_conv;
39757 }
39758
39759 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
39760         LDKInitFeatures this_arg_conv;
39761         this_arg_conv.inner = untag_ptr(this_arg);
39762         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39764         this_arg_conv.is_owned = false;
39765         jboolean ret_conv = InitFeatures_requires_data_loss_protect(&this_arg_conv);
39766         return ret_conv;
39767 }
39768
39769 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
39770         LDKNodeFeatures this_arg_conv;
39771         this_arg_conv.inner = untag_ptr(this_arg);
39772         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39774         this_arg_conv.is_owned = false;
39775         jboolean ret_conv = NodeFeatures_requires_data_loss_protect(&this_arg_conv);
39776         return ret_conv;
39777 }
39778
39779 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
39780         LDKInitFeatures this_arg_conv;
39781         this_arg_conv.inner = untag_ptr(this_arg);
39782         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39784         this_arg_conv.is_owned = false;
39785         InitFeatures_set_initial_routing_sync_optional(&this_arg_conv);
39786 }
39787
39788 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
39789         LDKInitFeatures this_arg_conv;
39790         this_arg_conv.inner = untag_ptr(this_arg);
39791         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39793         this_arg_conv.is_owned = false;
39794         InitFeatures_set_initial_routing_sync_required(&this_arg_conv);
39795 }
39796
39797 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1initial_1routing_1sync(JNIEnv *env, jclass clz, int64_t this_arg) {
39798         LDKInitFeatures this_arg_conv;
39799         this_arg_conv.inner = untag_ptr(this_arg);
39800         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39802         this_arg_conv.is_owned = false;
39803         jboolean ret_conv = InitFeatures_initial_routing_sync(&this_arg_conv);
39804         return ret_conv;
39805 }
39806
39807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
39808         LDKInitFeatures this_arg_conv;
39809         this_arg_conv.inner = untag_ptr(this_arg);
39810         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39812         this_arg_conv.is_owned = false;
39813         InitFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
39814 }
39815
39816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
39817         LDKInitFeatures this_arg_conv;
39818         this_arg_conv.inner = untag_ptr(this_arg);
39819         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39821         this_arg_conv.is_owned = false;
39822         InitFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
39823 }
39824
39825 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
39826         LDKInitFeatures this_arg_conv;
39827         this_arg_conv.inner = untag_ptr(this_arg);
39828         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39830         this_arg_conv.is_owned = false;
39831         jboolean ret_conv = InitFeatures_supports_upfront_shutdown_script(&this_arg_conv);
39832         return ret_conv;
39833 }
39834
39835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
39836         LDKNodeFeatures this_arg_conv;
39837         this_arg_conv.inner = untag_ptr(this_arg);
39838         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39840         this_arg_conv.is_owned = false;
39841         NodeFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
39842 }
39843
39844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
39845         LDKNodeFeatures this_arg_conv;
39846         this_arg_conv.inner = untag_ptr(this_arg);
39847         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39849         this_arg_conv.is_owned = false;
39850         NodeFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
39851 }
39852
39853 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
39854         LDKNodeFeatures this_arg_conv;
39855         this_arg_conv.inner = untag_ptr(this_arg);
39856         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39858         this_arg_conv.is_owned = false;
39859         jboolean ret_conv = NodeFeatures_supports_upfront_shutdown_script(&this_arg_conv);
39860         return ret_conv;
39861 }
39862
39863 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
39864         LDKInitFeatures this_arg_conv;
39865         this_arg_conv.inner = untag_ptr(this_arg);
39866         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39868         this_arg_conv.is_owned = false;
39869         jboolean ret_conv = InitFeatures_requires_upfront_shutdown_script(&this_arg_conv);
39870         return ret_conv;
39871 }
39872
39873 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
39874         LDKNodeFeatures this_arg_conv;
39875         this_arg_conv.inner = untag_ptr(this_arg);
39876         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39878         this_arg_conv.is_owned = false;
39879         jboolean ret_conv = NodeFeatures_requires_upfront_shutdown_script(&this_arg_conv);
39880         return ret_conv;
39881 }
39882
39883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
39884         LDKInitFeatures this_arg_conv;
39885         this_arg_conv.inner = untag_ptr(this_arg);
39886         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39888         this_arg_conv.is_owned = false;
39889         InitFeatures_set_gossip_queries_optional(&this_arg_conv);
39890 }
39891
39892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
39893         LDKInitFeatures this_arg_conv;
39894         this_arg_conv.inner = untag_ptr(this_arg);
39895         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39897         this_arg_conv.is_owned = false;
39898         InitFeatures_set_gossip_queries_required(&this_arg_conv);
39899 }
39900
39901 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
39902         LDKInitFeatures this_arg_conv;
39903         this_arg_conv.inner = untag_ptr(this_arg);
39904         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39906         this_arg_conv.is_owned = false;
39907         jboolean ret_conv = InitFeatures_supports_gossip_queries(&this_arg_conv);
39908         return ret_conv;
39909 }
39910
39911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
39912         LDKNodeFeatures this_arg_conv;
39913         this_arg_conv.inner = untag_ptr(this_arg);
39914         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39916         this_arg_conv.is_owned = false;
39917         NodeFeatures_set_gossip_queries_optional(&this_arg_conv);
39918 }
39919
39920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
39921         LDKNodeFeatures this_arg_conv;
39922         this_arg_conv.inner = untag_ptr(this_arg);
39923         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39925         this_arg_conv.is_owned = false;
39926         NodeFeatures_set_gossip_queries_required(&this_arg_conv);
39927 }
39928
39929 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
39930         LDKNodeFeatures this_arg_conv;
39931         this_arg_conv.inner = untag_ptr(this_arg);
39932         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39934         this_arg_conv.is_owned = false;
39935         jboolean ret_conv = NodeFeatures_supports_gossip_queries(&this_arg_conv);
39936         return ret_conv;
39937 }
39938
39939 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
39940         LDKInitFeatures this_arg_conv;
39941         this_arg_conv.inner = untag_ptr(this_arg);
39942         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39944         this_arg_conv.is_owned = false;
39945         jboolean ret_conv = InitFeatures_requires_gossip_queries(&this_arg_conv);
39946         return ret_conv;
39947 }
39948
39949 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
39950         LDKNodeFeatures this_arg_conv;
39951         this_arg_conv.inner = untag_ptr(this_arg);
39952         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39954         this_arg_conv.is_owned = false;
39955         jboolean ret_conv = NodeFeatures_requires_gossip_queries(&this_arg_conv);
39956         return ret_conv;
39957 }
39958
39959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
39960         LDKInitFeatures this_arg_conv;
39961         this_arg_conv.inner = untag_ptr(this_arg);
39962         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39964         this_arg_conv.is_owned = false;
39965         InitFeatures_set_variable_length_onion_optional(&this_arg_conv);
39966 }
39967
39968 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
39969         LDKInitFeatures this_arg_conv;
39970         this_arg_conv.inner = untag_ptr(this_arg);
39971         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39973         this_arg_conv.is_owned = false;
39974         InitFeatures_set_variable_length_onion_required(&this_arg_conv);
39975 }
39976
39977 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
39978         LDKInitFeatures this_arg_conv;
39979         this_arg_conv.inner = untag_ptr(this_arg);
39980         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39982         this_arg_conv.is_owned = false;
39983         jboolean ret_conv = InitFeatures_supports_variable_length_onion(&this_arg_conv);
39984         return ret_conv;
39985 }
39986
39987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
39988         LDKNodeFeatures this_arg_conv;
39989         this_arg_conv.inner = untag_ptr(this_arg);
39990         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39992         this_arg_conv.is_owned = false;
39993         NodeFeatures_set_variable_length_onion_optional(&this_arg_conv);
39994 }
39995
39996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
39997         LDKNodeFeatures this_arg_conv;
39998         this_arg_conv.inner = untag_ptr(this_arg);
39999         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40001         this_arg_conv.is_owned = false;
40002         NodeFeatures_set_variable_length_onion_required(&this_arg_conv);
40003 }
40004
40005 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
40006         LDKNodeFeatures this_arg_conv;
40007         this_arg_conv.inner = untag_ptr(this_arg);
40008         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40010         this_arg_conv.is_owned = false;
40011         jboolean ret_conv = NodeFeatures_supports_variable_length_onion(&this_arg_conv);
40012         return ret_conv;
40013 }
40014
40015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40016         LDKInvoiceFeatures this_arg_conv;
40017         this_arg_conv.inner = untag_ptr(this_arg);
40018         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40020         this_arg_conv.is_owned = false;
40021         InvoiceFeatures_set_variable_length_onion_optional(&this_arg_conv);
40022 }
40023
40024 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40025         LDKInvoiceFeatures this_arg_conv;
40026         this_arg_conv.inner = untag_ptr(this_arg);
40027         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40029         this_arg_conv.is_owned = false;
40030         InvoiceFeatures_set_variable_length_onion_required(&this_arg_conv);
40031 }
40032
40033 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
40034         LDKInvoiceFeatures this_arg_conv;
40035         this_arg_conv.inner = untag_ptr(this_arg);
40036         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40038         this_arg_conv.is_owned = false;
40039         jboolean ret_conv = InvoiceFeatures_supports_variable_length_onion(&this_arg_conv);
40040         return ret_conv;
40041 }
40042
40043 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
40044         LDKInitFeatures this_arg_conv;
40045         this_arg_conv.inner = untag_ptr(this_arg);
40046         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40048         this_arg_conv.is_owned = false;
40049         jboolean ret_conv = InitFeatures_requires_variable_length_onion(&this_arg_conv);
40050         return ret_conv;
40051 }
40052
40053 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
40054         LDKNodeFeatures this_arg_conv;
40055         this_arg_conv.inner = untag_ptr(this_arg);
40056         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40058         this_arg_conv.is_owned = false;
40059         jboolean ret_conv = NodeFeatures_requires_variable_length_onion(&this_arg_conv);
40060         return ret_conv;
40061 }
40062
40063 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
40064         LDKInvoiceFeatures this_arg_conv;
40065         this_arg_conv.inner = untag_ptr(this_arg);
40066         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40068         this_arg_conv.is_owned = false;
40069         jboolean ret_conv = InvoiceFeatures_requires_variable_length_onion(&this_arg_conv);
40070         return ret_conv;
40071 }
40072
40073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40074         LDKInitFeatures this_arg_conv;
40075         this_arg_conv.inner = untag_ptr(this_arg);
40076         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40078         this_arg_conv.is_owned = false;
40079         InitFeatures_set_static_remote_key_optional(&this_arg_conv);
40080 }
40081
40082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40083         LDKInitFeatures this_arg_conv;
40084         this_arg_conv.inner = untag_ptr(this_arg);
40085         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40087         this_arg_conv.is_owned = false;
40088         InitFeatures_set_static_remote_key_required(&this_arg_conv);
40089 }
40090
40091 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
40092         LDKInitFeatures this_arg_conv;
40093         this_arg_conv.inner = untag_ptr(this_arg);
40094         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40096         this_arg_conv.is_owned = false;
40097         jboolean ret_conv = InitFeatures_supports_static_remote_key(&this_arg_conv);
40098         return ret_conv;
40099 }
40100
40101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40102         LDKNodeFeatures this_arg_conv;
40103         this_arg_conv.inner = untag_ptr(this_arg);
40104         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40106         this_arg_conv.is_owned = false;
40107         NodeFeatures_set_static_remote_key_optional(&this_arg_conv);
40108 }
40109
40110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40111         LDKNodeFeatures this_arg_conv;
40112         this_arg_conv.inner = untag_ptr(this_arg);
40113         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40115         this_arg_conv.is_owned = false;
40116         NodeFeatures_set_static_remote_key_required(&this_arg_conv);
40117 }
40118
40119 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
40120         LDKNodeFeatures this_arg_conv;
40121         this_arg_conv.inner = untag_ptr(this_arg);
40122         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40124         this_arg_conv.is_owned = false;
40125         jboolean ret_conv = NodeFeatures_supports_static_remote_key(&this_arg_conv);
40126         return ret_conv;
40127 }
40128
40129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40130         LDKChannelTypeFeatures this_arg_conv;
40131         this_arg_conv.inner = untag_ptr(this_arg);
40132         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40134         this_arg_conv.is_owned = false;
40135         ChannelTypeFeatures_set_static_remote_key_optional(&this_arg_conv);
40136 }
40137
40138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40139         LDKChannelTypeFeatures this_arg_conv;
40140         this_arg_conv.inner = untag_ptr(this_arg);
40141         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40143         this_arg_conv.is_owned = false;
40144         ChannelTypeFeatures_set_static_remote_key_required(&this_arg_conv);
40145 }
40146
40147 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
40148         LDKChannelTypeFeatures this_arg_conv;
40149         this_arg_conv.inner = untag_ptr(this_arg);
40150         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40152         this_arg_conv.is_owned = false;
40153         jboolean ret_conv = ChannelTypeFeatures_supports_static_remote_key(&this_arg_conv);
40154         return ret_conv;
40155 }
40156
40157 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
40158         LDKInitFeatures this_arg_conv;
40159         this_arg_conv.inner = untag_ptr(this_arg);
40160         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40162         this_arg_conv.is_owned = false;
40163         jboolean ret_conv = InitFeatures_requires_static_remote_key(&this_arg_conv);
40164         return ret_conv;
40165 }
40166
40167 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
40168         LDKNodeFeatures this_arg_conv;
40169         this_arg_conv.inner = untag_ptr(this_arg);
40170         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40172         this_arg_conv.is_owned = false;
40173         jboolean ret_conv = NodeFeatures_requires_static_remote_key(&this_arg_conv);
40174         return ret_conv;
40175 }
40176
40177 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
40178         LDKChannelTypeFeatures this_arg_conv;
40179         this_arg_conv.inner = untag_ptr(this_arg);
40180         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40182         this_arg_conv.is_owned = false;
40183         jboolean ret_conv = ChannelTypeFeatures_requires_static_remote_key(&this_arg_conv);
40184         return ret_conv;
40185 }
40186
40187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40188         LDKInitFeatures this_arg_conv;
40189         this_arg_conv.inner = untag_ptr(this_arg);
40190         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40192         this_arg_conv.is_owned = false;
40193         InitFeatures_set_payment_secret_optional(&this_arg_conv);
40194 }
40195
40196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40197         LDKInitFeatures this_arg_conv;
40198         this_arg_conv.inner = untag_ptr(this_arg);
40199         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40201         this_arg_conv.is_owned = false;
40202         InitFeatures_set_payment_secret_required(&this_arg_conv);
40203 }
40204
40205 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
40206         LDKInitFeatures this_arg_conv;
40207         this_arg_conv.inner = untag_ptr(this_arg);
40208         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40210         this_arg_conv.is_owned = false;
40211         jboolean ret_conv = InitFeatures_supports_payment_secret(&this_arg_conv);
40212         return ret_conv;
40213 }
40214
40215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40216         LDKNodeFeatures this_arg_conv;
40217         this_arg_conv.inner = untag_ptr(this_arg);
40218         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40220         this_arg_conv.is_owned = false;
40221         NodeFeatures_set_payment_secret_optional(&this_arg_conv);
40222 }
40223
40224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40225         LDKNodeFeatures this_arg_conv;
40226         this_arg_conv.inner = untag_ptr(this_arg);
40227         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40229         this_arg_conv.is_owned = false;
40230         NodeFeatures_set_payment_secret_required(&this_arg_conv);
40231 }
40232
40233 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
40234         LDKNodeFeatures this_arg_conv;
40235         this_arg_conv.inner = untag_ptr(this_arg);
40236         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40238         this_arg_conv.is_owned = false;
40239         jboolean ret_conv = NodeFeatures_supports_payment_secret(&this_arg_conv);
40240         return ret_conv;
40241 }
40242
40243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40244         LDKInvoiceFeatures this_arg_conv;
40245         this_arg_conv.inner = untag_ptr(this_arg);
40246         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40248         this_arg_conv.is_owned = false;
40249         InvoiceFeatures_set_payment_secret_optional(&this_arg_conv);
40250 }
40251
40252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40253         LDKInvoiceFeatures this_arg_conv;
40254         this_arg_conv.inner = untag_ptr(this_arg);
40255         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40257         this_arg_conv.is_owned = false;
40258         InvoiceFeatures_set_payment_secret_required(&this_arg_conv);
40259 }
40260
40261 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
40262         LDKInvoiceFeatures this_arg_conv;
40263         this_arg_conv.inner = untag_ptr(this_arg);
40264         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40266         this_arg_conv.is_owned = false;
40267         jboolean ret_conv = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
40268         return ret_conv;
40269 }
40270
40271 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
40272         LDKInitFeatures this_arg_conv;
40273         this_arg_conv.inner = untag_ptr(this_arg);
40274         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40276         this_arg_conv.is_owned = false;
40277         jboolean ret_conv = InitFeatures_requires_payment_secret(&this_arg_conv);
40278         return ret_conv;
40279 }
40280
40281 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
40282         LDKNodeFeatures this_arg_conv;
40283         this_arg_conv.inner = untag_ptr(this_arg);
40284         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40286         this_arg_conv.is_owned = false;
40287         jboolean ret_conv = NodeFeatures_requires_payment_secret(&this_arg_conv);
40288         return ret_conv;
40289 }
40290
40291 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
40292         LDKInvoiceFeatures this_arg_conv;
40293         this_arg_conv.inner = untag_ptr(this_arg);
40294         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40296         this_arg_conv.is_owned = false;
40297         jboolean ret_conv = InvoiceFeatures_requires_payment_secret(&this_arg_conv);
40298         return ret_conv;
40299 }
40300
40301 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40302         LDKInitFeatures this_arg_conv;
40303         this_arg_conv.inner = untag_ptr(this_arg);
40304         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40306         this_arg_conv.is_owned = false;
40307         InitFeatures_set_basic_mpp_optional(&this_arg_conv);
40308 }
40309
40310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40311         LDKInitFeatures this_arg_conv;
40312         this_arg_conv.inner = untag_ptr(this_arg);
40313         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40315         this_arg_conv.is_owned = false;
40316         InitFeatures_set_basic_mpp_required(&this_arg_conv);
40317 }
40318
40319 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
40320         LDKInitFeatures this_arg_conv;
40321         this_arg_conv.inner = untag_ptr(this_arg);
40322         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40324         this_arg_conv.is_owned = false;
40325         jboolean ret_conv = InitFeatures_supports_basic_mpp(&this_arg_conv);
40326         return ret_conv;
40327 }
40328
40329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40330         LDKNodeFeatures this_arg_conv;
40331         this_arg_conv.inner = untag_ptr(this_arg);
40332         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40334         this_arg_conv.is_owned = false;
40335         NodeFeatures_set_basic_mpp_optional(&this_arg_conv);
40336 }
40337
40338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40339         LDKNodeFeatures this_arg_conv;
40340         this_arg_conv.inner = untag_ptr(this_arg);
40341         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40343         this_arg_conv.is_owned = false;
40344         NodeFeatures_set_basic_mpp_required(&this_arg_conv);
40345 }
40346
40347 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
40348         LDKNodeFeatures this_arg_conv;
40349         this_arg_conv.inner = untag_ptr(this_arg);
40350         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40352         this_arg_conv.is_owned = false;
40353         jboolean ret_conv = NodeFeatures_supports_basic_mpp(&this_arg_conv);
40354         return ret_conv;
40355 }
40356
40357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40358         LDKInvoiceFeatures this_arg_conv;
40359         this_arg_conv.inner = untag_ptr(this_arg);
40360         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40362         this_arg_conv.is_owned = false;
40363         InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
40364 }
40365
40366 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40367         LDKInvoiceFeatures this_arg_conv;
40368         this_arg_conv.inner = untag_ptr(this_arg);
40369         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40371         this_arg_conv.is_owned = false;
40372         InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
40373 }
40374
40375 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
40376         LDKInvoiceFeatures this_arg_conv;
40377         this_arg_conv.inner = untag_ptr(this_arg);
40378         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40380         this_arg_conv.is_owned = false;
40381         jboolean ret_conv = InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
40382         return ret_conv;
40383 }
40384
40385 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
40386         LDKInitFeatures this_arg_conv;
40387         this_arg_conv.inner = untag_ptr(this_arg);
40388         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40390         this_arg_conv.is_owned = false;
40391         jboolean ret_conv = InitFeatures_requires_basic_mpp(&this_arg_conv);
40392         return ret_conv;
40393 }
40394
40395 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
40396         LDKNodeFeatures this_arg_conv;
40397         this_arg_conv.inner = untag_ptr(this_arg);
40398         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40400         this_arg_conv.is_owned = false;
40401         jboolean ret_conv = NodeFeatures_requires_basic_mpp(&this_arg_conv);
40402         return ret_conv;
40403 }
40404
40405 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
40406         LDKInvoiceFeatures this_arg_conv;
40407         this_arg_conv.inner = untag_ptr(this_arg);
40408         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40410         this_arg_conv.is_owned = false;
40411         jboolean ret_conv = InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
40412         return ret_conv;
40413 }
40414
40415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40416         LDKInitFeatures this_arg_conv;
40417         this_arg_conv.inner = untag_ptr(this_arg);
40418         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40420         this_arg_conv.is_owned = false;
40421         InitFeatures_set_wumbo_optional(&this_arg_conv);
40422 }
40423
40424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40425         LDKInitFeatures this_arg_conv;
40426         this_arg_conv.inner = untag_ptr(this_arg);
40427         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40429         this_arg_conv.is_owned = false;
40430         InitFeatures_set_wumbo_required(&this_arg_conv);
40431 }
40432
40433 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
40434         LDKInitFeatures this_arg_conv;
40435         this_arg_conv.inner = untag_ptr(this_arg);
40436         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40438         this_arg_conv.is_owned = false;
40439         jboolean ret_conv = InitFeatures_supports_wumbo(&this_arg_conv);
40440         return ret_conv;
40441 }
40442
40443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40444         LDKNodeFeatures this_arg_conv;
40445         this_arg_conv.inner = untag_ptr(this_arg);
40446         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40448         this_arg_conv.is_owned = false;
40449         NodeFeatures_set_wumbo_optional(&this_arg_conv);
40450 }
40451
40452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40453         LDKNodeFeatures this_arg_conv;
40454         this_arg_conv.inner = untag_ptr(this_arg);
40455         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40457         this_arg_conv.is_owned = false;
40458         NodeFeatures_set_wumbo_required(&this_arg_conv);
40459 }
40460
40461 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
40462         LDKNodeFeatures this_arg_conv;
40463         this_arg_conv.inner = untag_ptr(this_arg);
40464         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40466         this_arg_conv.is_owned = false;
40467         jboolean ret_conv = NodeFeatures_supports_wumbo(&this_arg_conv);
40468         return ret_conv;
40469 }
40470
40471 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
40472         LDKInitFeatures this_arg_conv;
40473         this_arg_conv.inner = untag_ptr(this_arg);
40474         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40476         this_arg_conv.is_owned = false;
40477         jboolean ret_conv = InitFeatures_requires_wumbo(&this_arg_conv);
40478         return ret_conv;
40479 }
40480
40481 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
40482         LDKNodeFeatures this_arg_conv;
40483         this_arg_conv.inner = untag_ptr(this_arg);
40484         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40486         this_arg_conv.is_owned = false;
40487         jboolean ret_conv = NodeFeatures_requires_wumbo(&this_arg_conv);
40488         return ret_conv;
40489 }
40490
40491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40492         LDKInitFeatures this_arg_conv;
40493         this_arg_conv.inner = untag_ptr(this_arg);
40494         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40496         this_arg_conv.is_owned = false;
40497         InitFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
40498 }
40499
40500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40501         LDKInitFeatures this_arg_conv;
40502         this_arg_conv.inner = untag_ptr(this_arg);
40503         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40505         this_arg_conv.is_owned = false;
40506         InitFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
40507 }
40508
40509 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
40510         LDKInitFeatures this_arg_conv;
40511         this_arg_conv.inner = untag_ptr(this_arg);
40512         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40514         this_arg_conv.is_owned = false;
40515         jboolean ret_conv = InitFeatures_supports_shutdown_anysegwit(&this_arg_conv);
40516         return ret_conv;
40517 }
40518
40519 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40520         LDKNodeFeatures this_arg_conv;
40521         this_arg_conv.inner = untag_ptr(this_arg);
40522         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40524         this_arg_conv.is_owned = false;
40525         NodeFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
40526 }
40527
40528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40529         LDKNodeFeatures this_arg_conv;
40530         this_arg_conv.inner = untag_ptr(this_arg);
40531         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40533         this_arg_conv.is_owned = false;
40534         NodeFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
40535 }
40536
40537 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
40538         LDKNodeFeatures this_arg_conv;
40539         this_arg_conv.inner = untag_ptr(this_arg);
40540         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40542         this_arg_conv.is_owned = false;
40543         jboolean ret_conv = NodeFeatures_supports_shutdown_anysegwit(&this_arg_conv);
40544         return ret_conv;
40545 }
40546
40547 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
40548         LDKInitFeatures this_arg_conv;
40549         this_arg_conv.inner = untag_ptr(this_arg);
40550         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40552         this_arg_conv.is_owned = false;
40553         jboolean ret_conv = InitFeatures_requires_shutdown_anysegwit(&this_arg_conv);
40554         return ret_conv;
40555 }
40556
40557 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
40558         LDKNodeFeatures this_arg_conv;
40559         this_arg_conv.inner = untag_ptr(this_arg);
40560         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40562         this_arg_conv.is_owned = false;
40563         jboolean ret_conv = NodeFeatures_requires_shutdown_anysegwit(&this_arg_conv);
40564         return ret_conv;
40565 }
40566
40567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40568         LDKInitFeatures this_arg_conv;
40569         this_arg_conv.inner = untag_ptr(this_arg);
40570         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40572         this_arg_conv.is_owned = false;
40573         InitFeatures_set_channel_type_optional(&this_arg_conv);
40574 }
40575
40576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40577         LDKInitFeatures this_arg_conv;
40578         this_arg_conv.inner = untag_ptr(this_arg);
40579         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40581         this_arg_conv.is_owned = false;
40582         InitFeatures_set_channel_type_required(&this_arg_conv);
40583 }
40584
40585 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
40586         LDKInitFeatures this_arg_conv;
40587         this_arg_conv.inner = untag_ptr(this_arg);
40588         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40590         this_arg_conv.is_owned = false;
40591         jboolean ret_conv = InitFeatures_supports_channel_type(&this_arg_conv);
40592         return ret_conv;
40593 }
40594
40595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40596         LDKNodeFeatures this_arg_conv;
40597         this_arg_conv.inner = untag_ptr(this_arg);
40598         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40600         this_arg_conv.is_owned = false;
40601         NodeFeatures_set_channel_type_optional(&this_arg_conv);
40602 }
40603
40604 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40605         LDKNodeFeatures this_arg_conv;
40606         this_arg_conv.inner = untag_ptr(this_arg);
40607         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40609         this_arg_conv.is_owned = false;
40610         NodeFeatures_set_channel_type_required(&this_arg_conv);
40611 }
40612
40613 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
40614         LDKNodeFeatures this_arg_conv;
40615         this_arg_conv.inner = untag_ptr(this_arg);
40616         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40618         this_arg_conv.is_owned = false;
40619         jboolean ret_conv = NodeFeatures_supports_channel_type(&this_arg_conv);
40620         return ret_conv;
40621 }
40622
40623 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
40624         LDKInitFeatures this_arg_conv;
40625         this_arg_conv.inner = untag_ptr(this_arg);
40626         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40628         this_arg_conv.is_owned = false;
40629         jboolean ret_conv = InitFeatures_requires_channel_type(&this_arg_conv);
40630         return ret_conv;
40631 }
40632
40633 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
40634         LDKNodeFeatures this_arg_conv;
40635         this_arg_conv.inner = untag_ptr(this_arg);
40636         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40638         this_arg_conv.is_owned = false;
40639         jboolean ret_conv = NodeFeatures_requires_channel_type(&this_arg_conv);
40640         return ret_conv;
40641 }
40642
40643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40644         LDKInitFeatures this_arg_conv;
40645         this_arg_conv.inner = untag_ptr(this_arg);
40646         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40648         this_arg_conv.is_owned = false;
40649         InitFeatures_set_scid_privacy_optional(&this_arg_conv);
40650 }
40651
40652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40653         LDKInitFeatures this_arg_conv;
40654         this_arg_conv.inner = untag_ptr(this_arg);
40655         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40657         this_arg_conv.is_owned = false;
40658         InitFeatures_set_scid_privacy_required(&this_arg_conv);
40659 }
40660
40661 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
40662         LDKInitFeatures this_arg_conv;
40663         this_arg_conv.inner = untag_ptr(this_arg);
40664         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40666         this_arg_conv.is_owned = false;
40667         jboolean ret_conv = InitFeatures_supports_scid_privacy(&this_arg_conv);
40668         return ret_conv;
40669 }
40670
40671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40672         LDKNodeFeatures this_arg_conv;
40673         this_arg_conv.inner = untag_ptr(this_arg);
40674         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40676         this_arg_conv.is_owned = false;
40677         NodeFeatures_set_scid_privacy_optional(&this_arg_conv);
40678 }
40679
40680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40681         LDKNodeFeatures this_arg_conv;
40682         this_arg_conv.inner = untag_ptr(this_arg);
40683         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40685         this_arg_conv.is_owned = false;
40686         NodeFeatures_set_scid_privacy_required(&this_arg_conv);
40687 }
40688
40689 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
40690         LDKNodeFeatures this_arg_conv;
40691         this_arg_conv.inner = untag_ptr(this_arg);
40692         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40694         this_arg_conv.is_owned = false;
40695         jboolean ret_conv = NodeFeatures_supports_scid_privacy(&this_arg_conv);
40696         return ret_conv;
40697 }
40698
40699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40700         LDKChannelTypeFeatures this_arg_conv;
40701         this_arg_conv.inner = untag_ptr(this_arg);
40702         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40704         this_arg_conv.is_owned = false;
40705         ChannelTypeFeatures_set_scid_privacy_optional(&this_arg_conv);
40706 }
40707
40708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40709         LDKChannelTypeFeatures this_arg_conv;
40710         this_arg_conv.inner = untag_ptr(this_arg);
40711         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40713         this_arg_conv.is_owned = false;
40714         ChannelTypeFeatures_set_scid_privacy_required(&this_arg_conv);
40715 }
40716
40717 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
40718         LDKChannelTypeFeatures this_arg_conv;
40719         this_arg_conv.inner = untag_ptr(this_arg);
40720         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40722         this_arg_conv.is_owned = false;
40723         jboolean ret_conv = ChannelTypeFeatures_supports_scid_privacy(&this_arg_conv);
40724         return ret_conv;
40725 }
40726
40727 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
40728         LDKInitFeatures this_arg_conv;
40729         this_arg_conv.inner = untag_ptr(this_arg);
40730         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40732         this_arg_conv.is_owned = false;
40733         jboolean ret_conv = InitFeatures_requires_scid_privacy(&this_arg_conv);
40734         return ret_conv;
40735 }
40736
40737 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
40738         LDKNodeFeatures this_arg_conv;
40739         this_arg_conv.inner = untag_ptr(this_arg);
40740         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40742         this_arg_conv.is_owned = false;
40743         jboolean ret_conv = NodeFeatures_requires_scid_privacy(&this_arg_conv);
40744         return ret_conv;
40745 }
40746
40747 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
40748         LDKChannelTypeFeatures this_arg_conv;
40749         this_arg_conv.inner = untag_ptr(this_arg);
40750         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40752         this_arg_conv.is_owned = false;
40753         jboolean ret_conv = ChannelTypeFeatures_requires_scid_privacy(&this_arg_conv);
40754         return ret_conv;
40755 }
40756
40757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40758         LDKInitFeatures this_arg_conv;
40759         this_arg_conv.inner = untag_ptr(this_arg);
40760         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40762         this_arg_conv.is_owned = false;
40763         InitFeatures_set_zero_conf_optional(&this_arg_conv);
40764 }
40765
40766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40767         LDKInitFeatures this_arg_conv;
40768         this_arg_conv.inner = untag_ptr(this_arg);
40769         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40771         this_arg_conv.is_owned = false;
40772         InitFeatures_set_zero_conf_required(&this_arg_conv);
40773 }
40774
40775 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
40776         LDKInitFeatures this_arg_conv;
40777         this_arg_conv.inner = untag_ptr(this_arg);
40778         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40780         this_arg_conv.is_owned = false;
40781         jboolean ret_conv = InitFeatures_supports_zero_conf(&this_arg_conv);
40782         return ret_conv;
40783 }
40784
40785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40786         LDKNodeFeatures this_arg_conv;
40787         this_arg_conv.inner = untag_ptr(this_arg);
40788         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40790         this_arg_conv.is_owned = false;
40791         NodeFeatures_set_zero_conf_optional(&this_arg_conv);
40792 }
40793
40794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40795         LDKNodeFeatures this_arg_conv;
40796         this_arg_conv.inner = untag_ptr(this_arg);
40797         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40799         this_arg_conv.is_owned = false;
40800         NodeFeatures_set_zero_conf_required(&this_arg_conv);
40801 }
40802
40803 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
40804         LDKNodeFeatures this_arg_conv;
40805         this_arg_conv.inner = untag_ptr(this_arg);
40806         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40808         this_arg_conv.is_owned = false;
40809         jboolean ret_conv = NodeFeatures_supports_zero_conf(&this_arg_conv);
40810         return ret_conv;
40811 }
40812
40813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40814         LDKChannelTypeFeatures this_arg_conv;
40815         this_arg_conv.inner = untag_ptr(this_arg);
40816         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40818         this_arg_conv.is_owned = false;
40819         ChannelTypeFeatures_set_zero_conf_optional(&this_arg_conv);
40820 }
40821
40822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40823         LDKChannelTypeFeatures this_arg_conv;
40824         this_arg_conv.inner = untag_ptr(this_arg);
40825         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40827         this_arg_conv.is_owned = false;
40828         ChannelTypeFeatures_set_zero_conf_required(&this_arg_conv);
40829 }
40830
40831 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
40832         LDKChannelTypeFeatures this_arg_conv;
40833         this_arg_conv.inner = untag_ptr(this_arg);
40834         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40836         this_arg_conv.is_owned = false;
40837         jboolean ret_conv = ChannelTypeFeatures_supports_zero_conf(&this_arg_conv);
40838         return ret_conv;
40839 }
40840
40841 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
40842         LDKInitFeatures this_arg_conv;
40843         this_arg_conv.inner = untag_ptr(this_arg);
40844         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40846         this_arg_conv.is_owned = false;
40847         jboolean ret_conv = InitFeatures_requires_zero_conf(&this_arg_conv);
40848         return ret_conv;
40849 }
40850
40851 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
40852         LDKNodeFeatures this_arg_conv;
40853         this_arg_conv.inner = untag_ptr(this_arg);
40854         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40856         this_arg_conv.is_owned = false;
40857         jboolean ret_conv = NodeFeatures_requires_zero_conf(&this_arg_conv);
40858         return ret_conv;
40859 }
40860
40861 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
40862         LDKChannelTypeFeatures this_arg_conv;
40863         this_arg_conv.inner = untag_ptr(this_arg);
40864         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40866         this_arg_conv.is_owned = false;
40867         jboolean ret_conv = ChannelTypeFeatures_requires_zero_conf(&this_arg_conv);
40868         return ret_conv;
40869 }
40870
40871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40872         LDKNodeFeatures this_arg_conv;
40873         this_arg_conv.inner = untag_ptr(this_arg);
40874         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40876         this_arg_conv.is_owned = false;
40877         NodeFeatures_set_keysend_optional(&this_arg_conv);
40878 }
40879
40880 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40881         LDKNodeFeatures this_arg_conv;
40882         this_arg_conv.inner = untag_ptr(this_arg);
40883         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40885         this_arg_conv.is_owned = false;
40886         NodeFeatures_set_keysend_required(&this_arg_conv);
40887 }
40888
40889 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
40890         LDKNodeFeatures this_arg_conv;
40891         this_arg_conv.inner = untag_ptr(this_arg);
40892         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40894         this_arg_conv.is_owned = false;
40895         jboolean ret_conv = NodeFeatures_supports_keysend(&this_arg_conv);
40896         return ret_conv;
40897 }
40898
40899 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
40900         LDKNodeFeatures this_arg_conv;
40901         this_arg_conv.inner = untag_ptr(this_arg);
40902         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40904         this_arg_conv.is_owned = false;
40905         jboolean ret_conv = NodeFeatures_requires_keysend(&this_arg_conv);
40906         return ret_conv;
40907 }
40908
40909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40910         LDKShutdownScript this_obj_conv;
40911         this_obj_conv.inner = untag_ptr(this_obj);
40912         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40914         ShutdownScript_free(this_obj_conv);
40915 }
40916
40917 static inline uint64_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
40918         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
40919         int64_t ret_ref = 0;
40920         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40921         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40922         return ret_ref;
40923 }
40924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40925         LDKShutdownScript arg_conv;
40926         arg_conv.inner = untag_ptr(arg);
40927         arg_conv.is_owned = ptr_is_owned(arg);
40928         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40929         arg_conv.is_owned = false;
40930         int64_t ret_conv = ShutdownScript_clone_ptr(&arg_conv);
40931         return ret_conv;
40932 }
40933
40934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40935         LDKShutdownScript orig_conv;
40936         orig_conv.inner = untag_ptr(orig);
40937         orig_conv.is_owned = ptr_is_owned(orig);
40938         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40939         orig_conv.is_owned = false;
40940         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
40941         int64_t ret_ref = 0;
40942         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40943         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40944         return ret_ref;
40945 }
40946
40947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40948         LDKInvalidShutdownScript this_obj_conv;
40949         this_obj_conv.inner = untag_ptr(this_obj);
40950         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40952         InvalidShutdownScript_free(this_obj_conv);
40953 }
40954
40955 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
40956         LDKInvalidShutdownScript this_ptr_conv;
40957         this_ptr_conv.inner = untag_ptr(this_ptr);
40958         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40960         this_ptr_conv.is_owned = false;
40961         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
40962         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40963         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40964         return ret_arr;
40965 }
40966
40967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40968         LDKInvalidShutdownScript this_ptr_conv;
40969         this_ptr_conv.inner = untag_ptr(this_ptr);
40970         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40972         this_ptr_conv.is_owned = false;
40973         LDKCVec_u8Z val_ref;
40974         val_ref.datalen = (*env)->GetArrayLength(env, val);
40975         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
40976         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
40977         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
40978 }
40979
40980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
40981         LDKCVec_u8Z script_arg_ref;
40982         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
40983         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
40984         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
40985         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
40986         int64_t ret_ref = 0;
40987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40988         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40989         return ret_ref;
40990 }
40991
40992 static inline uint64_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
40993         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
40994         int64_t ret_ref = 0;
40995         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40996         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40997         return ret_ref;
40998 }
40999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41000         LDKInvalidShutdownScript arg_conv;
41001         arg_conv.inner = untag_ptr(arg);
41002         arg_conv.is_owned = ptr_is_owned(arg);
41003         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41004         arg_conv.is_owned = false;
41005         int64_t ret_conv = InvalidShutdownScript_clone_ptr(&arg_conv);
41006         return ret_conv;
41007 }
41008
41009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41010         LDKInvalidShutdownScript orig_conv;
41011         orig_conv.inner = untag_ptr(orig);
41012         orig_conv.is_owned = ptr_is_owned(orig);
41013         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41014         orig_conv.is_owned = false;
41015         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
41016         int64_t ret_ref = 0;
41017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41018         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41019         return ret_ref;
41020 }
41021
41022 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
41023         LDKShutdownScript obj_conv;
41024         obj_conv.inner = untag_ptr(obj);
41025         obj_conv.is_owned = ptr_is_owned(obj);
41026         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41027         obj_conv.is_owned = false;
41028         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
41029         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41030         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41031         CVec_u8Z_free(ret_var);
41032         return ret_arr;
41033 }
41034
41035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41036         LDKu8slice ser_ref;
41037         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41038         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41039         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
41040         *ret_conv = ShutdownScript_read(ser_ref);
41041         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41042         return tag_ptr(ret_conv, true);
41043 }
41044
41045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
41046         unsigned char pubkey_hash_arr[20];
41047         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
41048         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
41049         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
41050         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
41051         int64_t ret_ref = 0;
41052         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41053         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41054         return ret_ref;
41055 }
41056
41057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
41058         unsigned char script_hash_arr[32];
41059         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
41060         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
41061         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
41062         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
41063         int64_t ret_ref = 0;
41064         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41065         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41066         return ret_ref;
41067 }
41068
41069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
41070         
41071         LDKu8slice program_ref;
41072         program_ref.datalen = (*env)->GetArrayLength(env, program);
41073         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
41074         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
41075         *ret_conv = ShutdownScript_new_witness_program((LDKWitnessVersion){ ._0 = version }, program_ref);
41076         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
41077         return tag_ptr(ret_conv, true);
41078 }
41079
41080 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
41081         LDKShutdownScript this_arg_conv;
41082         this_arg_conv.inner = untag_ptr(this_arg);
41083         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41085         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
41086         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
41087         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41088         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41089         CVec_u8Z_free(ret_var);
41090         return ret_arr;
41091 }
41092
41093 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
41094         LDKShutdownScript 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41100         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
41101         return ret_arr;
41102 }
41103
41104 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
41105         LDKShutdownScript this_arg_conv;
41106         this_arg_conv.inner = untag_ptr(this_arg);
41107         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41109         this_arg_conv.is_owned = false;
41110         LDKInitFeatures features_conv;
41111         features_conv.inner = untag_ptr(features);
41112         features_conv.is_owned = ptr_is_owned(features);
41113         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
41114         features_conv.is_owned = false;
41115         jboolean ret_conv = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
41116         return ret_conv;
41117 }
41118
41119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
41120         if (!ptr_is_owned(this_ptr)) return;
41121         void* this_ptr_ptr = untag_ptr(this_ptr);
41122         CHECK_ACCESS(this_ptr_ptr);
41123         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
41124         FREE(untag_ptr(this_ptr));
41125         CustomMessageReader_free(this_ptr_conv);
41126 }
41127
41128 static inline uint64_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
41129         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
41130         *ret_ret = Type_clone(arg);
41131         return tag_ptr(ret_ret, true);
41132 }
41133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41134         void* arg_ptr = untag_ptr(arg);
41135         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
41136         LDKType* arg_conv = (LDKType*)arg_ptr;
41137         int64_t ret_conv = Type_clone_ptr(arg_conv);
41138         return ret_conv;
41139 }
41140
41141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41142         void* orig_ptr = untag_ptr(orig);
41143         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
41144         LDKType* orig_conv = (LDKType*)orig_ptr;
41145         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
41146         *ret_ret = Type_clone(orig_conv);
41147         return tag_ptr(ret_ret, true);
41148 }
41149
41150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
41151         if (!ptr_is_owned(this_ptr)) return;
41152         void* this_ptr_ptr = untag_ptr(this_ptr);
41153         CHECK_ACCESS(this_ptr_ptr);
41154         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
41155         FREE(untag_ptr(this_ptr));
41156         Type_free(this_ptr_conv);
41157 }
41158
41159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41160         LDKNodeId this_obj_conv;
41161         this_obj_conv.inner = untag_ptr(this_obj);
41162         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41164         NodeId_free(this_obj_conv);
41165 }
41166
41167 static inline uint64_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
41168         LDKNodeId ret_var = NodeId_clone(arg);
41169         int64_t ret_ref = 0;
41170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41171         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41172         return ret_ref;
41173 }
41174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41175         LDKNodeId arg_conv;
41176         arg_conv.inner = untag_ptr(arg);
41177         arg_conv.is_owned = ptr_is_owned(arg);
41178         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41179         arg_conv.is_owned = false;
41180         int64_t ret_conv = NodeId_clone_ptr(&arg_conv);
41181         return ret_conv;
41182 }
41183
41184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41185         LDKNodeId orig_conv;
41186         orig_conv.inner = untag_ptr(orig);
41187         orig_conv.is_owned = ptr_is_owned(orig);
41188         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41189         orig_conv.is_owned = false;
41190         LDKNodeId ret_var = NodeId_clone(&orig_conv);
41191         int64_t ret_ref = 0;
41192         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41193         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41194         return ret_ref;
41195 }
41196
41197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv *env, jclass clz, int8_tArray pubkey) {
41198         LDKPublicKey pubkey_ref;
41199         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
41200         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
41201         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
41202         int64_t ret_ref = 0;
41203         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41204         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41205         return ret_ref;
41206 }
41207
41208 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1slice(JNIEnv *env, jclass clz, int64_t this_arg) {
41209         LDKNodeId this_arg_conv;
41210         this_arg_conv.inner = untag_ptr(this_arg);
41211         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41213         this_arg_conv.is_owned = false;
41214         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
41215         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41216         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41217         return ret_arr;
41218 }
41219
41220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1hash(JNIEnv *env, jclass clz, int64_t o) {
41221         LDKNodeId o_conv;
41222         o_conv.inner = untag_ptr(o);
41223         o_conv.is_owned = ptr_is_owned(o);
41224         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41225         o_conv.is_owned = false;
41226         int64_t ret_conv = NodeId_hash(&o_conv);
41227         return ret_conv;
41228 }
41229
41230 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1write(JNIEnv *env, jclass clz, int64_t obj) {
41231         LDKNodeId obj_conv;
41232         obj_conv.inner = untag_ptr(obj);
41233         obj_conv.is_owned = ptr_is_owned(obj);
41234         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41235         obj_conv.is_owned = false;
41236         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
41237         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41238         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41239         CVec_u8Z_free(ret_var);
41240         return ret_arr;
41241 }
41242
41243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41244         LDKu8slice ser_ref;
41245         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41246         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41247         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
41248         *ret_conv = NodeId_read(ser_ref);
41249         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41250         return tag_ptr(ret_conv, true);
41251 }
41252
41253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41254         LDKNetworkGraph this_obj_conv;
41255         this_obj_conv.inner = untag_ptr(this_obj);
41256         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41258         NetworkGraph_free(this_obj_conv);
41259 }
41260
41261 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41262         LDKReadOnlyNetworkGraph this_obj_conv;
41263         this_obj_conv.inner = untag_ptr(this_obj);
41264         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41266         ReadOnlyNetworkGraph_free(this_obj_conv);
41267 }
41268
41269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
41270         if (!ptr_is_owned(this_ptr)) return;
41271         void* this_ptr_ptr = untag_ptr(this_ptr);
41272         CHECK_ACCESS(this_ptr_ptr);
41273         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
41274         FREE(untag_ptr(this_ptr));
41275         NetworkUpdate_free(this_ptr_conv);
41276 }
41277
41278 static inline uint64_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
41279         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
41280         *ret_copy = NetworkUpdate_clone(arg);
41281         int64_t ret_ref = tag_ptr(ret_copy, true);
41282         return ret_ref;
41283 }
41284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41285         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)untag_ptr(arg);
41286         int64_t ret_conv = NetworkUpdate_clone_ptr(arg_conv);
41287         return ret_conv;
41288 }
41289
41290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41291         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)untag_ptr(orig);
41292         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
41293         *ret_copy = NetworkUpdate_clone(orig_conv);
41294         int64_t ret_ref = tag_ptr(ret_copy, true);
41295         return ret_ref;
41296 }
41297
41298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
41299         LDKChannelUpdate msg_conv;
41300         msg_conv.inner = untag_ptr(msg);
41301         msg_conv.is_owned = ptr_is_owned(msg);
41302         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41303         msg_conv = ChannelUpdate_clone(&msg_conv);
41304         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
41305         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
41306         int64_t ret_ref = tag_ptr(ret_copy, true);
41307         return ret_ref;
41308 }
41309
41310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1failure(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
41311         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
41312         *ret_copy = NetworkUpdate_channel_failure(short_channel_id, is_permanent);
41313         int64_t ret_ref = tag_ptr(ret_copy, true);
41314         return ret_ref;
41315 }
41316
41317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
41318         LDKPublicKey node_id_ref;
41319         CHECK((*env)->GetArrayLength(env, node_id) == 33);
41320         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
41321         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
41322         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
41323         int64_t ret_ref = tag_ptr(ret_copy, true);
41324         return ret_ref;
41325 }
41326
41327 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
41328         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)untag_ptr(obj);
41329         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
41330         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41331         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41332         CVec_u8Z_free(ret_var);
41333         return ret_arr;
41334 }
41335
41336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41337         LDKu8slice ser_ref;
41338         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41339         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41340         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
41341         *ret_conv = NetworkUpdate_read(ser_ref);
41342         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41343         return tag_ptr(ret_conv, true);
41344 }
41345
41346 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41347         LDKP2PGossipSync this_obj_conv;
41348         this_obj_conv.inner = untag_ptr(this_obj);
41349         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41351         P2PGossipSync_free(this_obj_conv);
41352 }
41353
41354 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) {
41355         LDKNetworkGraph network_graph_conv;
41356         network_graph_conv.inner = untag_ptr(network_graph);
41357         network_graph_conv.is_owned = ptr_is_owned(network_graph);
41358         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
41359         network_graph_conv.is_owned = false;
41360         void* chain_access_ptr = untag_ptr(chain_access);
41361         CHECK_ACCESS(chain_access_ptr);
41362         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
41363         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
41364         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
41365                 // Manually implement clone for Java trait instances
41366                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
41367                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41368                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
41369                 }
41370         }
41371         void* logger_ptr = untag_ptr(logger);
41372         CHECK_ACCESS(logger_ptr);
41373         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
41374         if (logger_conv.free == LDKLogger_JCalls_free) {
41375                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41376                 LDKLogger_JCalls_cloned(&logger_conv);
41377         }
41378         LDKP2PGossipSync ret_var = P2PGossipSync_new(&network_graph_conv, chain_access_conv, logger_conv);
41379         int64_t ret_ref = 0;
41380         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41381         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41382         return ret_ref;
41383 }
41384
41385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
41386         LDKP2PGossipSync this_arg_conv;
41387         this_arg_conv.inner = untag_ptr(this_arg);
41388         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41390         this_arg_conv.is_owned = false;
41391         void* chain_access_ptr = untag_ptr(chain_access);
41392         CHECK_ACCESS(chain_access_ptr);
41393         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
41394         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
41395         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
41396                 // Manually implement clone for Java trait instances
41397                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
41398                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41399                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
41400                 }
41401         }
41402         P2PGossipSync_add_chain_access(&this_arg_conv, chain_access_conv);
41403 }
41404
41405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
41406         LDKNetworkGraph this_arg_conv;
41407         this_arg_conv.inner = untag_ptr(this_arg);
41408         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41410         this_arg_conv.is_owned = false;
41411         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
41412         *ret_ret = NetworkGraph_as_EventHandler(&this_arg_conv);
41413         return tag_ptr(ret_ret, true);
41414 }
41415
41416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
41417         LDKP2PGossipSync this_arg_conv;
41418         this_arg_conv.inner = untag_ptr(this_arg);
41419         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41421         this_arg_conv.is_owned = false;
41422         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
41423         *ret_ret = P2PGossipSync_as_RoutingMessageHandler(&this_arg_conv);
41424         return tag_ptr(ret_ret, true);
41425 }
41426
41427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
41428         LDKP2PGossipSync this_arg_conv;
41429         this_arg_conv.inner = untag_ptr(this_arg);
41430         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41432         this_arg_conv.is_owned = false;
41433         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
41434         *ret_ret = P2PGossipSync_as_MessageSendEventsProvider(&this_arg_conv);
41435         return tag_ptr(ret_ret, true);
41436 }
41437
41438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41439         LDKChannelUpdateInfo this_obj_conv;
41440         this_obj_conv.inner = untag_ptr(this_obj);
41441         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41443         ChannelUpdateInfo_free(this_obj_conv);
41444 }
41445
41446 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
41447         LDKChannelUpdateInfo this_ptr_conv;
41448         this_ptr_conv.inner = untag_ptr(this_ptr);
41449         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41451         this_ptr_conv.is_owned = false;
41452         int32_t ret_conv = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
41453         return ret_conv;
41454 }
41455
41456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
41457         LDKChannelUpdateInfo this_ptr_conv;
41458         this_ptr_conv.inner = untag_ptr(this_ptr);
41459         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41461         this_ptr_conv.is_owned = false;
41462         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
41463 }
41464
41465 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
41466         LDKChannelUpdateInfo this_ptr_conv;
41467         this_ptr_conv.inner = untag_ptr(this_ptr);
41468         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41470         this_ptr_conv.is_owned = false;
41471         jboolean ret_conv = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
41472         return ret_conv;
41473 }
41474
41475 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
41476         LDKChannelUpdateInfo this_ptr_conv;
41477         this_ptr_conv.inner = untag_ptr(this_ptr);
41478         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41480         this_ptr_conv.is_owned = false;
41481         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
41482 }
41483
41484 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
41485         LDKChannelUpdateInfo this_ptr_conv;
41486         this_ptr_conv.inner = untag_ptr(this_ptr);
41487         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41489         this_ptr_conv.is_owned = false;
41490         int16_t ret_conv = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
41491         return ret_conv;
41492 }
41493
41494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
41495         LDKChannelUpdateInfo this_ptr_conv;
41496         this_ptr_conv.inner = untag_ptr(this_ptr);
41497         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41499         this_ptr_conv.is_owned = false;
41500         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
41501 }
41502
41503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
41504         LDKChannelUpdateInfo this_ptr_conv;
41505         this_ptr_conv.inner = untag_ptr(this_ptr);
41506         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41508         this_ptr_conv.is_owned = false;
41509         int64_t ret_conv = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
41510         return ret_conv;
41511 }
41512
41513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41514         LDKChannelUpdateInfo this_ptr_conv;
41515         this_ptr_conv.inner = untag_ptr(this_ptr);
41516         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41518         this_ptr_conv.is_owned = false;
41519         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
41520 }
41521
41522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
41523         LDKChannelUpdateInfo this_ptr_conv;
41524         this_ptr_conv.inner = untag_ptr(this_ptr);
41525         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41527         this_ptr_conv.is_owned = false;
41528         int64_t ret_conv = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
41529         return ret_conv;
41530 }
41531
41532 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41533         LDKChannelUpdateInfo this_ptr_conv;
41534         this_ptr_conv.inner = untag_ptr(this_ptr);
41535         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41537         this_ptr_conv.is_owned = false;
41538         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val);
41539 }
41540
41541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
41542         LDKChannelUpdateInfo this_ptr_conv;
41543         this_ptr_conv.inner = untag_ptr(this_ptr);
41544         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41546         this_ptr_conv.is_owned = false;
41547         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
41548         int64_t ret_ref = 0;
41549         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41550         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41551         return ret_ref;
41552 }
41553
41554 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41555         LDKChannelUpdateInfo this_ptr_conv;
41556         this_ptr_conv.inner = untag_ptr(this_ptr);
41557         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41559         this_ptr_conv.is_owned = false;
41560         LDKRoutingFees val_conv;
41561         val_conv.inner = untag_ptr(val);
41562         val_conv.is_owned = ptr_is_owned(val);
41563         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41564         val_conv = RoutingFees_clone(&val_conv);
41565         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
41566 }
41567
41568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
41569         LDKChannelUpdateInfo this_ptr_conv;
41570         this_ptr_conv.inner = untag_ptr(this_ptr);
41571         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41573         this_ptr_conv.is_owned = false;
41574         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
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 void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41582         LDKChannelUpdateInfo this_ptr_conv;
41583         this_ptr_conv.inner = untag_ptr(this_ptr);
41584         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41586         this_ptr_conv.is_owned = false;
41587         LDKChannelUpdate val_conv;
41588         val_conv.inner = untag_ptr(val);
41589         val_conv.is_owned = ptr_is_owned(val);
41590         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41591         val_conv = ChannelUpdate_clone(&val_conv);
41592         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
41593 }
41594
41595 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) {
41596         LDKRoutingFees fees_arg_conv;
41597         fees_arg_conv.inner = untag_ptr(fees_arg);
41598         fees_arg_conv.is_owned = ptr_is_owned(fees_arg);
41599         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
41600         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
41601         LDKChannelUpdate last_update_message_arg_conv;
41602         last_update_message_arg_conv.inner = untag_ptr(last_update_message_arg);
41603         last_update_message_arg_conv.is_owned = ptr_is_owned(last_update_message_arg);
41604         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
41605         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
41606         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);
41607         int64_t ret_ref = 0;
41608         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41609         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41610         return ret_ref;
41611 }
41612
41613 static inline uint64_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
41614         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
41615         int64_t ret_ref = 0;
41616         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41617         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41618         return ret_ref;
41619 }
41620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41621         LDKChannelUpdateInfo arg_conv;
41622         arg_conv.inner = untag_ptr(arg);
41623         arg_conv.is_owned = ptr_is_owned(arg);
41624         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41625         arg_conv.is_owned = false;
41626         int64_t ret_conv = ChannelUpdateInfo_clone_ptr(&arg_conv);
41627         return ret_conv;
41628 }
41629
41630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41631         LDKChannelUpdateInfo orig_conv;
41632         orig_conv.inner = untag_ptr(orig);
41633         orig_conv.is_owned = ptr_is_owned(orig);
41634         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41635         orig_conv.is_owned = false;
41636         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
41637         int64_t ret_ref = 0;
41638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41639         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41640         return ret_ref;
41641 }
41642
41643 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
41644         LDKChannelUpdateInfo obj_conv;
41645         obj_conv.inner = untag_ptr(obj);
41646         obj_conv.is_owned = ptr_is_owned(obj);
41647         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41648         obj_conv.is_owned = false;
41649         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
41650         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41651         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41652         CVec_u8Z_free(ret_var);
41653         return ret_arr;
41654 }
41655
41656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41657         LDKu8slice ser_ref;
41658         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41659         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41660         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
41661         *ret_conv = ChannelUpdateInfo_read(ser_ref);
41662         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41663         return tag_ptr(ret_conv, true);
41664 }
41665
41666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41667         LDKChannelInfo this_obj_conv;
41668         this_obj_conv.inner = untag_ptr(this_obj);
41669         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41671         ChannelInfo_free(this_obj_conv);
41672 }
41673
41674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
41675         LDKChannelInfo this_ptr_conv;
41676         this_ptr_conv.inner = untag_ptr(this_ptr);
41677         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41679         this_ptr_conv.is_owned = false;
41680         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
41681         int64_t ret_ref = 0;
41682         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41683         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41684         return ret_ref;
41685 }
41686
41687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41688         LDKChannelInfo this_ptr_conv;
41689         this_ptr_conv.inner = untag_ptr(this_ptr);
41690         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41692         this_ptr_conv.is_owned = false;
41693         LDKChannelFeatures val_conv;
41694         val_conv.inner = untag_ptr(val);
41695         val_conv.is_owned = ptr_is_owned(val);
41696         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41697         val_conv = ChannelFeatures_clone(&val_conv);
41698         ChannelInfo_set_features(&this_ptr_conv, val_conv);
41699 }
41700
41701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
41702         LDKChannelInfo this_ptr_conv;
41703         this_ptr_conv.inner = untag_ptr(this_ptr);
41704         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41706         this_ptr_conv.is_owned = false;
41707         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
41708         int64_t ret_ref = 0;
41709         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41710         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41711         return ret_ref;
41712 }
41713
41714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41715         LDKChannelInfo this_ptr_conv;
41716         this_ptr_conv.inner = untag_ptr(this_ptr);
41717         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41719         this_ptr_conv.is_owned = false;
41720         LDKNodeId val_conv;
41721         val_conv.inner = untag_ptr(val);
41722         val_conv.is_owned = ptr_is_owned(val);
41723         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41724         val_conv = NodeId_clone(&val_conv);
41725         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
41726 }
41727
41728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
41729         LDKChannelInfo this_ptr_conv;
41730         this_ptr_conv.inner = untag_ptr(this_ptr);
41731         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41733         this_ptr_conv.is_owned = false;
41734         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
41735         int64_t ret_ref = 0;
41736         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41737         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41738         return ret_ref;
41739 }
41740
41741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41742         LDKChannelInfo this_ptr_conv;
41743         this_ptr_conv.inner = untag_ptr(this_ptr);
41744         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41746         this_ptr_conv.is_owned = false;
41747         LDKChannelUpdateInfo val_conv;
41748         val_conv.inner = untag_ptr(val);
41749         val_conv.is_owned = ptr_is_owned(val);
41750         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41751         val_conv = ChannelUpdateInfo_clone(&val_conv);
41752         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
41753 }
41754
41755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
41756         LDKChannelInfo this_ptr_conv;
41757         this_ptr_conv.inner = untag_ptr(this_ptr);
41758         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41760         this_ptr_conv.is_owned = false;
41761         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
41762         int64_t ret_ref = 0;
41763         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41764         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41765         return ret_ref;
41766 }
41767
41768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41769         LDKChannelInfo this_ptr_conv;
41770         this_ptr_conv.inner = untag_ptr(this_ptr);
41771         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41773         this_ptr_conv.is_owned = false;
41774         LDKNodeId val_conv;
41775         val_conv.inner = untag_ptr(val);
41776         val_conv.is_owned = ptr_is_owned(val);
41777         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41778         val_conv = NodeId_clone(&val_conv);
41779         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
41780 }
41781
41782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
41783         LDKChannelInfo this_ptr_conv;
41784         this_ptr_conv.inner = untag_ptr(this_ptr);
41785         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41787         this_ptr_conv.is_owned = false;
41788         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
41789         int64_t ret_ref = 0;
41790         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41791         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41792         return ret_ref;
41793 }
41794
41795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41796         LDKChannelInfo this_ptr_conv;
41797         this_ptr_conv.inner = untag_ptr(this_ptr);
41798         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41800         this_ptr_conv.is_owned = false;
41801         LDKChannelUpdateInfo val_conv;
41802         val_conv.inner = untag_ptr(val);
41803         val_conv.is_owned = ptr_is_owned(val);
41804         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41805         val_conv = ChannelUpdateInfo_clone(&val_conv);
41806         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
41807 }
41808
41809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
41810         LDKChannelInfo this_ptr_conv;
41811         this_ptr_conv.inner = untag_ptr(this_ptr);
41812         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41814         this_ptr_conv.is_owned = false;
41815         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
41816         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
41817         int64_t ret_ref = tag_ptr(ret_copy, true);
41818         return ret_ref;
41819 }
41820
41821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41822         LDKChannelInfo this_ptr_conv;
41823         this_ptr_conv.inner = untag_ptr(this_ptr);
41824         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41826         this_ptr_conv.is_owned = false;
41827         void* val_ptr = untag_ptr(val);
41828         CHECK_ACCESS(val_ptr);
41829         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
41830         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
41831         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
41832 }
41833
41834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
41835         LDKChannelInfo this_ptr_conv;
41836         this_ptr_conv.inner = untag_ptr(this_ptr);
41837         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41839         this_ptr_conv.is_owned = false;
41840         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
41841         int64_t ret_ref = 0;
41842         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41843         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41844         return ret_ref;
41845 }
41846
41847 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41848         LDKChannelInfo this_ptr_conv;
41849         this_ptr_conv.inner = untag_ptr(this_ptr);
41850         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41852         this_ptr_conv.is_owned = false;
41853         LDKChannelAnnouncement val_conv;
41854         val_conv.inner = untag_ptr(val);
41855         val_conv.is_owned = ptr_is_owned(val);
41856         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41857         val_conv = ChannelAnnouncement_clone(&val_conv);
41858         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
41859 }
41860
41861 static inline uint64_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
41862         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
41863         int64_t ret_ref = 0;
41864         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41865         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41866         return ret_ref;
41867 }
41868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41869         LDKChannelInfo arg_conv;
41870         arg_conv.inner = untag_ptr(arg);
41871         arg_conv.is_owned = ptr_is_owned(arg);
41872         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41873         arg_conv.is_owned = false;
41874         int64_t ret_conv = ChannelInfo_clone_ptr(&arg_conv);
41875         return ret_conv;
41876 }
41877
41878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41879         LDKChannelInfo orig_conv;
41880         orig_conv.inner = untag_ptr(orig);
41881         orig_conv.is_owned = ptr_is_owned(orig);
41882         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41883         orig_conv.is_owned = false;
41884         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
41885         int64_t ret_ref = 0;
41886         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41887         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41888         return ret_ref;
41889 }
41890
41891 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) {
41892         LDKChannelInfo this_arg_conv;
41893         this_arg_conv.inner = untag_ptr(this_arg);
41894         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41896         this_arg_conv.is_owned = false;
41897         LDKChannelUpdateInfo ret_var = ChannelInfo_get_directional_info(&this_arg_conv, channel_flags);
41898         int64_t ret_ref = 0;
41899         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41900         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41901         return ret_ref;
41902 }
41903
41904 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
41905         LDKChannelInfo obj_conv;
41906         obj_conv.inner = untag_ptr(obj);
41907         obj_conv.is_owned = ptr_is_owned(obj);
41908         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41909         obj_conv.is_owned = false;
41910         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
41911         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41912         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41913         CVec_u8Z_free(ret_var);
41914         return ret_arr;
41915 }
41916
41917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41918         LDKu8slice ser_ref;
41919         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41920         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41921         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
41922         *ret_conv = ChannelInfo_read(ser_ref);
41923         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41924         return tag_ptr(ret_conv, true);
41925 }
41926
41927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41928         LDKDirectedChannelInfo this_obj_conv;
41929         this_obj_conv.inner = untag_ptr(this_obj);
41930         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41932         DirectedChannelInfo_free(this_obj_conv);
41933 }
41934
41935 static inline uint64_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
41936         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
41937         int64_t ret_ref = 0;
41938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41939         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41940         return ret_ref;
41941 }
41942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41943         LDKDirectedChannelInfo arg_conv;
41944         arg_conv.inner = untag_ptr(arg);
41945         arg_conv.is_owned = ptr_is_owned(arg);
41946         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41947         arg_conv.is_owned = false;
41948         int64_t ret_conv = DirectedChannelInfo_clone_ptr(&arg_conv);
41949         return ret_conv;
41950 }
41951
41952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41953         LDKDirectedChannelInfo orig_conv;
41954         orig_conv.inner = untag_ptr(orig);
41955         orig_conv.is_owned = ptr_is_owned(orig);
41956         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41957         orig_conv.is_owned = false;
41958         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
41959         int64_t ret_ref = 0;
41960         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41961         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41962         return ret_ref;
41963 }
41964
41965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1channel(JNIEnv *env, jclass clz, int64_t this_arg) {
41966         LDKDirectedChannelInfo this_arg_conv;
41967         this_arg_conv.inner = untag_ptr(this_arg);
41968         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41970         this_arg_conv.is_owned = false;
41971         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
41972         int64_t ret_ref = 0;
41973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41974         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41975         return ret_ref;
41976 }
41977
41978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1direction(JNIEnv *env, jclass clz, int64_t this_arg) {
41979         LDKDirectedChannelInfo this_arg_conv;
41980         this_arg_conv.inner = untag_ptr(this_arg);
41981         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41983         this_arg_conv.is_owned = false;
41984         LDKChannelUpdateInfo ret_var = DirectedChannelInfo_direction(&this_arg_conv);
41985         int64_t ret_ref = 0;
41986         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41987         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41988         return ret_ref;
41989 }
41990
41991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
41992         LDKDirectedChannelInfo this_arg_conv;
41993         this_arg_conv.inner = untag_ptr(this_arg);
41994         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41996         this_arg_conv.is_owned = false;
41997         int64_t ret_conv = DirectedChannelInfo_htlc_maximum_msat(&this_arg_conv);
41998         return ret_conv;
41999 }
42000
42001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_arg) {
42002         LDKDirectedChannelInfo 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         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42008         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
42009         int64_t ret_ref = tag_ptr(ret_copy, true);
42010         return ret_ref;
42011 }
42012
42013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42014         if (!ptr_is_owned(this_ptr)) return;
42015         void* this_ptr_ptr = untag_ptr(this_ptr);
42016         CHECK_ACCESS(this_ptr_ptr);
42017         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
42018         FREE(untag_ptr(this_ptr));
42019         EffectiveCapacity_free(this_ptr_conv);
42020 }
42021
42022 static inline uint64_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
42023         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42024         *ret_copy = EffectiveCapacity_clone(arg);
42025         int64_t ret_ref = tag_ptr(ret_copy, true);
42026         return ret_ref;
42027 }
42028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42029         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)untag_ptr(arg);
42030         int64_t ret_conv = EffectiveCapacity_clone_ptr(arg_conv);
42031         return ret_conv;
42032 }
42033
42034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42035         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)untag_ptr(orig);
42036         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42037         *ret_copy = EffectiveCapacity_clone(orig_conv);
42038         int64_t ret_ref = tag_ptr(ret_copy, true);
42039         return ret_ref;
42040 }
42041
42042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1exact_1liquidity(JNIEnv *env, jclass clz, int64_t liquidity_msat) {
42043         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42044         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
42045         int64_t ret_ref = tag_ptr(ret_copy, true);
42046         return ret_ref;
42047 }
42048
42049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1maximum_1htlc(JNIEnv *env, jclass clz, int64_t amount_msat) {
42050         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42051         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
42052         int64_t ret_ref = tag_ptr(ret_copy, true);
42053         return ret_ref;
42054 }
42055
42056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1total(JNIEnv *env, jclass clz, int64_t capacity_msat, int64_t htlc_maximum_msat) {
42057         void* htlc_maximum_msat_ptr = untag_ptr(htlc_maximum_msat);
42058         CHECK_ACCESS(htlc_maximum_msat_ptr);
42059         LDKCOption_u64Z htlc_maximum_msat_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_ptr);
42060         htlc_maximum_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_maximum_msat));
42061         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42062         *ret_copy = EffectiveCapacity_total(capacity_msat, htlc_maximum_msat_conv);
42063         int64_t ret_ref = tag_ptr(ret_copy, true);
42064         return ret_ref;
42065 }
42066
42067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1infinite(JNIEnv *env, jclass clz) {
42068         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42069         *ret_copy = EffectiveCapacity_infinite();
42070         int64_t ret_ref = tag_ptr(ret_copy, true);
42071         return ret_ref;
42072 }
42073
42074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1unknown(JNIEnv *env, jclass clz) {
42075         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42076         *ret_copy = EffectiveCapacity_unknown();
42077         int64_t ret_ref = tag_ptr(ret_copy, true);
42078         return ret_ref;
42079 }
42080
42081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1as_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
42082         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)untag_ptr(this_arg);
42083         int64_t ret_conv = EffectiveCapacity_as_msat(this_arg_conv);
42084         return ret_conv;
42085 }
42086
42087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42088         LDKRoutingFees this_obj_conv;
42089         this_obj_conv.inner = untag_ptr(this_obj);
42090         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42092         RoutingFees_free(this_obj_conv);
42093 }
42094
42095 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42096         LDKRoutingFees this_ptr_conv;
42097         this_ptr_conv.inner = untag_ptr(this_ptr);
42098         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42100         this_ptr_conv.is_owned = false;
42101         int32_t ret_conv = RoutingFees_get_base_msat(&this_ptr_conv);
42102         return ret_conv;
42103 }
42104
42105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
42106         LDKRoutingFees this_ptr_conv;
42107         this_ptr_conv.inner = untag_ptr(this_ptr);
42108         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42110         this_ptr_conv.is_owned = false;
42111         RoutingFees_set_base_msat(&this_ptr_conv, val);
42112 }
42113
42114 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
42115         LDKRoutingFees this_ptr_conv;
42116         this_ptr_conv.inner = untag_ptr(this_ptr);
42117         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42119         this_ptr_conv.is_owned = false;
42120         int32_t ret_conv = RoutingFees_get_proportional_millionths(&this_ptr_conv);
42121         return ret_conv;
42122 }
42123
42124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
42125         LDKRoutingFees this_ptr_conv;
42126         this_ptr_conv.inner = untag_ptr(this_ptr);
42127         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42129         this_ptr_conv.is_owned = false;
42130         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
42131 }
42132
42133 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) {
42134         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
42135         int64_t ret_ref = 0;
42136         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42137         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42138         return ret_ref;
42139 }
42140
42141 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42142         LDKRoutingFees a_conv;
42143         a_conv.inner = untag_ptr(a);
42144         a_conv.is_owned = ptr_is_owned(a);
42145         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42146         a_conv.is_owned = false;
42147         LDKRoutingFees b_conv;
42148         b_conv.inner = untag_ptr(b);
42149         b_conv.is_owned = ptr_is_owned(b);
42150         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42151         b_conv.is_owned = false;
42152         jboolean ret_conv = RoutingFees_eq(&a_conv, &b_conv);
42153         return ret_conv;
42154 }
42155
42156 static inline uint64_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
42157         LDKRoutingFees ret_var = RoutingFees_clone(arg);
42158         int64_t ret_ref = 0;
42159         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42160         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42161         return ret_ref;
42162 }
42163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42164         LDKRoutingFees arg_conv;
42165         arg_conv.inner = untag_ptr(arg);
42166         arg_conv.is_owned = ptr_is_owned(arg);
42167         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42168         arg_conv.is_owned = false;
42169         int64_t ret_conv = RoutingFees_clone_ptr(&arg_conv);
42170         return ret_conv;
42171 }
42172
42173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42174         LDKRoutingFees orig_conv;
42175         orig_conv.inner = untag_ptr(orig);
42176         orig_conv.is_owned = ptr_is_owned(orig);
42177         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42178         orig_conv.is_owned = false;
42179         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
42180         int64_t ret_ref = 0;
42181         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42182         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42183         return ret_ref;
42184 }
42185
42186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) {
42187         LDKRoutingFees o_conv;
42188         o_conv.inner = untag_ptr(o);
42189         o_conv.is_owned = ptr_is_owned(o);
42190         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42191         o_conv.is_owned = false;
42192         int64_t ret_conv = RoutingFees_hash(&o_conv);
42193         return ret_conv;
42194 }
42195
42196 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
42197         LDKRoutingFees obj_conv;
42198         obj_conv.inner = untag_ptr(obj);
42199         obj_conv.is_owned = ptr_is_owned(obj);
42200         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42201         obj_conv.is_owned = false;
42202         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
42203         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42204         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42205         CVec_u8Z_free(ret_var);
42206         return ret_arr;
42207 }
42208
42209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42210         LDKu8slice ser_ref;
42211         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42212         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42213         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
42214         *ret_conv = RoutingFees_read(ser_ref);
42215         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42216         return tag_ptr(ret_conv, true);
42217 }
42218
42219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42220         LDKNodeAnnouncementInfo this_obj_conv;
42221         this_obj_conv.inner = untag_ptr(this_obj);
42222         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42224         NodeAnnouncementInfo_free(this_obj_conv);
42225 }
42226
42227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
42228         LDKNodeAnnouncementInfo this_ptr_conv;
42229         this_ptr_conv.inner = untag_ptr(this_ptr);
42230         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42232         this_ptr_conv.is_owned = false;
42233         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
42234         int64_t ret_ref = 0;
42235         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42236         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42237         return ret_ref;
42238 }
42239
42240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42241         LDKNodeAnnouncementInfo this_ptr_conv;
42242         this_ptr_conv.inner = untag_ptr(this_ptr);
42243         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42245         this_ptr_conv.is_owned = false;
42246         LDKNodeFeatures val_conv;
42247         val_conv.inner = untag_ptr(val);
42248         val_conv.is_owned = ptr_is_owned(val);
42249         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42250         val_conv = NodeFeatures_clone(&val_conv);
42251         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
42252 }
42253
42254 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
42255         LDKNodeAnnouncementInfo this_ptr_conv;
42256         this_ptr_conv.inner = untag_ptr(this_ptr);
42257         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42259         this_ptr_conv.is_owned = false;
42260         int32_t ret_conv = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
42261         return ret_conv;
42262 }
42263
42264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
42265         LDKNodeAnnouncementInfo this_ptr_conv;
42266         this_ptr_conv.inner = untag_ptr(this_ptr);
42267         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42269         this_ptr_conv.is_owned = false;
42270         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
42271 }
42272
42273 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
42274         LDKNodeAnnouncementInfo this_ptr_conv;
42275         this_ptr_conv.inner = untag_ptr(this_ptr);
42276         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42278         this_ptr_conv.is_owned = false;
42279         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
42280         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
42281         return ret_arr;
42282 }
42283
42284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42285         LDKNodeAnnouncementInfo this_ptr_conv;
42286         this_ptr_conv.inner = untag_ptr(this_ptr);
42287         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42289         this_ptr_conv.is_owned = false;
42290         LDKThreeBytes val_ref;
42291         CHECK((*env)->GetArrayLength(env, val) == 3);
42292         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
42293         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
42294 }
42295
42296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
42297         LDKNodeAnnouncementInfo this_ptr_conv;
42298         this_ptr_conv.inner = untag_ptr(this_ptr);
42299         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42301         this_ptr_conv.is_owned = false;
42302         LDKNodeAlias ret_var = NodeAnnouncementInfo_get_alias(&this_ptr_conv);
42303         int64_t ret_ref = 0;
42304         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42305         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42306         return ret_ref;
42307 }
42308
42309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42310         LDKNodeAnnouncementInfo this_ptr_conv;
42311         this_ptr_conv.inner = untag_ptr(this_ptr);
42312         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42314         this_ptr_conv.is_owned = false;
42315         LDKNodeAlias val_conv;
42316         val_conv.inner = untag_ptr(val);
42317         val_conv.is_owned = ptr_is_owned(val);
42318         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42319         val_conv = NodeAlias_clone(&val_conv);
42320         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_conv);
42321 }
42322
42323 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr) {
42324         LDKNodeAnnouncementInfo this_ptr_conv;
42325         this_ptr_conv.inner = untag_ptr(this_ptr);
42326         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42328         this_ptr_conv.is_owned = false;
42329         LDKCVec_NetAddressZ ret_var = NodeAnnouncementInfo_get_addresses(&this_ptr_conv);
42330         int64_tArray ret_arr = NULL;
42331         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
42332         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
42333         for (size_t m = 0; m < ret_var.datalen; m++) {
42334                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
42335                 *ret_conv_12_copy = ret_var.data[m];
42336                 int64_t ret_conv_12_ref = tag_ptr(ret_conv_12_copy, true);
42337                 ret_arr_ptr[m] = ret_conv_12_ref;
42338         }
42339         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
42340         FREE(ret_var.data);
42341         return ret_arr;
42342 }
42343
42344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
42345         LDKNodeAnnouncementInfo this_ptr_conv;
42346         this_ptr_conv.inner = untag_ptr(this_ptr);
42347         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42349         this_ptr_conv.is_owned = false;
42350         LDKCVec_NetAddressZ val_constr;
42351         val_constr.datalen = (*env)->GetArrayLength(env, val);
42352         if (val_constr.datalen > 0)
42353                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
42354         else
42355                 val_constr.data = NULL;
42356         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
42357         for (size_t m = 0; m < val_constr.datalen; m++) {
42358                 int64_t val_conv_12 = val_vals[m];
42359                 void* val_conv_12_ptr = untag_ptr(val_conv_12);
42360                 CHECK_ACCESS(val_conv_12_ptr);
42361                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
42362                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(val_conv_12));
42363                 val_constr.data[m] = val_conv_12_conv;
42364         }
42365         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
42366         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
42367 }
42368
42369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
42370         LDKNodeAnnouncementInfo this_ptr_conv;
42371         this_ptr_conv.inner = untag_ptr(this_ptr);
42372         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42374         this_ptr_conv.is_owned = false;
42375         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
42376         int64_t ret_ref = 0;
42377         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42378         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42379         return ret_ref;
42380 }
42381
42382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42383         LDKNodeAnnouncementInfo this_ptr_conv;
42384         this_ptr_conv.inner = untag_ptr(this_ptr);
42385         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42387         this_ptr_conv.is_owned = false;
42388         LDKNodeAnnouncement val_conv;
42389         val_conv.inner = untag_ptr(val);
42390         val_conv.is_owned = ptr_is_owned(val);
42391         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42392         val_conv = NodeAnnouncement_clone(&val_conv);
42393         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
42394 }
42395
42396 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) {
42397         LDKNodeFeatures features_arg_conv;
42398         features_arg_conv.inner = untag_ptr(features_arg);
42399         features_arg_conv.is_owned = ptr_is_owned(features_arg);
42400         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
42401         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
42402         LDKThreeBytes rgb_arg_ref;
42403         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
42404         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
42405         LDKNodeAlias alias_arg_conv;
42406         alias_arg_conv.inner = untag_ptr(alias_arg);
42407         alias_arg_conv.is_owned = ptr_is_owned(alias_arg);
42408         CHECK_INNER_FIELD_ACCESS_OR_NULL(alias_arg_conv);
42409         alias_arg_conv = NodeAlias_clone(&alias_arg_conv);
42410         LDKCVec_NetAddressZ addresses_arg_constr;
42411         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
42412         if (addresses_arg_constr.datalen > 0)
42413                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
42414         else
42415                 addresses_arg_constr.data = NULL;
42416         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
42417         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
42418                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
42419                 void* addresses_arg_conv_12_ptr = untag_ptr(addresses_arg_conv_12);
42420                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
42421                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
42422                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
42423         }
42424         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
42425         LDKNodeAnnouncement announcement_message_arg_conv;
42426         announcement_message_arg_conv.inner = untag_ptr(announcement_message_arg);
42427         announcement_message_arg_conv.is_owned = ptr_is_owned(announcement_message_arg);
42428         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
42429         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
42430         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_conv, addresses_arg_constr, announcement_message_arg_conv);
42431         int64_t ret_ref = 0;
42432         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42433         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42434         return ret_ref;
42435 }
42436
42437 static inline uint64_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
42438         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
42439         int64_t ret_ref = 0;
42440         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42441         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42442         return ret_ref;
42443 }
42444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42445         LDKNodeAnnouncementInfo arg_conv;
42446         arg_conv.inner = untag_ptr(arg);
42447         arg_conv.is_owned = ptr_is_owned(arg);
42448         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42449         arg_conv.is_owned = false;
42450         int64_t ret_conv = NodeAnnouncementInfo_clone_ptr(&arg_conv);
42451         return ret_conv;
42452 }
42453
42454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42455         LDKNodeAnnouncementInfo orig_conv;
42456         orig_conv.inner = untag_ptr(orig);
42457         orig_conv.is_owned = ptr_is_owned(orig);
42458         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42459         orig_conv.is_owned = false;
42460         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
42461         int64_t ret_ref = 0;
42462         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42463         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42464         return ret_ref;
42465 }
42466
42467 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
42468         LDKNodeAnnouncementInfo obj_conv;
42469         obj_conv.inner = untag_ptr(obj);
42470         obj_conv.is_owned = ptr_is_owned(obj);
42471         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42472         obj_conv.is_owned = false;
42473         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
42474         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42475         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42476         CVec_u8Z_free(ret_var);
42477         return ret_arr;
42478 }
42479
42480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42481         LDKu8slice ser_ref;
42482         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42483         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42484         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
42485         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
42486         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42487         return tag_ptr(ret_conv, true);
42488 }
42489
42490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42491         LDKNodeAlias this_obj_conv;
42492         this_obj_conv.inner = untag_ptr(this_obj);
42493         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42495         NodeAlias_free(this_obj_conv);
42496 }
42497
42498 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
42499         LDKNodeAlias this_ptr_conv;
42500         this_ptr_conv.inner = untag_ptr(this_ptr);
42501         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42503         this_ptr_conv.is_owned = false;
42504         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42505         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAlias_get_a(&this_ptr_conv));
42506         return ret_arr;
42507 }
42508
42509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42510         LDKNodeAlias this_ptr_conv;
42511         this_ptr_conv.inner = untag_ptr(this_ptr);
42512         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42514         this_ptr_conv.is_owned = false;
42515         LDKThirtyTwoBytes val_ref;
42516         CHECK((*env)->GetArrayLength(env, val) == 32);
42517         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
42518         NodeAlias_set_a(&this_ptr_conv, val_ref);
42519 }
42520
42521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
42522         LDKThirtyTwoBytes a_arg_ref;
42523         CHECK((*env)->GetArrayLength(env, a_arg) == 32);
42524         (*env)->GetByteArrayRegion(env, a_arg, 0, 32, a_arg_ref.data);
42525         LDKNodeAlias ret_var = NodeAlias_new(a_arg_ref);
42526         int64_t ret_ref = 0;
42527         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42528         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42529         return ret_ref;
42530 }
42531
42532 static inline uint64_t NodeAlias_clone_ptr(LDKNodeAlias *NONNULL_PTR arg) {
42533         LDKNodeAlias ret_var = NodeAlias_clone(arg);
42534         int64_t ret_ref = 0;
42535         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42536         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42537         return ret_ref;
42538 }
42539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42540         LDKNodeAlias arg_conv;
42541         arg_conv.inner = untag_ptr(arg);
42542         arg_conv.is_owned = ptr_is_owned(arg);
42543         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42544         arg_conv.is_owned = false;
42545         int64_t ret_conv = NodeAlias_clone_ptr(&arg_conv);
42546         return ret_conv;
42547 }
42548
42549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42550         LDKNodeAlias orig_conv;
42551         orig_conv.inner = untag_ptr(orig);
42552         orig_conv.is_owned = ptr_is_owned(orig);
42553         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42554         orig_conv.is_owned = false;
42555         LDKNodeAlias ret_var = NodeAlias_clone(&orig_conv);
42556         int64_t ret_ref = 0;
42557         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42558         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42559         return ret_ref;
42560 }
42561
42562 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1write(JNIEnv *env, jclass clz, int64_t obj) {
42563         LDKNodeAlias obj_conv;
42564         obj_conv.inner = untag_ptr(obj);
42565         obj_conv.is_owned = ptr_is_owned(obj);
42566         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42567         obj_conv.is_owned = false;
42568         LDKCVec_u8Z ret_var = NodeAlias_write(&obj_conv);
42569         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42570         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42571         CVec_u8Z_free(ret_var);
42572         return ret_arr;
42573 }
42574
42575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42576         LDKu8slice ser_ref;
42577         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42578         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42579         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
42580         *ret_conv = NodeAlias_read(ser_ref);
42581         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42582         return tag_ptr(ret_conv, true);
42583 }
42584
42585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42586         LDKNodeInfo this_obj_conv;
42587         this_obj_conv.inner = untag_ptr(this_obj);
42588         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42590         NodeInfo_free(this_obj_conv);
42591 }
42592
42593 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
42594         LDKNodeInfo this_ptr_conv;
42595         this_ptr_conv.inner = untag_ptr(this_ptr);
42596         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42598         this_ptr_conv.is_owned = false;
42599         LDKCVec_u64Z ret_var = NodeInfo_get_channels(&this_ptr_conv);
42600         int64_tArray ret_arr = NULL;
42601         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
42602         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
42603         for (size_t g = 0; g < ret_var.datalen; g++) {
42604                 int64_t ret_conv_6_conv = ret_var.data[g];
42605                 ret_arr_ptr[g] = ret_conv_6_conv;
42606         }
42607         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
42608         FREE(ret_var.data);
42609         return ret_arr;
42610 }
42611
42612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
42613         LDKNodeInfo this_ptr_conv;
42614         this_ptr_conv.inner = untag_ptr(this_ptr);
42615         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42617         this_ptr_conv.is_owned = false;
42618         LDKCVec_u64Z val_constr;
42619         val_constr.datalen = (*env)->GetArrayLength(env, val);
42620         if (val_constr.datalen > 0)
42621                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
42622         else
42623                 val_constr.data = NULL;
42624         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
42625         for (size_t g = 0; g < val_constr.datalen; g++) {
42626                 int64_t val_conv_6 = val_vals[g];
42627                 val_constr.data[g] = val_conv_6;
42628         }
42629         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
42630         NodeInfo_set_channels(&this_ptr_conv, val_constr);
42631 }
42632
42633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
42634         LDKNodeInfo this_ptr_conv;
42635         this_ptr_conv.inner = untag_ptr(this_ptr);
42636         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42638         this_ptr_conv.is_owned = false;
42639         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
42640         int64_t ret_ref = 0;
42641         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42642         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42643         return ret_ref;
42644 }
42645
42646 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) {
42647         LDKNodeInfo this_ptr_conv;
42648         this_ptr_conv.inner = untag_ptr(this_ptr);
42649         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42651         this_ptr_conv.is_owned = false;
42652         LDKRoutingFees val_conv;
42653         val_conv.inner = untag_ptr(val);
42654         val_conv.is_owned = ptr_is_owned(val);
42655         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42656         val_conv = RoutingFees_clone(&val_conv);
42657         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
42658 }
42659
42660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
42661         LDKNodeInfo this_ptr_conv;
42662         this_ptr_conv.inner = untag_ptr(this_ptr);
42663         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42665         this_ptr_conv.is_owned = false;
42666         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
42667         int64_t ret_ref = 0;
42668         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42669         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42670         return ret_ref;
42671 }
42672
42673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42674         LDKNodeInfo this_ptr_conv;
42675         this_ptr_conv.inner = untag_ptr(this_ptr);
42676         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42678         this_ptr_conv.is_owned = false;
42679         LDKNodeAnnouncementInfo val_conv;
42680         val_conv.inner = untag_ptr(val);
42681         val_conv.is_owned = ptr_is_owned(val);
42682         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42683         val_conv = NodeAnnouncementInfo_clone(&val_conv);
42684         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
42685 }
42686
42687 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) {
42688         LDKCVec_u64Z channels_arg_constr;
42689         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
42690         if (channels_arg_constr.datalen > 0)
42691                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
42692         else
42693                 channels_arg_constr.data = NULL;
42694         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
42695         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
42696                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
42697                 channels_arg_constr.data[g] = channels_arg_conv_6;
42698         }
42699         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
42700         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
42701         lowest_inbound_channel_fees_arg_conv.inner = untag_ptr(lowest_inbound_channel_fees_arg);
42702         lowest_inbound_channel_fees_arg_conv.is_owned = ptr_is_owned(lowest_inbound_channel_fees_arg);
42703         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
42704         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
42705         LDKNodeAnnouncementInfo announcement_info_arg_conv;
42706         announcement_info_arg_conv.inner = untag_ptr(announcement_info_arg);
42707         announcement_info_arg_conv.is_owned = ptr_is_owned(announcement_info_arg);
42708         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
42709         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
42710         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
42711         int64_t ret_ref = 0;
42712         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42713         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42714         return ret_ref;
42715 }
42716
42717 static inline uint64_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
42718         LDKNodeInfo ret_var = NodeInfo_clone(arg);
42719         int64_t ret_ref = 0;
42720         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42721         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42722         return ret_ref;
42723 }
42724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42725         LDKNodeInfo arg_conv;
42726         arg_conv.inner = untag_ptr(arg);
42727         arg_conv.is_owned = ptr_is_owned(arg);
42728         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42729         arg_conv.is_owned = false;
42730         int64_t ret_conv = NodeInfo_clone_ptr(&arg_conv);
42731         return ret_conv;
42732 }
42733
42734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42735         LDKNodeInfo orig_conv;
42736         orig_conv.inner = untag_ptr(orig);
42737         orig_conv.is_owned = ptr_is_owned(orig);
42738         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42739         orig_conv.is_owned = false;
42740         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
42741         int64_t ret_ref = 0;
42742         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42743         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42744         return ret_ref;
42745 }
42746
42747 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
42748         LDKNodeInfo obj_conv;
42749         obj_conv.inner = untag_ptr(obj);
42750         obj_conv.is_owned = ptr_is_owned(obj);
42751         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42752         obj_conv.is_owned = false;
42753         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
42754         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42755         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42756         CVec_u8Z_free(ret_var);
42757         return ret_arr;
42758 }
42759
42760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42761         LDKu8slice ser_ref;
42762         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42763         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42764         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
42765         *ret_conv = NodeInfo_read(ser_ref);
42766         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42767         return tag_ptr(ret_conv, true);
42768 }
42769
42770 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
42771         LDKNetworkGraph obj_conv;
42772         obj_conv.inner = untag_ptr(obj);
42773         obj_conv.is_owned = ptr_is_owned(obj);
42774         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42775         obj_conv.is_owned = false;
42776         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
42777         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42778         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42779         CVec_u8Z_free(ret_var);
42780         return ret_arr;
42781 }
42782
42783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
42784         LDKu8slice ser_ref;
42785         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42786         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42787         void* arg_ptr = untag_ptr(arg);
42788         CHECK_ACCESS(arg_ptr);
42789         LDKLogger arg_conv = *(LDKLogger*)(arg_ptr);
42790         if (arg_conv.free == LDKLogger_JCalls_free) {
42791                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42792                 LDKLogger_JCalls_cloned(&arg_conv);
42793         }
42794         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
42795         *ret_conv = NetworkGraph_read(ser_ref, arg_conv);
42796         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42797         return tag_ptr(ret_conv, true);
42798 }
42799
42800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash, int64_t logger) {
42801         LDKThirtyTwoBytes genesis_hash_ref;
42802         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
42803         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
42804         void* logger_ptr = untag_ptr(logger);
42805         CHECK_ACCESS(logger_ptr);
42806         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
42807         if (logger_conv.free == LDKLogger_JCalls_free) {
42808                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42809                 LDKLogger_JCalls_cloned(&logger_conv);
42810         }
42811         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref, logger_conv);
42812         int64_t ret_ref = 0;
42813         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42814         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42815         return ret_ref;
42816 }
42817
42818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) {
42819         LDKNetworkGraph 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         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
42825         int64_t ret_ref = 0;
42826         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42827         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42828         return ret_ref;
42829 }
42830
42831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1get_1last_1rapid_1gossip_1sync_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
42832         LDKNetworkGraph this_arg_conv;
42833         this_arg_conv.inner = untag_ptr(this_arg);
42834         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42836         this_arg_conv.is_owned = false;
42837         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
42838         *ret_copy = NetworkGraph_get_last_rapid_gossip_sync_timestamp(&this_arg_conv);
42839         int64_t ret_ref = tag_ptr(ret_copy, true);
42840         return ret_ref;
42841 }
42842
42843 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) {
42844         LDKNetworkGraph this_arg_conv;
42845         this_arg_conv.inner = untag_ptr(this_arg);
42846         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42848         this_arg_conv.is_owned = false;
42849         NetworkGraph_set_last_rapid_gossip_sync_timestamp(&this_arg_conv, last_rapid_gossip_sync_timestamp);
42850 }
42851
42852 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) {
42853         LDKNetworkGraph this_arg_conv;
42854         this_arg_conv.inner = untag_ptr(this_arg);
42855         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42857         this_arg_conv.is_owned = false;
42858         LDKNodeAnnouncement msg_conv;
42859         msg_conv.inner = untag_ptr(msg);
42860         msg_conv.is_owned = ptr_is_owned(msg);
42861         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
42862         msg_conv.is_owned = false;
42863         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
42864         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
42865         return tag_ptr(ret_conv, true);
42866 }
42867
42868 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) {
42869         LDKNetworkGraph this_arg_conv;
42870         this_arg_conv.inner = untag_ptr(this_arg);
42871         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42873         this_arg_conv.is_owned = false;
42874         LDKUnsignedNodeAnnouncement msg_conv;
42875         msg_conv.inner = untag_ptr(msg);
42876         msg_conv.is_owned = ptr_is_owned(msg);
42877         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
42878         msg_conv.is_owned = false;
42879         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
42880         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
42881         return tag_ptr(ret_conv, true);
42882 }
42883
42884 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) {
42885         LDKNetworkGraph 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         LDKChannelAnnouncement msg_conv;
42891         msg_conv.inner = untag_ptr(msg);
42892         msg_conv.is_owned = ptr_is_owned(msg);
42893         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
42894         msg_conv.is_owned = false;
42895         void* chain_access_ptr = untag_ptr(chain_access);
42896         CHECK_ACCESS(chain_access_ptr);
42897         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
42898         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
42899         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
42900                 // Manually implement clone for Java trait instances
42901                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
42902                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42903                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
42904                 }
42905         }
42906         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
42907         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
42908         return tag_ptr(ret_conv, true);
42909 }
42910
42911 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) {
42912         LDKNetworkGraph this_arg_conv;
42913         this_arg_conv.inner = untag_ptr(this_arg);
42914         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42916         this_arg_conv.is_owned = false;
42917         LDKUnsignedChannelAnnouncement msg_conv;
42918         msg_conv.inner = untag_ptr(msg);
42919         msg_conv.is_owned = ptr_is_owned(msg);
42920         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
42921         msg_conv.is_owned = false;
42922         void* chain_access_ptr = untag_ptr(chain_access);
42923         CHECK_ACCESS(chain_access_ptr);
42924         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
42925         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
42926         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
42927                 // Manually implement clone for Java trait instances
42928                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
42929                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42930                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
42931                 }
42932         }
42933         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
42934         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
42935         return tag_ptr(ret_conv, true);
42936 }
42937
42938 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) {
42939         LDKNetworkGraph this_arg_conv;
42940         this_arg_conv.inner = untag_ptr(this_arg);
42941         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42943         this_arg_conv.is_owned = false;
42944         LDKChannelFeatures features_conv;
42945         features_conv.inner = untag_ptr(features);
42946         features_conv.is_owned = ptr_is_owned(features);
42947         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
42948         features_conv = ChannelFeatures_clone(&features_conv);
42949         LDKPublicKey node_id_1_ref;
42950         CHECK((*env)->GetArrayLength(env, node_id_1) == 33);
42951         (*env)->GetByteArrayRegion(env, node_id_1, 0, 33, node_id_1_ref.compressed_form);
42952         LDKPublicKey node_id_2_ref;
42953         CHECK((*env)->GetArrayLength(env, node_id_2) == 33);
42954         (*env)->GetByteArrayRegion(env, node_id_2, 0, 33, node_id_2_ref.compressed_form);
42955         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
42956         *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);
42957         return tag_ptr(ret_conv, true);
42958 }
42959
42960 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) {
42961         LDKNetworkGraph 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         NetworkGraph_channel_failed(&this_arg_conv, short_channel_id, is_permanent);
42967 }
42968
42969 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) {
42970         LDKNetworkGraph this_arg_conv;
42971         this_arg_conv.inner = untag_ptr(this_arg);
42972         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42974         this_arg_conv.is_owned = false;
42975         LDKPublicKey _node_id_ref;
42976         CHECK((*env)->GetArrayLength(env, _node_id) == 33);
42977         (*env)->GetByteArrayRegion(env, _node_id, 0, 33, _node_id_ref.compressed_form);
42978         NetworkGraph_node_failed(&this_arg_conv, _node_id_ref, is_permanent);
42979 }
42980
42981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1remove_1stale_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
42982         LDKNetworkGraph this_arg_conv;
42983         this_arg_conv.inner = untag_ptr(this_arg);
42984         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42986         this_arg_conv.is_owned = false;
42987         NetworkGraph_remove_stale_channels(&this_arg_conv);
42988 }
42989
42990 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) {
42991         LDKNetworkGraph this_arg_conv;
42992         this_arg_conv.inner = untag_ptr(this_arg);
42993         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42995         this_arg_conv.is_owned = false;
42996         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
42997 }
42998
42999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
43000         LDKNetworkGraph this_arg_conv;
43001         this_arg_conv.inner = untag_ptr(this_arg);
43002         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43004         this_arg_conv.is_owned = false;
43005         LDKChannelUpdate msg_conv;
43006         msg_conv.inner = untag_ptr(msg);
43007         msg_conv.is_owned = ptr_is_owned(msg);
43008         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
43009         msg_conv.is_owned = false;
43010         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
43011         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
43012         return tag_ptr(ret_conv, true);
43013 }
43014
43015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
43016         LDKNetworkGraph this_arg_conv;
43017         this_arg_conv.inner = untag_ptr(this_arg);
43018         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43020         this_arg_conv.is_owned = false;
43021         LDKUnsignedChannelUpdate msg_conv;
43022         msg_conv.inner = untag_ptr(msg);
43023         msg_conv.is_owned = ptr_is_owned(msg);
43024         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
43025         msg_conv.is_owned = false;
43026         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
43027         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
43028         return tag_ptr(ret_conv, true);
43029 }
43030
43031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id) {
43032         LDKReadOnlyNetworkGraph this_arg_conv;
43033         this_arg_conv.inner = untag_ptr(this_arg);
43034         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43036         this_arg_conv.is_owned = false;
43037         LDKChannelInfo ret_var = ReadOnlyNetworkGraph_channel(&this_arg_conv, short_channel_id);
43038         int64_t ret_ref = 0;
43039         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43040         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43041         return ret_ref;
43042 }
43043
43044 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
43045         LDKReadOnlyNetworkGraph this_arg_conv;
43046         this_arg_conv.inner = untag_ptr(this_arg);
43047         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43049         this_arg_conv.is_owned = false;
43050         LDKCVec_u64Z ret_var = ReadOnlyNetworkGraph_list_channels(&this_arg_conv);
43051         int64_tArray ret_arr = NULL;
43052         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
43053         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
43054         for (size_t g = 0; g < ret_var.datalen; g++) {
43055                 int64_t ret_conv_6_conv = ret_var.data[g];
43056                 ret_arr_ptr[g] = ret_conv_6_conv;
43057         }
43058         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
43059         FREE(ret_var.data);
43060         return ret_arr;
43061 }
43062
43063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1node(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
43064         LDKReadOnlyNetworkGraph this_arg_conv;
43065         this_arg_conv.inner = untag_ptr(this_arg);
43066         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43068         this_arg_conv.is_owned = false;
43069         LDKNodeId node_id_conv;
43070         node_id_conv.inner = untag_ptr(node_id);
43071         node_id_conv.is_owned = ptr_is_owned(node_id);
43072         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
43073         node_id_conv.is_owned = false;
43074         LDKNodeInfo ret_var = ReadOnlyNetworkGraph_node(&this_arg_conv, &node_id_conv);
43075         int64_t ret_ref = 0;
43076         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43077         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43078         return ret_ref;
43079 }
43080
43081 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1list_1nodes(JNIEnv *env, jclass clz, int64_t this_arg) {
43082         LDKReadOnlyNetworkGraph this_arg_conv;
43083         this_arg_conv.inner = untag_ptr(this_arg);
43084         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43086         this_arg_conv.is_owned = false;
43087         LDKCVec_NodeIdZ ret_var = ReadOnlyNetworkGraph_list_nodes(&this_arg_conv);
43088         int64_tArray ret_arr = NULL;
43089         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
43090         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
43091         for (size_t i = 0; i < ret_var.datalen; i++) {
43092                 LDKNodeId ret_conv_8_var = ret_var.data[i];
43093                 int64_t ret_conv_8_ref = 0;
43094                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_8_var);
43095                 ret_conv_8_ref = tag_ptr(ret_conv_8_var.inner, ret_conv_8_var.is_owned);
43096                 ret_arr_ptr[i] = ret_conv_8_ref;
43097         }
43098         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
43099         FREE(ret_var.data);
43100         return ret_arr;
43101 }
43102
43103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey) {
43104         LDKReadOnlyNetworkGraph this_arg_conv;
43105         this_arg_conv.inner = untag_ptr(this_arg);
43106         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43108         this_arg_conv.is_owned = false;
43109         LDKPublicKey pubkey_ref;
43110         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
43111         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
43112         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
43113         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
43114         int64_t ret_ref = tag_ptr(ret_copy, true);
43115         return ret_ref;
43116 }
43117
43118 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43119         LDKRouteHop this_obj_conv;
43120         this_obj_conv.inner = untag_ptr(this_obj);
43121         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43123         RouteHop_free(this_obj_conv);
43124 }
43125
43126 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
43127         LDKRouteHop this_ptr_conv;
43128         this_ptr_conv.inner = untag_ptr(this_ptr);
43129         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43131         this_ptr_conv.is_owned = false;
43132         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
43133         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
43134         return ret_arr;
43135 }
43136
43137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43138         LDKRouteHop this_ptr_conv;
43139         this_ptr_conv.inner = untag_ptr(this_ptr);
43140         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43142         this_ptr_conv.is_owned = false;
43143         LDKPublicKey val_ref;
43144         CHECK((*env)->GetArrayLength(env, val) == 33);
43145         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
43146         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
43147 }
43148
43149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
43150         LDKRouteHop this_ptr_conv;
43151         this_ptr_conv.inner = untag_ptr(this_ptr);
43152         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43154         this_ptr_conv.is_owned = false;
43155         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
43156         int64_t ret_ref = 0;
43157         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43158         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43159         return ret_ref;
43160 }
43161
43162 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43163         LDKRouteHop this_ptr_conv;
43164         this_ptr_conv.inner = untag_ptr(this_ptr);
43165         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43167         this_ptr_conv.is_owned = false;
43168         LDKNodeFeatures val_conv;
43169         val_conv.inner = untag_ptr(val);
43170         val_conv.is_owned = ptr_is_owned(val);
43171         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43172         val_conv = NodeFeatures_clone(&val_conv);
43173         RouteHop_set_node_features(&this_ptr_conv, val_conv);
43174 }
43175
43176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
43177         LDKRouteHop this_ptr_conv;
43178         this_ptr_conv.inner = untag_ptr(this_ptr);
43179         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43181         this_ptr_conv.is_owned = false;
43182         int64_t ret_conv = RouteHop_get_short_channel_id(&this_ptr_conv);
43183         return ret_conv;
43184 }
43185
43186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43187         LDKRouteHop this_ptr_conv;
43188         this_ptr_conv.inner = untag_ptr(this_ptr);
43189         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43191         this_ptr_conv.is_owned = false;
43192         RouteHop_set_short_channel_id(&this_ptr_conv, val);
43193 }
43194
43195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
43196         LDKRouteHop this_ptr_conv;
43197         this_ptr_conv.inner = untag_ptr(this_ptr);
43198         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43200         this_ptr_conv.is_owned = false;
43201         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
43202         int64_t ret_ref = 0;
43203         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43204         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43205         return ret_ref;
43206 }
43207
43208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43209         LDKRouteHop this_ptr_conv;
43210         this_ptr_conv.inner = untag_ptr(this_ptr);
43211         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43213         this_ptr_conv.is_owned = false;
43214         LDKChannelFeatures val_conv;
43215         val_conv.inner = untag_ptr(val);
43216         val_conv.is_owned = ptr_is_owned(val);
43217         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43218         val_conv = ChannelFeatures_clone(&val_conv);
43219         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
43220 }
43221
43222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43223         LDKRouteHop this_ptr_conv;
43224         this_ptr_conv.inner = untag_ptr(this_ptr);
43225         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43227         this_ptr_conv.is_owned = false;
43228         int64_t ret_conv = RouteHop_get_fee_msat(&this_ptr_conv);
43229         return ret_conv;
43230 }
43231
43232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43233         LDKRouteHop this_ptr_conv;
43234         this_ptr_conv.inner = untag_ptr(this_ptr);
43235         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43237         this_ptr_conv.is_owned = false;
43238         RouteHop_set_fee_msat(&this_ptr_conv, val);
43239 }
43240
43241 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
43242         LDKRouteHop this_ptr_conv;
43243         this_ptr_conv.inner = untag_ptr(this_ptr);
43244         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43246         this_ptr_conv.is_owned = false;
43247         int32_t ret_conv = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
43248         return ret_conv;
43249 }
43250
43251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
43252         LDKRouteHop this_ptr_conv;
43253         this_ptr_conv.inner = untag_ptr(this_ptr);
43254         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43256         this_ptr_conv.is_owned = false;
43257         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
43258 }
43259
43260 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) {
43261         LDKPublicKey pubkey_arg_ref;
43262         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
43263         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
43264         LDKNodeFeatures node_features_arg_conv;
43265         node_features_arg_conv.inner = untag_ptr(node_features_arg);
43266         node_features_arg_conv.is_owned = ptr_is_owned(node_features_arg);
43267         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
43268         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
43269         LDKChannelFeatures channel_features_arg_conv;
43270         channel_features_arg_conv.inner = untag_ptr(channel_features_arg);
43271         channel_features_arg_conv.is_owned = ptr_is_owned(channel_features_arg);
43272         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
43273         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
43274         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);
43275         int64_t ret_ref = 0;
43276         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43277         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43278         return ret_ref;
43279 }
43280
43281 static inline uint64_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
43282         LDKRouteHop ret_var = RouteHop_clone(arg);
43283         int64_t ret_ref = 0;
43284         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43285         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43286         return ret_ref;
43287 }
43288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43289         LDKRouteHop arg_conv;
43290         arg_conv.inner = untag_ptr(arg);
43291         arg_conv.is_owned = ptr_is_owned(arg);
43292         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43293         arg_conv.is_owned = false;
43294         int64_t ret_conv = RouteHop_clone_ptr(&arg_conv);
43295         return ret_conv;
43296 }
43297
43298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43299         LDKRouteHop orig_conv;
43300         orig_conv.inner = untag_ptr(orig);
43301         orig_conv.is_owned = ptr_is_owned(orig);
43302         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43303         orig_conv.is_owned = false;
43304         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
43305         int64_t ret_ref = 0;
43306         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43307         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43308         return ret_ref;
43309 }
43310
43311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
43312         LDKRouteHop o_conv;
43313         o_conv.inner = untag_ptr(o);
43314         o_conv.is_owned = ptr_is_owned(o);
43315         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43316         o_conv.is_owned = false;
43317         int64_t ret_conv = RouteHop_hash(&o_conv);
43318         return ret_conv;
43319 }
43320
43321 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43322         LDKRouteHop a_conv;
43323         a_conv.inner = untag_ptr(a);
43324         a_conv.is_owned = ptr_is_owned(a);
43325         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43326         a_conv.is_owned = false;
43327         LDKRouteHop b_conv;
43328         b_conv.inner = untag_ptr(b);
43329         b_conv.is_owned = ptr_is_owned(b);
43330         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43331         b_conv.is_owned = false;
43332         jboolean ret_conv = RouteHop_eq(&a_conv, &b_conv);
43333         return ret_conv;
43334 }
43335
43336 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
43337         LDKRouteHop obj_conv;
43338         obj_conv.inner = untag_ptr(obj);
43339         obj_conv.is_owned = ptr_is_owned(obj);
43340         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43341         obj_conv.is_owned = false;
43342         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
43343         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43344         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43345         CVec_u8Z_free(ret_var);
43346         return ret_arr;
43347 }
43348
43349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43350         LDKu8slice ser_ref;
43351         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43352         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43353         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
43354         *ret_conv = RouteHop_read(ser_ref);
43355         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43356         return tag_ptr(ret_conv, true);
43357 }
43358
43359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43360         LDKRoute this_obj_conv;
43361         this_obj_conv.inner = untag_ptr(this_obj);
43362         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43364         Route_free(this_obj_conv);
43365 }
43366
43367 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) {
43368         LDKRoute this_ptr_conv;
43369         this_ptr_conv.inner = untag_ptr(this_ptr);
43370         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43372         this_ptr_conv.is_owned = false;
43373         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
43374         jobjectArray ret_arr = NULL;
43375         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_J_clz, NULL);
43376         ;
43377         for (size_t m = 0; m < ret_var.datalen; m++) {
43378                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
43379                 int64_tArray ret_conv_12_arr = NULL;
43380                 ret_conv_12_arr = (*env)->NewLongArray(env, ret_conv_12_var.datalen);
43381                 int64_t *ret_conv_12_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_conv_12_arr, NULL);
43382                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
43383                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
43384                         int64_t ret_conv_12_conv_10_ref = 0;
43385                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
43386                         ret_conv_12_conv_10_ref = tag_ptr(ret_conv_12_conv_10_var.inner, ret_conv_12_conv_10_var.is_owned);
43387                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
43388                 }
43389                 (*env)->ReleasePrimitiveArrayCritical(env, ret_conv_12_arr, ret_conv_12_arr_ptr, 0);
43390                 FREE(ret_conv_12_var.data);
43391                 (*env)->SetObjectArrayElement(env, ret_arr, m, ret_conv_12_arr);
43392         }
43393         
43394         FREE(ret_var.data);
43395         return ret_arr;
43396 }
43397
43398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
43399         LDKRoute this_ptr_conv;
43400         this_ptr_conv.inner = untag_ptr(this_ptr);
43401         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43403         this_ptr_conv.is_owned = false;
43404         LDKCVec_CVec_RouteHopZZ val_constr;
43405         val_constr.datalen = (*env)->GetArrayLength(env, val);
43406         if (val_constr.datalen > 0)
43407                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
43408         else
43409                 val_constr.data = NULL;
43410         for (size_t m = 0; m < val_constr.datalen; m++) {
43411                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
43412                 LDKCVec_RouteHopZ val_conv_12_constr;
43413                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
43414                 if (val_conv_12_constr.datalen > 0)
43415                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
43416                 else
43417                         val_conv_12_constr.data = NULL;
43418                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
43419                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
43420                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
43421                         LDKRouteHop val_conv_12_conv_10_conv;
43422                         val_conv_12_conv_10_conv.inner = untag_ptr(val_conv_12_conv_10);
43423                         val_conv_12_conv_10_conv.is_owned = ptr_is_owned(val_conv_12_conv_10);
43424                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
43425                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
43426                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
43427                 }
43428                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
43429                 val_constr.data[m] = val_conv_12_constr;
43430         }
43431         Route_set_paths(&this_ptr_conv, val_constr);
43432 }
43433
43434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
43435         LDKRoute this_ptr_conv;
43436         this_ptr_conv.inner = untag_ptr(this_ptr);
43437         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43439         this_ptr_conv.is_owned = false;
43440         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
43441         int64_t ret_ref = 0;
43442         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43443         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43444         return ret_ref;
43445 }
43446
43447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43448         LDKRoute this_ptr_conv;
43449         this_ptr_conv.inner = untag_ptr(this_ptr);
43450         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43452         this_ptr_conv.is_owned = false;
43453         LDKPaymentParameters val_conv;
43454         val_conv.inner = untag_ptr(val);
43455         val_conv.is_owned = ptr_is_owned(val);
43456         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43457         val_conv = PaymentParameters_clone(&val_conv);
43458         Route_set_payment_params(&this_ptr_conv, val_conv);
43459 }
43460
43461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg, int64_t payment_params_arg) {
43462         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
43463         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
43464         if (paths_arg_constr.datalen > 0)
43465                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
43466         else
43467                 paths_arg_constr.data = NULL;
43468         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
43469                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
43470                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
43471                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
43472                 if (paths_arg_conv_12_constr.datalen > 0)
43473                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
43474                 else
43475                         paths_arg_conv_12_constr.data = NULL;
43476                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
43477                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
43478                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
43479                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
43480                         paths_arg_conv_12_conv_10_conv.inner = untag_ptr(paths_arg_conv_12_conv_10);
43481                         paths_arg_conv_12_conv_10_conv.is_owned = ptr_is_owned(paths_arg_conv_12_conv_10);
43482                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
43483                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
43484                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
43485                 }
43486                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
43487                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
43488         }
43489         LDKPaymentParameters payment_params_arg_conv;
43490         payment_params_arg_conv.inner = untag_ptr(payment_params_arg);
43491         payment_params_arg_conv.is_owned = ptr_is_owned(payment_params_arg);
43492         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
43493         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
43494         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
43495         int64_t ret_ref = 0;
43496         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43497         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43498         return ret_ref;
43499 }
43500
43501 static inline uint64_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
43502         LDKRoute ret_var = Route_clone(arg);
43503         int64_t ret_ref = 0;
43504         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43505         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43506         return ret_ref;
43507 }
43508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43509         LDKRoute arg_conv;
43510         arg_conv.inner = untag_ptr(arg);
43511         arg_conv.is_owned = ptr_is_owned(arg);
43512         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43513         arg_conv.is_owned = false;
43514         int64_t ret_conv = Route_clone_ptr(&arg_conv);
43515         return ret_conv;
43516 }
43517
43518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43519         LDKRoute orig_conv;
43520         orig_conv.inner = untag_ptr(orig);
43521         orig_conv.is_owned = ptr_is_owned(orig);
43522         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43523         orig_conv.is_owned = false;
43524         LDKRoute ret_var = Route_clone(&orig_conv);
43525         int64_t ret_ref = 0;
43526         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43527         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43528         return ret_ref;
43529 }
43530
43531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) {
43532         LDKRoute o_conv;
43533         o_conv.inner = untag_ptr(o);
43534         o_conv.is_owned = ptr_is_owned(o);
43535         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43536         o_conv.is_owned = false;
43537         int64_t ret_conv = Route_hash(&o_conv);
43538         return ret_conv;
43539 }
43540
43541 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43542         LDKRoute a_conv;
43543         a_conv.inner = untag_ptr(a);
43544         a_conv.is_owned = ptr_is_owned(a);
43545         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43546         a_conv.is_owned = false;
43547         LDKRoute b_conv;
43548         b_conv.inner = untag_ptr(b);
43549         b_conv.is_owned = ptr_is_owned(b);
43550         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43551         b_conv.is_owned = false;
43552         jboolean ret_conv = Route_eq(&a_conv, &b_conv);
43553         return ret_conv;
43554 }
43555
43556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) {
43557         LDKRoute this_arg_conv;
43558         this_arg_conv.inner = untag_ptr(this_arg);
43559         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43561         this_arg_conv.is_owned = false;
43562         int64_t ret_conv = Route_get_total_fees(&this_arg_conv);
43563         return ret_conv;
43564 }
43565
43566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
43567         LDKRoute this_arg_conv;
43568         this_arg_conv.inner = untag_ptr(this_arg);
43569         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43571         this_arg_conv.is_owned = false;
43572         int64_t ret_conv = Route_get_total_amount(&this_arg_conv);
43573         return ret_conv;
43574 }
43575
43576 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
43577         LDKRoute obj_conv;
43578         obj_conv.inner = untag_ptr(obj);
43579         obj_conv.is_owned = ptr_is_owned(obj);
43580         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43581         obj_conv.is_owned = false;
43582         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
43583         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43584         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43585         CVec_u8Z_free(ret_var);
43586         return ret_arr;
43587 }
43588
43589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43590         LDKu8slice ser_ref;
43591         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43592         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43593         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
43594         *ret_conv = Route_read(ser_ref);
43595         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43596         return tag_ptr(ret_conv, true);
43597 }
43598
43599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43600         LDKRouteParameters this_obj_conv;
43601         this_obj_conv.inner = untag_ptr(this_obj);
43602         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43604         RouteParameters_free(this_obj_conv);
43605 }
43606
43607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
43608         LDKRouteParameters this_ptr_conv;
43609         this_ptr_conv.inner = untag_ptr(this_ptr);
43610         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43612         this_ptr_conv.is_owned = false;
43613         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
43614         int64_t ret_ref = 0;
43615         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43616         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43617         return ret_ref;
43618 }
43619
43620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43621         LDKRouteParameters this_ptr_conv;
43622         this_ptr_conv.inner = untag_ptr(this_ptr);
43623         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43625         this_ptr_conv.is_owned = false;
43626         LDKPaymentParameters val_conv;
43627         val_conv.inner = untag_ptr(val);
43628         val_conv.is_owned = ptr_is_owned(val);
43629         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43630         val_conv = PaymentParameters_clone(&val_conv);
43631         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
43632 }
43633
43634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43635         LDKRouteParameters this_ptr_conv;
43636         this_ptr_conv.inner = untag_ptr(this_ptr);
43637         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43639         this_ptr_conv.is_owned = false;
43640         int64_t ret_conv = RouteParameters_get_final_value_msat(&this_ptr_conv);
43641         return ret_conv;
43642 }
43643
43644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43645         LDKRouteParameters this_ptr_conv;
43646         this_ptr_conv.inner = untag_ptr(this_ptr);
43647         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43649         this_ptr_conv.is_owned = false;
43650         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
43651 }
43652
43653 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
43654         LDKRouteParameters this_ptr_conv;
43655         this_ptr_conv.inner = untag_ptr(this_ptr);
43656         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43658         this_ptr_conv.is_owned = false;
43659         int32_t ret_conv = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
43660         return ret_conv;
43661 }
43662
43663 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) {
43664         LDKRouteParameters this_ptr_conv;
43665         this_ptr_conv.inner = untag_ptr(this_ptr);
43666         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43668         this_ptr_conv.is_owned = false;
43669         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
43670 }
43671
43672 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) {
43673         LDKPaymentParameters payment_params_arg_conv;
43674         payment_params_arg_conv.inner = untag_ptr(payment_params_arg);
43675         payment_params_arg_conv.is_owned = ptr_is_owned(payment_params_arg);
43676         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
43677         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
43678         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
43679         int64_t ret_ref = 0;
43680         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43681         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43682         return ret_ref;
43683 }
43684
43685 static inline uint64_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
43686         LDKRouteParameters ret_var = RouteParameters_clone(arg);
43687         int64_t ret_ref = 0;
43688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43689         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43690         return ret_ref;
43691 }
43692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43693         LDKRouteParameters arg_conv;
43694         arg_conv.inner = untag_ptr(arg);
43695         arg_conv.is_owned = ptr_is_owned(arg);
43696         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43697         arg_conv.is_owned = false;
43698         int64_t ret_conv = RouteParameters_clone_ptr(&arg_conv);
43699         return ret_conv;
43700 }
43701
43702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43703         LDKRouteParameters orig_conv;
43704         orig_conv.inner = untag_ptr(orig);
43705         orig_conv.is_owned = ptr_is_owned(orig);
43706         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43707         orig_conv.is_owned = false;
43708         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
43709         int64_t ret_ref = 0;
43710         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43711         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43712         return ret_ref;
43713 }
43714
43715 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
43716         LDKRouteParameters obj_conv;
43717         obj_conv.inner = untag_ptr(obj);
43718         obj_conv.is_owned = ptr_is_owned(obj);
43719         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43720         obj_conv.is_owned = false;
43721         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
43722         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43723         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43724         CVec_u8Z_free(ret_var);
43725         return ret_arr;
43726 }
43727
43728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43729         LDKu8slice ser_ref;
43730         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43731         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43732         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
43733         *ret_conv = RouteParameters_read(ser_ref);
43734         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43735         return tag_ptr(ret_conv, true);
43736 }
43737
43738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43739         LDKPaymentParameters this_obj_conv;
43740         this_obj_conv.inner = untag_ptr(this_obj);
43741         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43743         PaymentParameters_free(this_obj_conv);
43744 }
43745
43746 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
43747         LDKPaymentParameters this_ptr_conv;
43748         this_ptr_conv.inner = untag_ptr(this_ptr);
43749         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43751         this_ptr_conv.is_owned = false;
43752         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
43753         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form);
43754         return ret_arr;
43755 }
43756
43757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43758         LDKPaymentParameters this_ptr_conv;
43759         this_ptr_conv.inner = untag_ptr(this_ptr);
43760         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43762         this_ptr_conv.is_owned = false;
43763         LDKPublicKey val_ref;
43764         CHECK((*env)->GetArrayLength(env, val) == 33);
43765         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
43766         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
43767 }
43768
43769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
43770         LDKPaymentParameters this_ptr_conv;
43771         this_ptr_conv.inner = untag_ptr(this_ptr);
43772         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43774         this_ptr_conv.is_owned = false;
43775         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
43776         int64_t ret_ref = 0;
43777         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43778         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43779         return ret_ref;
43780 }
43781
43782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43783         LDKPaymentParameters this_ptr_conv;
43784         this_ptr_conv.inner = untag_ptr(this_ptr);
43785         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43787         this_ptr_conv.is_owned = false;
43788         LDKInvoiceFeatures val_conv;
43789         val_conv.inner = untag_ptr(val);
43790         val_conv.is_owned = ptr_is_owned(val);
43791         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43792         val_conv = InvoiceFeatures_clone(&val_conv);
43793         PaymentParameters_set_features(&this_ptr_conv, val_conv);
43794 }
43795
43796 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr) {
43797         LDKPaymentParameters this_ptr_conv;
43798         this_ptr_conv.inner = untag_ptr(this_ptr);
43799         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43801         this_ptr_conv.is_owned = false;
43802         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
43803         int64_tArray ret_arr = NULL;
43804         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
43805         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
43806         for (size_t l = 0; l < ret_var.datalen; l++) {
43807                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
43808                 int64_t ret_conv_11_ref = 0;
43809                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
43810                 ret_conv_11_ref = tag_ptr(ret_conv_11_var.inner, ret_conv_11_var.is_owned);
43811                 ret_arr_ptr[l] = ret_conv_11_ref;
43812         }
43813         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
43814         FREE(ret_var.data);
43815         return ret_arr;
43816 }
43817
43818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
43819         LDKPaymentParameters this_ptr_conv;
43820         this_ptr_conv.inner = untag_ptr(this_ptr);
43821         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43823         this_ptr_conv.is_owned = false;
43824         LDKCVec_RouteHintZ val_constr;
43825         val_constr.datalen = (*env)->GetArrayLength(env, val);
43826         if (val_constr.datalen > 0)
43827                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
43828         else
43829                 val_constr.data = NULL;
43830         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
43831         for (size_t l = 0; l < val_constr.datalen; l++) {
43832                 int64_t val_conv_11 = val_vals[l];
43833                 LDKRouteHint val_conv_11_conv;
43834                 val_conv_11_conv.inner = untag_ptr(val_conv_11);
43835                 val_conv_11_conv.is_owned = ptr_is_owned(val_conv_11);
43836                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
43837                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
43838                 val_constr.data[l] = val_conv_11_conv;
43839         }
43840         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
43841         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
43842 }
43843
43844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr) {
43845         LDKPaymentParameters 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         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
43851         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
43852         int64_t ret_ref = tag_ptr(ret_copy, true);
43853         return ret_ref;
43854 }
43855
43856 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43857         LDKPaymentParameters this_ptr_conv;
43858         this_ptr_conv.inner = untag_ptr(this_ptr);
43859         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43861         this_ptr_conv.is_owned = false;
43862         void* val_ptr = untag_ptr(val);
43863         CHECK_ACCESS(val_ptr);
43864         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
43865         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
43866         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
43867 }
43868
43869 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1total_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
43870         LDKPaymentParameters this_ptr_conv;
43871         this_ptr_conv.inner = untag_ptr(this_ptr);
43872         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43874         this_ptr_conv.is_owned = false;
43875         int32_t ret_conv = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
43876         return ret_conv;
43877 }
43878
43879 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) {
43880         LDKPaymentParameters this_ptr_conv;
43881         this_ptr_conv.inner = untag_ptr(this_ptr);
43882         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43884         this_ptr_conv.is_owned = false;
43885         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
43886 }
43887
43888 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr) {
43889         LDKPaymentParameters this_ptr_conv;
43890         this_ptr_conv.inner = untag_ptr(this_ptr);
43891         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43893         this_ptr_conv.is_owned = false;
43894         int8_t ret_conv = PaymentParameters_get_max_path_count(&this_ptr_conv);
43895         return ret_conv;
43896 }
43897
43898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1max_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
43899         LDKPaymentParameters 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         PaymentParameters_set_max_path_count(&this_ptr_conv, val);
43905 }
43906
43907 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) {
43908         LDKPaymentParameters this_ptr_conv;
43909         this_ptr_conv.inner = untag_ptr(this_ptr);
43910         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43912         this_ptr_conv.is_owned = false;
43913         int8_t ret_conv = PaymentParameters_get_max_channel_saturation_power_of_half(&this_ptr_conv);
43914         return ret_conv;
43915 }
43916
43917 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) {
43918         LDKPaymentParameters this_ptr_conv;
43919         this_ptr_conv.inner = untag_ptr(this_ptr);
43920         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43922         this_ptr_conv.is_owned = false;
43923         PaymentParameters_set_max_channel_saturation_power_of_half(&this_ptr_conv, val);
43924 }
43925
43926 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1previously_1failed_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
43927         LDKPaymentParameters this_ptr_conv;
43928         this_ptr_conv.inner = untag_ptr(this_ptr);
43929         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43931         this_ptr_conv.is_owned = false;
43932         LDKCVec_u64Z ret_var = PaymentParameters_get_previously_failed_channels(&this_ptr_conv);
43933         int64_tArray ret_arr = NULL;
43934         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
43935         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
43936         for (size_t g = 0; g < ret_var.datalen; g++) {
43937                 int64_t ret_conv_6_conv = ret_var.data[g];
43938                 ret_arr_ptr[g] = ret_conv_6_conv;
43939         }
43940         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
43941         FREE(ret_var.data);
43942         return ret_arr;
43943 }
43944
43945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1previously_1failed_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
43946         LDKPaymentParameters this_ptr_conv;
43947         this_ptr_conv.inner = untag_ptr(this_ptr);
43948         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43950         this_ptr_conv.is_owned = false;
43951         LDKCVec_u64Z val_constr;
43952         val_constr.datalen = (*env)->GetArrayLength(env, val);
43953         if (val_constr.datalen > 0)
43954                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
43955         else
43956                 val_constr.data = NULL;
43957         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
43958         for (size_t g = 0; g < val_constr.datalen; g++) {
43959                 int64_t val_conv_6 = val_vals[g];
43960                 val_constr.data[g] = val_conv_6;
43961         }
43962         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
43963         PaymentParameters_set_previously_failed_channels(&this_ptr_conv, val_constr);
43964 }
43965
43966 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) {
43967         LDKPublicKey payee_pubkey_arg_ref;
43968         CHECK((*env)->GetArrayLength(env, payee_pubkey_arg) == 33);
43969         (*env)->GetByteArrayRegion(env, payee_pubkey_arg, 0, 33, payee_pubkey_arg_ref.compressed_form);
43970         LDKInvoiceFeatures features_arg_conv;
43971         features_arg_conv.inner = untag_ptr(features_arg);
43972         features_arg_conv.is_owned = ptr_is_owned(features_arg);
43973         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
43974         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
43975         LDKCVec_RouteHintZ route_hints_arg_constr;
43976         route_hints_arg_constr.datalen = (*env)->GetArrayLength(env, route_hints_arg);
43977         if (route_hints_arg_constr.datalen > 0)
43978                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
43979         else
43980                 route_hints_arg_constr.data = NULL;
43981         int64_t* route_hints_arg_vals = (*env)->GetLongArrayElements (env, route_hints_arg, NULL);
43982         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
43983                 int64_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
43984                 LDKRouteHint route_hints_arg_conv_11_conv;
43985                 route_hints_arg_conv_11_conv.inner = untag_ptr(route_hints_arg_conv_11);
43986                 route_hints_arg_conv_11_conv.is_owned = ptr_is_owned(route_hints_arg_conv_11);
43987                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
43988                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
43989                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
43990         }
43991         (*env)->ReleaseLongArrayElements(env, route_hints_arg, route_hints_arg_vals, 0);
43992         void* expiry_time_arg_ptr = untag_ptr(expiry_time_arg);
43993         CHECK_ACCESS(expiry_time_arg_ptr);
43994         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
43995         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(expiry_time_arg));
43996         LDKCVec_u64Z previously_failed_channels_arg_constr;
43997         previously_failed_channels_arg_constr.datalen = (*env)->GetArrayLength(env, previously_failed_channels_arg);
43998         if (previously_failed_channels_arg_constr.datalen > 0)
43999                 previously_failed_channels_arg_constr.data = MALLOC(previously_failed_channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
44000         else
44001                 previously_failed_channels_arg_constr.data = NULL;
44002         int64_t* previously_failed_channels_arg_vals = (*env)->GetLongArrayElements (env, previously_failed_channels_arg, NULL);
44003         for (size_t g = 0; g < previously_failed_channels_arg_constr.datalen; g++) {
44004                 int64_t previously_failed_channels_arg_conv_6 = previously_failed_channels_arg_vals[g];
44005                 previously_failed_channels_arg_constr.data[g] = previously_failed_channels_arg_conv_6;
44006         }
44007         (*env)->ReleaseLongArrayElements(env, previously_failed_channels_arg, previously_failed_channels_arg_vals, 0);
44008         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);
44009         int64_t ret_ref = 0;
44010         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44011         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44012         return ret_ref;
44013 }
44014
44015 static inline uint64_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
44016         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
44017         int64_t ret_ref = 0;
44018         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44019         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44020         return ret_ref;
44021 }
44022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44023         LDKPaymentParameters arg_conv;
44024         arg_conv.inner = untag_ptr(arg);
44025         arg_conv.is_owned = ptr_is_owned(arg);
44026         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44027         arg_conv.is_owned = false;
44028         int64_t ret_conv = PaymentParameters_clone_ptr(&arg_conv);
44029         return ret_conv;
44030 }
44031
44032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44033         LDKPaymentParameters orig_conv;
44034         orig_conv.inner = untag_ptr(orig);
44035         orig_conv.is_owned = ptr_is_owned(orig);
44036         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44037         orig_conv.is_owned = false;
44038         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
44039         int64_t ret_ref = 0;
44040         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44041         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44042         return ret_ref;
44043 }
44044
44045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1hash(JNIEnv *env, jclass clz, int64_t o) {
44046         LDKPaymentParameters o_conv;
44047         o_conv.inner = untag_ptr(o);
44048         o_conv.is_owned = ptr_is_owned(o);
44049         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44050         o_conv.is_owned = false;
44051         int64_t ret_conv = PaymentParameters_hash(&o_conv);
44052         return ret_conv;
44053 }
44054
44055 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44056         LDKPaymentParameters a_conv;
44057         a_conv.inner = untag_ptr(a);
44058         a_conv.is_owned = ptr_is_owned(a);
44059         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44060         a_conv.is_owned = false;
44061         LDKPaymentParameters b_conv;
44062         b_conv.inner = untag_ptr(b);
44063         b_conv.is_owned = ptr_is_owned(b);
44064         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44065         b_conv.is_owned = false;
44066         jboolean ret_conv = PaymentParameters_eq(&a_conv, &b_conv);
44067         return ret_conv;
44068 }
44069
44070 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
44071         LDKPaymentParameters obj_conv;
44072         obj_conv.inner = untag_ptr(obj);
44073         obj_conv.is_owned = ptr_is_owned(obj);
44074         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44075         obj_conv.is_owned = false;
44076         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
44077         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44078         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44079         CVec_u8Z_free(ret_var);
44080         return ret_arr;
44081 }
44082
44083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44084         LDKu8slice ser_ref;
44085         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44086         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44087         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
44088         *ret_conv = PaymentParameters_read(ser_ref);
44089         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44090         return tag_ptr(ret_conv, true);
44091 }
44092
44093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1from_1node_1id(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
44094         LDKPublicKey payee_pubkey_ref;
44095         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
44096         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
44097         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
44098         int64_t ret_ref = 0;
44099         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44100         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44101         return ret_ref;
44102 }
44103
44104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1for_1keysend(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
44105         LDKPublicKey payee_pubkey_ref;
44106         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
44107         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
44108         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
44109         int64_t ret_ref = 0;
44110         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44111         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44112         return ret_ref;
44113 }
44114
44115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44116         LDKRouteHint this_obj_conv;
44117         this_obj_conv.inner = untag_ptr(this_obj);
44118         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44120         RouteHint_free(this_obj_conv);
44121 }
44122
44123 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
44124         LDKRouteHint this_ptr_conv;
44125         this_ptr_conv.inner = untag_ptr(this_ptr);
44126         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44128         this_ptr_conv.is_owned = false;
44129         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
44130         int64_tArray ret_arr = NULL;
44131         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
44132         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
44133         for (size_t o = 0; o < ret_var.datalen; o++) {
44134                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
44135                 int64_t ret_conv_14_ref = 0;
44136                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
44137                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
44138                 ret_arr_ptr[o] = ret_conv_14_ref;
44139         }
44140         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
44141         FREE(ret_var.data);
44142         return ret_arr;
44143 }
44144
44145 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
44146         LDKRouteHint this_ptr_conv;
44147         this_ptr_conv.inner = untag_ptr(this_ptr);
44148         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44150         this_ptr_conv.is_owned = false;
44151         LDKCVec_RouteHintHopZ val_constr;
44152         val_constr.datalen = (*env)->GetArrayLength(env, val);
44153         if (val_constr.datalen > 0)
44154                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
44155         else
44156                 val_constr.data = NULL;
44157         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
44158         for (size_t o = 0; o < val_constr.datalen; o++) {
44159                 int64_t val_conv_14 = val_vals[o];
44160                 LDKRouteHintHop val_conv_14_conv;
44161                 val_conv_14_conv.inner = untag_ptr(val_conv_14);
44162                 val_conv_14_conv.is_owned = ptr_is_owned(val_conv_14);
44163                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
44164                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
44165                 val_constr.data[o] = val_conv_14_conv;
44166         }
44167         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
44168         RouteHint_set_a(&this_ptr_conv, val_constr);
44169 }
44170
44171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv *env, jclass clz, int64_tArray a_arg) {
44172         LDKCVec_RouteHintHopZ a_arg_constr;
44173         a_arg_constr.datalen = (*env)->GetArrayLength(env, a_arg);
44174         if (a_arg_constr.datalen > 0)
44175                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
44176         else
44177                 a_arg_constr.data = NULL;
44178         int64_t* a_arg_vals = (*env)->GetLongArrayElements (env, a_arg, NULL);
44179         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
44180                 int64_t a_arg_conv_14 = a_arg_vals[o];
44181                 LDKRouteHintHop a_arg_conv_14_conv;
44182                 a_arg_conv_14_conv.inner = untag_ptr(a_arg_conv_14);
44183                 a_arg_conv_14_conv.is_owned = ptr_is_owned(a_arg_conv_14);
44184                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
44185                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
44186                 a_arg_constr.data[o] = a_arg_conv_14_conv;
44187         }
44188         (*env)->ReleaseLongArrayElements(env, a_arg, a_arg_vals, 0);
44189         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
44190         int64_t ret_ref = 0;
44191         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44192         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44193         return ret_ref;
44194 }
44195
44196 static inline uint64_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
44197         LDKRouteHint ret_var = RouteHint_clone(arg);
44198         int64_t ret_ref = 0;
44199         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44200         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44201         return ret_ref;
44202 }
44203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44204         LDKRouteHint arg_conv;
44205         arg_conv.inner = untag_ptr(arg);
44206         arg_conv.is_owned = ptr_is_owned(arg);
44207         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44208         arg_conv.is_owned = false;
44209         int64_t ret_conv = RouteHint_clone_ptr(&arg_conv);
44210         return ret_conv;
44211 }
44212
44213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44214         LDKRouteHint orig_conv;
44215         orig_conv.inner = untag_ptr(orig);
44216         orig_conv.is_owned = ptr_is_owned(orig);
44217         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44218         orig_conv.is_owned = false;
44219         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
44220         int64_t ret_ref = 0;
44221         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44222         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44223         return ret_ref;
44224 }
44225
44226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) {
44227         LDKRouteHint o_conv;
44228         o_conv.inner = untag_ptr(o);
44229         o_conv.is_owned = ptr_is_owned(o);
44230         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44231         o_conv.is_owned = false;
44232         int64_t ret_conv = RouteHint_hash(&o_conv);
44233         return ret_conv;
44234 }
44235
44236 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44237         LDKRouteHint a_conv;
44238         a_conv.inner = untag_ptr(a);
44239         a_conv.is_owned = ptr_is_owned(a);
44240         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44241         a_conv.is_owned = false;
44242         LDKRouteHint b_conv;
44243         b_conv.inner = untag_ptr(b);
44244         b_conv.is_owned = ptr_is_owned(b);
44245         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44246         b_conv.is_owned = false;
44247         jboolean ret_conv = RouteHint_eq(&a_conv, &b_conv);
44248         return ret_conv;
44249 }
44250
44251 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1write(JNIEnv *env, jclass clz, int64_t obj) {
44252         LDKRouteHint obj_conv;
44253         obj_conv.inner = untag_ptr(obj);
44254         obj_conv.is_owned = ptr_is_owned(obj);
44255         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44256         obj_conv.is_owned = false;
44257         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
44258         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44259         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44260         CVec_u8Z_free(ret_var);
44261         return ret_arr;
44262 }
44263
44264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44265         LDKu8slice ser_ref;
44266         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44267         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44268         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
44269         *ret_conv = RouteHint_read(ser_ref);
44270         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44271         return tag_ptr(ret_conv, true);
44272 }
44273
44274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44275         LDKRouteHintHop this_obj_conv;
44276         this_obj_conv.inner = untag_ptr(this_obj);
44277         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44279         RouteHintHop_free(this_obj_conv);
44280 }
44281
44282 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
44283         LDKRouteHintHop this_ptr_conv;
44284         this_ptr_conv.inner = untag_ptr(this_ptr);
44285         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44287         this_ptr_conv.is_owned = false;
44288         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
44289         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
44290         return ret_arr;
44291 }
44292
44293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
44294         LDKRouteHintHop this_ptr_conv;
44295         this_ptr_conv.inner = untag_ptr(this_ptr);
44296         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44298         this_ptr_conv.is_owned = false;
44299         LDKPublicKey val_ref;
44300         CHECK((*env)->GetArrayLength(env, val) == 33);
44301         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
44302         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
44303 }
44304
44305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
44306         LDKRouteHintHop this_ptr_conv;
44307         this_ptr_conv.inner = untag_ptr(this_ptr);
44308         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44310         this_ptr_conv.is_owned = false;
44311         int64_t ret_conv = RouteHintHop_get_short_channel_id(&this_ptr_conv);
44312         return ret_conv;
44313 }
44314
44315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44316         LDKRouteHintHop this_ptr_conv;
44317         this_ptr_conv.inner = untag_ptr(this_ptr);
44318         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44320         this_ptr_conv.is_owned = false;
44321         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
44322 }
44323
44324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
44325         LDKRouteHintHop this_ptr_conv;
44326         this_ptr_conv.inner = untag_ptr(this_ptr);
44327         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44329         this_ptr_conv.is_owned = false;
44330         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
44331         int64_t ret_ref = 0;
44332         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44333         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44334         return ret_ref;
44335 }
44336
44337 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44338         LDKRouteHintHop this_ptr_conv;
44339         this_ptr_conv.inner = untag_ptr(this_ptr);
44340         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44342         this_ptr_conv.is_owned = false;
44343         LDKRoutingFees val_conv;
44344         val_conv.inner = untag_ptr(val);
44345         val_conv.is_owned = ptr_is_owned(val);
44346         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44347         val_conv = RoutingFees_clone(&val_conv);
44348         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
44349 }
44350
44351 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
44352         LDKRouteHintHop this_ptr_conv;
44353         this_ptr_conv.inner = untag_ptr(this_ptr);
44354         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44356         this_ptr_conv.is_owned = false;
44357         int16_t ret_conv = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
44358         return ret_conv;
44359 }
44360
44361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
44362         LDKRouteHintHop this_ptr_conv;
44363         this_ptr_conv.inner = untag_ptr(this_ptr);
44364         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44366         this_ptr_conv.is_owned = false;
44367         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
44368 }
44369
44370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
44371         LDKRouteHintHop this_ptr_conv;
44372         this_ptr_conv.inner = untag_ptr(this_ptr);
44373         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44375         this_ptr_conv.is_owned = false;
44376         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
44377         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
44378         int64_t ret_ref = tag_ptr(ret_copy, true);
44379         return ret_ref;
44380 }
44381
44382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44383         LDKRouteHintHop this_ptr_conv;
44384         this_ptr_conv.inner = untag_ptr(this_ptr);
44385         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44387         this_ptr_conv.is_owned = false;
44388         void* val_ptr = untag_ptr(val);
44389         CHECK_ACCESS(val_ptr);
44390         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
44391         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
44392         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
44393 }
44394
44395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
44396         LDKRouteHintHop this_ptr_conv;
44397         this_ptr_conv.inner = untag_ptr(this_ptr);
44398         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44400         this_ptr_conv.is_owned = false;
44401         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
44402         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
44403         int64_t ret_ref = tag_ptr(ret_copy, true);
44404         return ret_ref;
44405 }
44406
44407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44408         LDKRouteHintHop this_ptr_conv;
44409         this_ptr_conv.inner = untag_ptr(this_ptr);
44410         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44412         this_ptr_conv.is_owned = false;
44413         void* val_ptr = untag_ptr(val);
44414         CHECK_ACCESS(val_ptr);
44415         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
44416         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
44417         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
44418 }
44419
44420 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) {
44421         LDKPublicKey src_node_id_arg_ref;
44422         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
44423         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
44424         LDKRoutingFees fees_arg_conv;
44425         fees_arg_conv.inner = untag_ptr(fees_arg);
44426         fees_arg_conv.is_owned = ptr_is_owned(fees_arg);
44427         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
44428         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
44429         void* htlc_minimum_msat_arg_ptr = untag_ptr(htlc_minimum_msat_arg);
44430         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
44431         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
44432         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_minimum_msat_arg));
44433         void* htlc_maximum_msat_arg_ptr = untag_ptr(htlc_maximum_msat_arg);
44434         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
44435         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
44436         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_maximum_msat_arg));
44437         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);
44438         int64_t ret_ref = 0;
44439         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44440         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44441         return ret_ref;
44442 }
44443
44444 static inline uint64_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
44445         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
44446         int64_t ret_ref = 0;
44447         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44448         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44449         return ret_ref;
44450 }
44451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44452         LDKRouteHintHop arg_conv;
44453         arg_conv.inner = untag_ptr(arg);
44454         arg_conv.is_owned = ptr_is_owned(arg);
44455         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44456         arg_conv.is_owned = false;
44457         int64_t ret_conv = RouteHintHop_clone_ptr(&arg_conv);
44458         return ret_conv;
44459 }
44460
44461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44462         LDKRouteHintHop orig_conv;
44463         orig_conv.inner = untag_ptr(orig);
44464         orig_conv.is_owned = ptr_is_owned(orig);
44465         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44466         orig_conv.is_owned = false;
44467         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
44468         int64_t ret_ref = 0;
44469         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44470         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44471         return ret_ref;
44472 }
44473
44474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
44475         LDKRouteHintHop o_conv;
44476         o_conv.inner = untag_ptr(o);
44477         o_conv.is_owned = ptr_is_owned(o);
44478         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44479         o_conv.is_owned = false;
44480         int64_t ret_conv = RouteHintHop_hash(&o_conv);
44481         return ret_conv;
44482 }
44483
44484 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44485         LDKRouteHintHop a_conv;
44486         a_conv.inner = untag_ptr(a);
44487         a_conv.is_owned = ptr_is_owned(a);
44488         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44489         a_conv.is_owned = false;
44490         LDKRouteHintHop b_conv;
44491         b_conv.inner = untag_ptr(b);
44492         b_conv.is_owned = ptr_is_owned(b);
44493         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44494         b_conv.is_owned = false;
44495         jboolean ret_conv = RouteHintHop_eq(&a_conv, &b_conv);
44496         return ret_conv;
44497 }
44498
44499 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
44500         LDKRouteHintHop obj_conv;
44501         obj_conv.inner = untag_ptr(obj);
44502         obj_conv.is_owned = ptr_is_owned(obj);
44503         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44504         obj_conv.is_owned = false;
44505         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
44506         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44507         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44508         CVec_u8Z_free(ret_var);
44509         return ret_arr;
44510 }
44511
44512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44513         LDKu8slice ser_ref;
44514         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44515         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44516         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
44517         *ret_conv = RouteHintHop_read(ser_ref);
44518         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44519         return tag_ptr(ret_conv, true);
44520 }
44521
44522 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) {
44523         LDKPublicKey our_node_pubkey_ref;
44524         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
44525         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
44526         LDKRouteParameters route_params_conv;
44527         route_params_conv.inner = untag_ptr(route_params);
44528         route_params_conv.is_owned = ptr_is_owned(route_params);
44529         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
44530         route_params_conv.is_owned = false;
44531         LDKNetworkGraph network_graph_conv;
44532         network_graph_conv.inner = untag_ptr(network_graph);
44533         network_graph_conv.is_owned = ptr_is_owned(network_graph);
44534         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
44535         network_graph_conv.is_owned = false;
44536         LDKCVec_ChannelDetailsZ first_hops_constr;
44537         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
44538         if (first_hops != NULL) {
44539                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
44540                 if (first_hops_constr.datalen > 0)
44541                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
44542                 else
44543                         first_hops_constr.data = NULL;
44544                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
44545                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
44546                         int64_t first_hops_conv_16 = first_hops_vals[q];
44547                         LDKChannelDetails first_hops_conv_16_conv;
44548                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
44549                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
44550                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
44551                         first_hops_conv_16_conv.is_owned = false;
44552                         first_hops_constr.data[q] = first_hops_conv_16_conv;
44553                 }
44554                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
44555                 first_hops_ptr = &first_hops_constr;
44556         }
44557         void* logger_ptr = untag_ptr(logger);
44558         CHECK_ACCESS(logger_ptr);
44559         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
44560         if (logger_conv.free == LDKLogger_JCalls_free) {
44561                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44562                 LDKLogger_JCalls_cloned(&logger_conv);
44563         }
44564         void* scorer_ptr = untag_ptr(scorer);
44565         if (ptr_is_owned(scorer)) { CHECK_ACCESS(scorer_ptr); }
44566         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
44567         unsigned char random_seed_bytes_arr[32];
44568         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
44569         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
44570         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
44571         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
44572         *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);
44573         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
44574         return tag_ptr(ret_conv, true);
44575 }
44576
44577 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) {
44578         LDKPublicKey our_node_pubkey_ref;
44579         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
44580         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
44581         LDKCVec_PublicKeyZ hops_constr;
44582         hops_constr.datalen = (*env)->GetArrayLength(env, hops);
44583         if (hops_constr.datalen > 0)
44584                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
44585         else
44586                 hops_constr.data = NULL;
44587         for (size_t i = 0; i < hops_constr.datalen; i++) {
44588                 int8_tArray hops_conv_8 = (*env)->GetObjectArrayElement(env, hops, i);
44589                 LDKPublicKey hops_conv_8_ref;
44590                 CHECK((*env)->GetArrayLength(env, hops_conv_8) == 33);
44591                 (*env)->GetByteArrayRegion(env, hops_conv_8, 0, 33, hops_conv_8_ref.compressed_form);
44592                 hops_constr.data[i] = hops_conv_8_ref;
44593         }
44594         LDKRouteParameters route_params_conv;
44595         route_params_conv.inner = untag_ptr(route_params);
44596         route_params_conv.is_owned = ptr_is_owned(route_params);
44597         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
44598         route_params_conv.is_owned = false;
44599         LDKNetworkGraph network_graph_conv;
44600         network_graph_conv.inner = untag_ptr(network_graph);
44601         network_graph_conv.is_owned = ptr_is_owned(network_graph);
44602         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
44603         network_graph_conv.is_owned = false;
44604         void* logger_ptr = untag_ptr(logger);
44605         CHECK_ACCESS(logger_ptr);
44606         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
44607         if (logger_conv.free == LDKLogger_JCalls_free) {
44608                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44609                 LDKLogger_JCalls_cloned(&logger_conv);
44610         }
44611         unsigned char random_seed_bytes_arr[32];
44612         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
44613         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
44614         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
44615         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
44616         *ret_conv = build_route_from_hops(our_node_pubkey_ref, hops_constr, &route_params_conv, &network_graph_conv, logger_conv, random_seed_bytes_ref);
44617         return tag_ptr(ret_conv, true);
44618 }
44619
44620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
44621         if (!ptr_is_owned(this_ptr)) return;
44622         void* this_ptr_ptr = untag_ptr(this_ptr);
44623         CHECK_ACCESS(this_ptr_ptr);
44624         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
44625         FREE(untag_ptr(this_ptr));
44626         Score_free(this_ptr_conv);
44627 }
44628
44629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
44630         if (!ptr_is_owned(this_ptr)) return;
44631         void* this_ptr_ptr = untag_ptr(this_ptr);
44632         CHECK_ACCESS(this_ptr_ptr);
44633         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
44634         FREE(untag_ptr(this_ptr));
44635         LockableScore_free(this_ptr_conv);
44636 }
44637
44638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44639         LDKMultiThreadedLockableScore this_obj_conv;
44640         this_obj_conv.inner = untag_ptr(this_obj);
44641         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44643         MultiThreadedLockableScore_free(this_obj_conv);
44644 }
44645
44646 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1write(JNIEnv *env, jclass clz, int64_t obj) {
44647         LDKMultiThreadedLockableScore obj_conv;
44648         obj_conv.inner = untag_ptr(obj);
44649         obj_conv.is_owned = ptr_is_owned(obj);
44650         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44651         obj_conv.is_owned = false;
44652         LDKCVec_u8Z ret_var = MultiThreadedLockableScore_write(&obj_conv);
44653         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44654         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44655         CVec_u8Z_free(ret_var);
44656         return ret_arr;
44657 }
44658
44659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1new(JNIEnv *env, jclass clz, int64_t score) {
44660         void* score_ptr = untag_ptr(score);
44661         CHECK_ACCESS(score_ptr);
44662         LDKScore score_conv = *(LDKScore*)(score_ptr);
44663         if (score_conv.free == LDKScore_JCalls_free) {
44664                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44665                 LDKScore_JCalls_cloned(&score_conv);
44666         }
44667         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
44668         int64_t ret_ref = 0;
44669         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44670         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44671         return ret_ref;
44672 }
44673
44674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44675         LDKChannelUsage this_obj_conv;
44676         this_obj_conv.inner = untag_ptr(this_obj);
44677         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44679         ChannelUsage_free(this_obj_conv);
44680 }
44681
44682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
44683         LDKChannelUsage this_ptr_conv;
44684         this_ptr_conv.inner = untag_ptr(this_ptr);
44685         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44687         this_ptr_conv.is_owned = false;
44688         int64_t ret_conv = ChannelUsage_get_amount_msat(&this_ptr_conv);
44689         return ret_conv;
44690 }
44691
44692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44693         LDKChannelUsage this_ptr_conv;
44694         this_ptr_conv.inner = untag_ptr(this_ptr);
44695         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44697         this_ptr_conv.is_owned = false;
44698         ChannelUsage_set_amount_msat(&this_ptr_conv, val);
44699 }
44700
44701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
44702         LDKChannelUsage this_ptr_conv;
44703         this_ptr_conv.inner = untag_ptr(this_ptr);
44704         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44706         this_ptr_conv.is_owned = false;
44707         int64_t ret_conv = ChannelUsage_get_inflight_htlc_msat(&this_ptr_conv);
44708         return ret_conv;
44709 }
44710
44711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44712         LDKChannelUsage this_ptr_conv;
44713         this_ptr_conv.inner = untag_ptr(this_ptr);
44714         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44716         this_ptr_conv.is_owned = false;
44717         ChannelUsage_set_inflight_htlc_msat(&this_ptr_conv, val);
44718 }
44719
44720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr) {
44721         LDKChannelUsage this_ptr_conv;
44722         this_ptr_conv.inner = untag_ptr(this_ptr);
44723         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44725         this_ptr_conv.is_owned = false;
44726         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
44727         *ret_copy = ChannelUsage_get_effective_capacity(&this_ptr_conv);
44728         int64_t ret_ref = tag_ptr(ret_copy, true);
44729         return ret_ref;
44730 }
44731
44732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44733         LDKChannelUsage this_ptr_conv;
44734         this_ptr_conv.inner = untag_ptr(this_ptr);
44735         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44737         this_ptr_conv.is_owned = false;
44738         void* val_ptr = untag_ptr(val);
44739         CHECK_ACCESS(val_ptr);
44740         LDKEffectiveCapacity val_conv = *(LDKEffectiveCapacity*)(val_ptr);
44741         val_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)untag_ptr(val));
44742         ChannelUsage_set_effective_capacity(&this_ptr_conv, val_conv);
44743 }
44744
44745 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) {
44746         void* effective_capacity_arg_ptr = untag_ptr(effective_capacity_arg);
44747         CHECK_ACCESS(effective_capacity_arg_ptr);
44748         LDKEffectiveCapacity effective_capacity_arg_conv = *(LDKEffectiveCapacity*)(effective_capacity_arg_ptr);
44749         effective_capacity_arg_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)untag_ptr(effective_capacity_arg));
44750         LDKChannelUsage ret_var = ChannelUsage_new(amount_msat_arg, inflight_htlc_msat_arg, effective_capacity_arg_conv);
44751         int64_t ret_ref = 0;
44752         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44753         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44754         return ret_ref;
44755 }
44756
44757 static inline uint64_t ChannelUsage_clone_ptr(LDKChannelUsage *NONNULL_PTR arg) {
44758         LDKChannelUsage ret_var = ChannelUsage_clone(arg);
44759         int64_t ret_ref = 0;
44760         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44761         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44762         return ret_ref;
44763 }
44764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44765         LDKChannelUsage arg_conv;
44766         arg_conv.inner = untag_ptr(arg);
44767         arg_conv.is_owned = ptr_is_owned(arg);
44768         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44769         arg_conv.is_owned = false;
44770         int64_t ret_conv = ChannelUsage_clone_ptr(&arg_conv);
44771         return ret_conv;
44772 }
44773
44774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44775         LDKChannelUsage orig_conv;
44776         orig_conv.inner = untag_ptr(orig);
44777         orig_conv.is_owned = ptr_is_owned(orig);
44778         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44779         orig_conv.is_owned = false;
44780         LDKChannelUsage ret_var = ChannelUsage_clone(&orig_conv);
44781         int64_t ret_ref = 0;
44782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44783         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44784         return ret_ref;
44785 }
44786
44787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44788         LDKFixedPenaltyScorer this_obj_conv;
44789         this_obj_conv.inner = untag_ptr(this_obj);
44790         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44792         FixedPenaltyScorer_free(this_obj_conv);
44793 }
44794
44795 static inline uint64_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
44796         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
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 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44803         LDKFixedPenaltyScorer arg_conv;
44804         arg_conv.inner = untag_ptr(arg);
44805         arg_conv.is_owned = ptr_is_owned(arg);
44806         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44807         arg_conv.is_owned = false;
44808         int64_t ret_conv = FixedPenaltyScorer_clone_ptr(&arg_conv);
44809         return ret_conv;
44810 }
44811
44812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44813         LDKFixedPenaltyScorer orig_conv;
44814         orig_conv.inner = untag_ptr(orig);
44815         orig_conv.is_owned = ptr_is_owned(orig);
44816         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44817         orig_conv.is_owned = false;
44818         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
44819         int64_t ret_ref = 0;
44820         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44821         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44822         return ret_ref;
44823 }
44824
44825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1with_1penalty(JNIEnv *env, jclass clz, int64_t penalty_msat) {
44826         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
44827         int64_t ret_ref = 0;
44828         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44829         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44830         return ret_ref;
44831 }
44832
44833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
44834         LDKFixedPenaltyScorer this_arg_conv;
44835         this_arg_conv.inner = untag_ptr(this_arg);
44836         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44838         this_arg_conv.is_owned = false;
44839         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
44840         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
44841         return tag_ptr(ret_ret, true);
44842 }
44843
44844 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
44845         LDKFixedPenaltyScorer obj_conv;
44846         obj_conv.inner = untag_ptr(obj);
44847         obj_conv.is_owned = ptr_is_owned(obj);
44848         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44849         obj_conv.is_owned = false;
44850         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
44851         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44852         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44853         CVec_u8Z_free(ret_var);
44854         return ret_arr;
44855 }
44856
44857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
44858         LDKu8slice ser_ref;
44859         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44860         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44861         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
44862         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
44863         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44864         return tag_ptr(ret_conv, true);
44865 }
44866
44867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44868         LDKProbabilisticScorer this_obj_conv;
44869         this_obj_conv.inner = untag_ptr(this_obj);
44870         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44872         ProbabilisticScorer_free(this_obj_conv);
44873 }
44874
44875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44876         LDKProbabilisticScoringParameters this_obj_conv;
44877         this_obj_conv.inner = untag_ptr(this_obj);
44878         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44880         ProbabilisticScoringParameters_free(this_obj_conv);
44881 }
44882
44883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
44884         LDKProbabilisticScoringParameters this_ptr_conv;
44885         this_ptr_conv.inner = untag_ptr(this_ptr);
44886         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44888         this_ptr_conv.is_owned = false;
44889         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
44890         return ret_conv;
44891 }
44892
44893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44894         LDKProbabilisticScoringParameters this_ptr_conv;
44895         this_ptr_conv.inner = untag_ptr(this_ptr);
44896         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44898         this_ptr_conv.is_owned = false;
44899         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
44900 }
44901
44902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
44903         LDKProbabilisticScoringParameters this_ptr_conv;
44904         this_ptr_conv.inner = untag_ptr(this_ptr);
44905         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44907         this_ptr_conv.is_owned = false;
44908         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_amount_multiplier_msat(&this_ptr_conv);
44909         return ret_conv;
44910 }
44911
44912 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) {
44913         LDKProbabilisticScoringParameters this_ptr_conv;
44914         this_ptr_conv.inner = untag_ptr(this_ptr);
44915         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44917         this_ptr_conv.is_owned = false;
44918         ProbabilisticScoringParameters_set_base_penalty_amount_multiplier_msat(&this_ptr_conv, val);
44919 }
44920
44921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
44922         LDKProbabilisticScoringParameters this_ptr_conv;
44923         this_ptr_conv.inner = untag_ptr(this_ptr);
44924         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44926         this_ptr_conv.is_owned = false;
44927         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
44928         return ret_conv;
44929 }
44930
44931 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) {
44932         LDKProbabilisticScoringParameters this_ptr_conv;
44933         this_ptr_conv.inner = untag_ptr(this_ptr);
44934         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44936         this_ptr_conv.is_owned = false;
44937         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
44938 }
44939
44940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1offset_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
44941         LDKProbabilisticScoringParameters this_ptr_conv;
44942         this_ptr_conv.inner = untag_ptr(this_ptr);
44943         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44945         this_ptr_conv.is_owned = false;
44946         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
44947         return ret_conv;
44948 }
44949
44950 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) {
44951         LDKProbabilisticScoringParameters this_ptr_conv;
44952         this_ptr_conv.inner = untag_ptr(this_ptr);
44953         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44955         this_ptr_conv.is_owned = false;
44956         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
44957 }
44958
44959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
44960         LDKProbabilisticScoringParameters this_ptr_conv;
44961         this_ptr_conv.inner = untag_ptr(this_ptr);
44962         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44964         this_ptr_conv.is_owned = false;
44965         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
44966         return ret_conv;
44967 }
44968
44969 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) {
44970         LDKProbabilisticScoringParameters this_ptr_conv;
44971         this_ptr_conv.inner = untag_ptr(this_ptr);
44972         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44974         this_ptr_conv.is_owned = false;
44975         ProbabilisticScoringParameters_set_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
44976 }
44977
44978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1anti_1probing_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
44979         LDKProbabilisticScoringParameters this_ptr_conv;
44980         this_ptr_conv.inner = untag_ptr(this_ptr);
44981         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44983         this_ptr_conv.is_owned = false;
44984         int64_t ret_conv = ProbabilisticScoringParameters_get_anti_probing_penalty_msat(&this_ptr_conv);
44985         return ret_conv;
44986 }
44987
44988 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) {
44989         LDKProbabilisticScoringParameters this_ptr_conv;
44990         this_ptr_conv.inner = untag_ptr(this_ptr);
44991         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44993         this_ptr_conv.is_owned = false;
44994         ProbabilisticScoringParameters_set_anti_probing_penalty_msat(&this_ptr_conv, val);
44995 }
44996
44997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1considered_1impossible_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
44998         LDKProbabilisticScoringParameters this_ptr_conv;
44999         this_ptr_conv.inner = untag_ptr(this_ptr);
45000         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45002         this_ptr_conv.is_owned = false;
45003         int64_t ret_conv = ProbabilisticScoringParameters_get_considered_impossible_penalty_msat(&this_ptr_conv);
45004         return ret_conv;
45005 }
45006
45007 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) {
45008         LDKProbabilisticScoringParameters this_ptr_conv;
45009         this_ptr_conv.inner = untag_ptr(this_ptr);
45010         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45012         this_ptr_conv.is_owned = false;
45013         ProbabilisticScoringParameters_set_considered_impossible_penalty_msat(&this_ptr_conv, val);
45014 }
45015
45016 static inline uint64_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
45017         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
45018         int64_t ret_ref = 0;
45019         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45020         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45021         return ret_ref;
45022 }
45023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45024         LDKProbabilisticScoringParameters arg_conv;
45025         arg_conv.inner = untag_ptr(arg);
45026         arg_conv.is_owned = ptr_is_owned(arg);
45027         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45028         arg_conv.is_owned = false;
45029         int64_t ret_conv = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
45030         return ret_conv;
45031 }
45032
45033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45034         LDKProbabilisticScoringParameters orig_conv;
45035         orig_conv.inner = untag_ptr(orig);
45036         orig_conv.is_owned = ptr_is_owned(orig);
45037         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45038         orig_conv.is_owned = false;
45039         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
45040         int64_t ret_ref = 0;
45041         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45042         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45043         return ret_ref;
45044 }
45045
45046 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) {
45047         LDKProbabilisticScoringParameters params_conv;
45048         params_conv.inner = untag_ptr(params);
45049         params_conv.is_owned = ptr_is_owned(params);
45050         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
45051         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
45052         LDKNetworkGraph network_graph_conv;
45053         network_graph_conv.inner = untag_ptr(network_graph);
45054         network_graph_conv.is_owned = ptr_is_owned(network_graph);
45055         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
45056         network_graph_conv.is_owned = false;
45057         void* logger_ptr = untag_ptr(logger);
45058         CHECK_ACCESS(logger_ptr);
45059         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
45060         if (logger_conv.free == LDKLogger_JCalls_free) {
45061                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45062                 LDKLogger_JCalls_cloned(&logger_conv);
45063         }
45064         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv, logger_conv);
45065         int64_t ret_ref = 0;
45066         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45067         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45068         return ret_ref;
45069 }
45070
45071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1debug_1log_1liquidity_1stats(JNIEnv *env, jclass clz, int64_t this_arg) {
45072         LDKProbabilisticScorer this_arg_conv;
45073         this_arg_conv.inner = untag_ptr(this_arg);
45074         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45076         this_arg_conv.is_owned = false;
45077         ProbabilisticScorer_debug_log_liquidity_stats(&this_arg_conv);
45078 }
45079
45080 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) {
45081         LDKProbabilisticScorer this_arg_conv;
45082         this_arg_conv.inner = untag_ptr(this_arg);
45083         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45085         this_arg_conv.is_owned = false;
45086         LDKNodeId target_conv;
45087         target_conv.inner = untag_ptr(target);
45088         target_conv.is_owned = ptr_is_owned(target);
45089         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
45090         target_conv.is_owned = false;
45091         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
45092         *ret_copy = ProbabilisticScorer_estimated_channel_liquidity_range(&this_arg_conv, scid, &target_conv);
45093         int64_t ret_ref = tag_ptr(ret_copy, true);
45094         return ret_ref;
45095 }
45096
45097 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1add_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
45098         LDKProbabilisticScorer this_arg_conv;
45099         this_arg_conv.inner = untag_ptr(this_arg);
45100         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45102         this_arg_conv.is_owned = false;
45103         LDKNodeId node_id_conv;
45104         node_id_conv.inner = untag_ptr(node_id);
45105         node_id_conv.is_owned = ptr_is_owned(node_id);
45106         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
45107         node_id_conv.is_owned = false;
45108         ProbabilisticScorer_add_banned(&this_arg_conv, &node_id_conv);
45109 }
45110
45111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
45112         LDKProbabilisticScorer this_arg_conv;
45113         this_arg_conv.inner = untag_ptr(this_arg);
45114         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45116         this_arg_conv.is_owned = false;
45117         LDKNodeId node_id_conv;
45118         node_id_conv.inner = untag_ptr(node_id);
45119         node_id_conv.is_owned = ptr_is_owned(node_id);
45120         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
45121         node_id_conv.is_owned = false;
45122         ProbabilisticScorer_remove_banned(&this_arg_conv, &node_id_conv);
45123 }
45124
45125 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) {
45126         LDKProbabilisticScorer this_arg_conv;
45127         this_arg_conv.inner = untag_ptr(this_arg);
45128         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45130         this_arg_conv.is_owned = false;
45131         LDKNodeId node_id_conv;
45132         node_id_conv.inner = untag_ptr(node_id);
45133         node_id_conv.is_owned = ptr_is_owned(node_id);
45134         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
45135         node_id_conv.is_owned = false;
45136         ProbabilisticScorer_set_manual_penalty(&this_arg_conv, &node_id_conv, penalty);
45137 }
45138
45139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1manual_1penalty(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
45140         LDKProbabilisticScorer this_arg_conv;
45141         this_arg_conv.inner = untag_ptr(this_arg);
45142         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45144         this_arg_conv.is_owned = false;
45145         LDKNodeId node_id_conv;
45146         node_id_conv.inner = untag_ptr(node_id);
45147         node_id_conv.is_owned = ptr_is_owned(node_id);
45148         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
45149         node_id_conv.is_owned = false;
45150         ProbabilisticScorer_remove_manual_penalty(&this_arg_conv, &node_id_conv);
45151 }
45152
45153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1clear_1manual_1penalties(JNIEnv *env, jclass clz, int64_t this_arg) {
45154         LDKProbabilisticScorer this_arg_conv;
45155         this_arg_conv.inner = untag_ptr(this_arg);
45156         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45158         this_arg_conv.is_owned = false;
45159         ProbabilisticScorer_clear_manual_penalties(&this_arg_conv);
45160 }
45161
45162 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) {
45163         LDKProbabilisticScoringParameters this_arg_conv;
45164         this_arg_conv.inner = untag_ptr(this_arg);
45165         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45167         this_arg_conv.is_owned = false;
45168         LDKCVec_NodeIdZ node_ids_constr;
45169         node_ids_constr.datalen = (*env)->GetArrayLength(env, node_ids);
45170         if (node_ids_constr.datalen > 0)
45171                 node_ids_constr.data = MALLOC(node_ids_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
45172         else
45173                 node_ids_constr.data = NULL;
45174         int64_t* node_ids_vals = (*env)->GetLongArrayElements (env, node_ids, NULL);
45175         for (size_t i = 0; i < node_ids_constr.datalen; i++) {
45176                 int64_t node_ids_conv_8 = node_ids_vals[i];
45177                 LDKNodeId node_ids_conv_8_conv;
45178                 node_ids_conv_8_conv.inner = untag_ptr(node_ids_conv_8);
45179                 node_ids_conv_8_conv.is_owned = ptr_is_owned(node_ids_conv_8);
45180                 CHECK_INNER_FIELD_ACCESS_OR_NULL(node_ids_conv_8_conv);
45181                 node_ids_conv_8_conv = NodeId_clone(&node_ids_conv_8_conv);
45182                 node_ids_constr.data[i] = node_ids_conv_8_conv;
45183         }
45184         (*env)->ReleaseLongArrayElements(env, node_ids, node_ids_vals, 0);
45185         ProbabilisticScoringParameters_add_banned_from_list(&this_arg_conv, node_ids_constr);
45186 }
45187
45188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1default(JNIEnv *env, jclass clz) {
45189         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
45190         int64_t ret_ref = 0;
45191         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45192         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45193         return ret_ref;
45194 }
45195
45196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
45197         LDKProbabilisticScorer this_arg_conv;
45198         this_arg_conv.inner = untag_ptr(this_arg);
45199         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45201         this_arg_conv.is_owned = false;
45202         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
45203         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
45204         return tag_ptr(ret_ret, true);
45205 }
45206
45207 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
45208         LDKProbabilisticScorer obj_conv;
45209         obj_conv.inner = untag_ptr(obj);
45210         obj_conv.is_owned = ptr_is_owned(obj);
45211         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45212         obj_conv.is_owned = false;
45213         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
45214         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45215         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45216         CVec_u8Z_free(ret_var);
45217         return ret_arr;
45218 }
45219
45220 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) {
45221         LDKu8slice ser_ref;
45222         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45223         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45224         LDKProbabilisticScoringParameters arg_a_conv;
45225         arg_a_conv.inner = untag_ptr(arg_a);
45226         arg_a_conv.is_owned = ptr_is_owned(arg_a);
45227         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
45228         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
45229         LDKNetworkGraph arg_b_conv;
45230         arg_b_conv.inner = untag_ptr(arg_b);
45231         arg_b_conv.is_owned = ptr_is_owned(arg_b);
45232         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
45233         arg_b_conv.is_owned = false;
45234         void* arg_c_ptr = untag_ptr(arg_c);
45235         CHECK_ACCESS(arg_c_ptr);
45236         LDKLogger arg_c_conv = *(LDKLogger*)(arg_c_ptr);
45237         if (arg_c_conv.free == LDKLogger_JCalls_free) {
45238                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45239                 LDKLogger_JCalls_cloned(&arg_c_conv);
45240         }
45241         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
45242         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv, arg_c_conv);
45243         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45244         return tag_ptr(ret_conv, true);
45245 }
45246
45247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45248         LDKFilesystemPersister this_obj_conv;
45249         this_obj_conv.inner = untag_ptr(this_obj);
45250         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45252         FilesystemPersister_free(this_obj_conv);
45253 }
45254
45255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
45256         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
45257         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
45258         int64_t ret_ref = 0;
45259         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45260         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45261         return ret_ref;
45262 }
45263
45264 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
45265         LDKFilesystemPersister this_arg_conv;
45266         this_arg_conv.inner = untag_ptr(this_arg);
45267         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45269         this_arg_conv.is_owned = false;
45270         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
45271         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
45272         Str_free(ret_str);
45273         return ret_conv;
45274 }
45275
45276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
45277         LDKFilesystemPersister this_arg_conv;
45278         this_arg_conv.inner = untag_ptr(this_arg);
45279         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45281         this_arg_conv.is_owned = false;
45282         void* keys_manager_ptr = untag_ptr(keys_manager);
45283         CHECK_ACCESS(keys_manager_ptr);
45284         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
45285         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
45286                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45287                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
45288         }
45289         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
45290         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
45291         return tag_ptr(ret_conv, true);
45292 }
45293
45294 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45295         LDKBackgroundProcessor this_obj_conv;
45296         this_obj_conv.inner = untag_ptr(this_obj);
45297         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45299         BackgroundProcessor_free(this_obj_conv);
45300 }
45301
45302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipSync_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
45303         if (!ptr_is_owned(this_ptr)) return;
45304         void* this_ptr_ptr = untag_ptr(this_ptr);
45305         CHECK_ACCESS(this_ptr_ptr);
45306         LDKGossipSync this_ptr_conv = *(LDKGossipSync*)(this_ptr_ptr);
45307         FREE(untag_ptr(this_ptr));
45308         GossipSync_free(this_ptr_conv);
45309 }
45310
45311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1p2_1p(JNIEnv *env, jclass clz, int64_t a) {
45312         LDKP2PGossipSync a_conv;
45313         a_conv.inner = untag_ptr(a);
45314         a_conv.is_owned = ptr_is_owned(a);
45315         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45316         a_conv.is_owned = false;
45317         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
45318         *ret_copy = GossipSync_p2_p(&a_conv);
45319         int64_t ret_ref = tag_ptr(ret_copy, true);
45320         return ret_ref;
45321 }
45322
45323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1rapid(JNIEnv *env, jclass clz, int64_t a) {
45324         LDKRapidGossipSync a_conv;
45325         a_conv.inner = untag_ptr(a);
45326         a_conv.is_owned = ptr_is_owned(a);
45327         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45328         a_conv.is_owned = false;
45329         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
45330         *ret_copy = GossipSync_rapid(&a_conv);
45331         int64_t ret_ref = tag_ptr(ret_copy, true);
45332         return ret_ref;
45333 }
45334
45335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1none(JNIEnv *env, jclass clz) {
45336         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
45337         *ret_copy = GossipSync_none();
45338         int64_t ret_ref = tag_ptr(ret_copy, true);
45339         return ret_ref;
45340 }
45341
45342 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) {
45343         void* persister_ptr = untag_ptr(persister);
45344         CHECK_ACCESS(persister_ptr);
45345         LDKPersister persister_conv = *(LDKPersister*)(persister_ptr);
45346         if (persister_conv.free == LDKPersister_JCalls_free) {
45347                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45348                 LDKPersister_JCalls_cloned(&persister_conv);
45349         }
45350         void* event_handler_ptr = untag_ptr(event_handler);
45351         CHECK_ACCESS(event_handler_ptr);
45352         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
45353         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
45354                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45355                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
45356         }
45357         LDKChainMonitor chain_monitor_conv;
45358         chain_monitor_conv.inner = untag_ptr(chain_monitor);
45359         chain_monitor_conv.is_owned = ptr_is_owned(chain_monitor);
45360         CHECK_INNER_FIELD_ACCESS_OR_NULL(chain_monitor_conv);
45361         chain_monitor_conv.is_owned = false;
45362         LDKChannelManager channel_manager_conv;
45363         channel_manager_conv.inner = untag_ptr(channel_manager);
45364         channel_manager_conv.is_owned = ptr_is_owned(channel_manager);
45365         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
45366         channel_manager_conv.is_owned = false;
45367         void* gossip_sync_ptr = untag_ptr(gossip_sync);
45368         CHECK_ACCESS(gossip_sync_ptr);
45369         LDKGossipSync gossip_sync_conv = *(LDKGossipSync*)(gossip_sync_ptr);
45370         // WARNING: we may need a move here but no clone is available for LDKGossipSync
45371         LDKPeerManager peer_manager_conv;
45372         peer_manager_conv.inner = untag_ptr(peer_manager);
45373         peer_manager_conv.is_owned = ptr_is_owned(peer_manager);
45374         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_manager_conv);
45375         peer_manager_conv.is_owned = false;
45376         void* logger_ptr = untag_ptr(logger);
45377         CHECK_ACCESS(logger_ptr);
45378         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
45379         if (logger_conv.free == LDKLogger_JCalls_free) {
45380                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45381                 LDKLogger_JCalls_cloned(&logger_conv);
45382         }
45383         LDKMultiThreadedLockableScore scorer_conv;
45384         scorer_conv.inner = untag_ptr(scorer);
45385         scorer_conv.is_owned = ptr_is_owned(scorer);
45386         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
45387         scorer_conv.is_owned = false;
45388         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);
45389         int64_t ret_ref = 0;
45390         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45391         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45392         return ret_ref;
45393 }
45394
45395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
45396         LDKBackgroundProcessor this_arg_conv;
45397         this_arg_conv.inner = untag_ptr(this_arg);
45398         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45400         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
45401         
45402         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
45403         *ret_conv = BackgroundProcessor_join(this_arg_conv);
45404         return tag_ptr(ret_conv, true);
45405 }
45406
45407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
45408         LDKBackgroundProcessor this_arg_conv;
45409         this_arg_conv.inner = untag_ptr(this_arg);
45410         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45412         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
45413         
45414         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
45415         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
45416         return tag_ptr(ret_conv, true);
45417 }
45418
45419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
45420         if (!ptr_is_owned(this_ptr)) return;
45421         void* this_ptr_ptr = untag_ptr(this_ptr);
45422         CHECK_ACCESS(this_ptr_ptr);
45423         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
45424         FREE(untag_ptr(this_ptr));
45425         ParseError_free(this_ptr_conv);
45426 }
45427
45428 static inline uint64_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
45429         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45430         *ret_copy = ParseError_clone(arg);
45431         int64_t ret_ref = tag_ptr(ret_copy, true);
45432         return ret_ref;
45433 }
45434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45435         LDKParseError* arg_conv = (LDKParseError*)untag_ptr(arg);
45436         int64_t ret_conv = ParseError_clone_ptr(arg_conv);
45437         return ret_conv;
45438 }
45439
45440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45441         LDKParseError* orig_conv = (LDKParseError*)untag_ptr(orig);
45442         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45443         *ret_copy = ParseError_clone(orig_conv);
45444         int64_t ret_ref = tag_ptr(ret_copy, true);
45445         return ret_ref;
45446 }
45447
45448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bech32_1error(JNIEnv *env, jclass clz, int64_t a) {
45449         void* a_ptr = untag_ptr(a);
45450         CHECK_ACCESS(a_ptr);
45451         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
45452         a_conv = Bech32Error_clone((LDKBech32Error*)untag_ptr(a));
45453         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45454         *ret_copy = ParseError_bech32_error(a_conv);
45455         int64_t ret_ref = tag_ptr(ret_copy, true);
45456         return ret_ref;
45457 }
45458
45459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1parse_1amount_1error(JNIEnv *env, jclass clz, int32_t a) {
45460         
45461         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45462         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
45463         int64_t ret_ref = tag_ptr(ret_copy, true);
45464         return ret_ref;
45465 }
45466
45467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1signature(JNIEnv *env, jclass clz, jclass a) {
45468         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_java(env, a);
45469         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45470         *ret_copy = ParseError_malformed_signature(a_conv);
45471         int64_t ret_ref = tag_ptr(ret_copy, true);
45472         return ret_ref;
45473 }
45474
45475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bad_1prefix(JNIEnv *env, jclass clz) {
45476         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45477         *ret_copy = ParseError_bad_prefix();
45478         int64_t ret_ref = tag_ptr(ret_copy, true);
45479         return ret_ref;
45480 }
45481
45482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1currency(JNIEnv *env, jclass clz) {
45483         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45484         *ret_copy = ParseError_unknown_currency();
45485         int64_t ret_ref = tag_ptr(ret_copy, true);
45486         return ret_ref;
45487 }
45488
45489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1si_1prefix(JNIEnv *env, jclass clz) {
45490         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45491         *ret_copy = ParseError_unknown_si_prefix();
45492         int64_t ret_ref = tag_ptr(ret_copy, true);
45493         return ret_ref;
45494 }
45495
45496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1hrp(JNIEnv *env, jclass clz) {
45497         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45498         *ret_copy = ParseError_malformed_hrp();
45499         int64_t ret_ref = tag_ptr(ret_copy, true);
45500         return ret_ref;
45501 }
45502
45503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1too_1short_1data_1part(JNIEnv *env, jclass clz) {
45504         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45505         *ret_copy = ParseError_too_short_data_part();
45506         int64_t ret_ref = tag_ptr(ret_copy, true);
45507         return ret_ref;
45508 }
45509
45510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unexpected_1end_1of_1tagged_1fields(JNIEnv *env, jclass clz) {
45511         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45512         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
45513         int64_t ret_ref = tag_ptr(ret_copy, true);
45514         return ret_ref;
45515 }
45516
45517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1description_1decode_1error(JNIEnv *env, jclass clz, int32_t a) {
45518         
45519         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45520         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
45521         int64_t ret_ref = tag_ptr(ret_copy, true);
45522         return ret_ref;
45523 }
45524
45525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1padding_1error(JNIEnv *env, jclass clz) {
45526         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45527         *ret_copy = ParseError_padding_error();
45528         int64_t ret_ref = tag_ptr(ret_copy, true);
45529         return ret_ref;
45530 }
45531
45532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1integer_1overflow_1error(JNIEnv *env, jclass clz) {
45533         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45534         *ret_copy = ParseError_integer_overflow_error();
45535         int64_t ret_ref = tag_ptr(ret_copy, true);
45536         return ret_ref;
45537 }
45538
45539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1seg_1wit_1program_1length(JNIEnv *env, jclass clz) {
45540         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45541         *ret_copy = ParseError_invalid_seg_wit_program_length();
45542         int64_t ret_ref = tag_ptr(ret_copy, true);
45543         return ret_ref;
45544 }
45545
45546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1pub_1key_1hash_1length(JNIEnv *env, jclass clz) {
45547         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45548         *ret_copy = ParseError_invalid_pub_key_hash_length();
45549         int64_t ret_ref = tag_ptr(ret_copy, true);
45550         return ret_ref;
45551 }
45552
45553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1script_1hash_1length(JNIEnv *env, jclass clz) {
45554         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45555         *ret_copy = ParseError_invalid_script_hash_length();
45556         int64_t ret_ref = tag_ptr(ret_copy, true);
45557         return ret_ref;
45558 }
45559
45560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
45561         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45562         *ret_copy = ParseError_invalid_recovery_id();
45563         int64_t ret_ref = tag_ptr(ret_copy, true);
45564         return ret_ref;
45565 }
45566
45567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1slice_1length(JNIEnv *env, jclass clz, jstring a) {
45568         LDKStr a_conv = java_to_owned_str(env, a);
45569         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45570         *ret_copy = ParseError_invalid_slice_length(a_conv);
45571         int64_t ret_ref = tag_ptr(ret_copy, true);
45572         return ret_ref;
45573 }
45574
45575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1skip(JNIEnv *env, jclass clz) {
45576         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45577         *ret_copy = ParseError_skip();
45578         int64_t ret_ref = tag_ptr(ret_copy, true);
45579         return ret_ref;
45580 }
45581
45582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
45583         if (!ptr_is_owned(this_ptr)) return;
45584         void* this_ptr_ptr = untag_ptr(this_ptr);
45585         CHECK_ACCESS(this_ptr_ptr);
45586         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
45587         FREE(untag_ptr(this_ptr));
45588         ParseOrSemanticError_free(this_ptr_conv);
45589 }
45590
45591 static inline uint64_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
45592         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
45593         *ret_copy = ParseOrSemanticError_clone(arg);
45594         int64_t ret_ref = tag_ptr(ret_copy, true);
45595         return ret_ref;
45596 }
45597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45598         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)untag_ptr(arg);
45599         int64_t ret_conv = ParseOrSemanticError_clone_ptr(arg_conv);
45600         return ret_conv;
45601 }
45602
45603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45604         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)untag_ptr(orig);
45605         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
45606         *ret_copy = ParseOrSemanticError_clone(orig_conv);
45607         int64_t ret_ref = tag_ptr(ret_copy, true);
45608         return ret_ref;
45609 }
45610
45611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1parse_1error(JNIEnv *env, jclass clz, int64_t a) {
45612         void* a_ptr = untag_ptr(a);
45613         CHECK_ACCESS(a_ptr);
45614         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
45615         a_conv = ParseError_clone((LDKParseError*)untag_ptr(a));
45616         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
45617         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
45618         int64_t ret_ref = tag_ptr(ret_copy, true);
45619         return ret_ref;
45620 }
45621
45622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1semantic_1error(JNIEnv *env, jclass clz, jclass a) {
45623         LDKSemanticError a_conv = LDKSemanticError_from_java(env, a);
45624         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
45625         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
45626         int64_t ret_ref = tag_ptr(ret_copy, true);
45627         return ret_ref;
45628 }
45629
45630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45631         LDKInvoice this_obj_conv;
45632         this_obj_conv.inner = untag_ptr(this_obj);
45633         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45635         Invoice_free(this_obj_conv);
45636 }
45637
45638 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45639         LDKInvoice a_conv;
45640         a_conv.inner = untag_ptr(a);
45641         a_conv.is_owned = ptr_is_owned(a);
45642         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45643         a_conv.is_owned = false;
45644         LDKInvoice b_conv;
45645         b_conv.inner = untag_ptr(b);
45646         b_conv.is_owned = ptr_is_owned(b);
45647         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45648         b_conv.is_owned = false;
45649         jboolean ret_conv = Invoice_eq(&a_conv, &b_conv);
45650         return ret_conv;
45651 }
45652
45653 static inline uint64_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
45654         LDKInvoice ret_var = Invoice_clone(arg);
45655         int64_t ret_ref = 0;
45656         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45657         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45658         return ret_ref;
45659 }
45660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45661         LDKInvoice arg_conv;
45662         arg_conv.inner = untag_ptr(arg);
45663         arg_conv.is_owned = ptr_is_owned(arg);
45664         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45665         arg_conv.is_owned = false;
45666         int64_t ret_conv = Invoice_clone_ptr(&arg_conv);
45667         return ret_conv;
45668 }
45669
45670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45671         LDKInvoice orig_conv;
45672         orig_conv.inner = untag_ptr(orig);
45673         orig_conv.is_owned = ptr_is_owned(orig);
45674         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45675         orig_conv.is_owned = false;
45676         LDKInvoice ret_var = Invoice_clone(&orig_conv);
45677         int64_t ret_ref = 0;
45678         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45679         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45680         return ret_ref;
45681 }
45682
45683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45684         LDKSignedRawInvoice this_obj_conv;
45685         this_obj_conv.inner = untag_ptr(this_obj);
45686         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45688         SignedRawInvoice_free(this_obj_conv);
45689 }
45690
45691 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45692         LDKSignedRawInvoice a_conv;
45693         a_conv.inner = untag_ptr(a);
45694         a_conv.is_owned = ptr_is_owned(a);
45695         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45696         a_conv.is_owned = false;
45697         LDKSignedRawInvoice b_conv;
45698         b_conv.inner = untag_ptr(b);
45699         b_conv.is_owned = ptr_is_owned(b);
45700         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45701         b_conv.is_owned = false;
45702         jboolean ret_conv = SignedRawInvoice_eq(&a_conv, &b_conv);
45703         return ret_conv;
45704 }
45705
45706 static inline uint64_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
45707         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
45708         int64_t ret_ref = 0;
45709         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45710         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45711         return ret_ref;
45712 }
45713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45714         LDKSignedRawInvoice arg_conv;
45715         arg_conv.inner = untag_ptr(arg);
45716         arg_conv.is_owned = ptr_is_owned(arg);
45717         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45718         arg_conv.is_owned = false;
45719         int64_t ret_conv = SignedRawInvoice_clone_ptr(&arg_conv);
45720         return ret_conv;
45721 }
45722
45723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45724         LDKSignedRawInvoice orig_conv;
45725         orig_conv.inner = untag_ptr(orig);
45726         orig_conv.is_owned = ptr_is_owned(orig);
45727         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45728         orig_conv.is_owned = false;
45729         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
45730         int64_t ret_ref = 0;
45731         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45732         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45733         return ret_ref;
45734 }
45735
45736 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45737         LDKRawInvoice this_obj_conv;
45738         this_obj_conv.inner = untag_ptr(this_obj);
45739         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45741         RawInvoice_free(this_obj_conv);
45742 }
45743
45744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
45745         LDKRawInvoice this_ptr_conv;
45746         this_ptr_conv.inner = untag_ptr(this_ptr);
45747         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45749         this_ptr_conv.is_owned = false;
45750         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
45751         int64_t ret_ref = 0;
45752         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45753         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45754         return ret_ref;
45755 }
45756
45757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45758         LDKRawInvoice this_ptr_conv;
45759         this_ptr_conv.inner = untag_ptr(this_ptr);
45760         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45762         this_ptr_conv.is_owned = false;
45763         LDKRawDataPart val_conv;
45764         val_conv.inner = untag_ptr(val);
45765         val_conv.is_owned = ptr_is_owned(val);
45766         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45767         val_conv = RawDataPart_clone(&val_conv);
45768         RawInvoice_set_data(&this_ptr_conv, val_conv);
45769 }
45770
45771 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45772         LDKRawInvoice a_conv;
45773         a_conv.inner = untag_ptr(a);
45774         a_conv.is_owned = ptr_is_owned(a);
45775         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45776         a_conv.is_owned = false;
45777         LDKRawInvoice b_conv;
45778         b_conv.inner = untag_ptr(b);
45779         b_conv.is_owned = ptr_is_owned(b);
45780         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45781         b_conv.is_owned = false;
45782         jboolean ret_conv = RawInvoice_eq(&a_conv, &b_conv);
45783         return ret_conv;
45784 }
45785
45786 static inline uint64_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
45787         LDKRawInvoice ret_var = RawInvoice_clone(arg);
45788         int64_t ret_ref = 0;
45789         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45790         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45791         return ret_ref;
45792 }
45793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45794         LDKRawInvoice arg_conv;
45795         arg_conv.inner = untag_ptr(arg);
45796         arg_conv.is_owned = ptr_is_owned(arg);
45797         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45798         arg_conv.is_owned = false;
45799         int64_t ret_conv = RawInvoice_clone_ptr(&arg_conv);
45800         return ret_conv;
45801 }
45802
45803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45804         LDKRawInvoice orig_conv;
45805         orig_conv.inner = untag_ptr(orig);
45806         orig_conv.is_owned = ptr_is_owned(orig);
45807         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45808         orig_conv.is_owned = false;
45809         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
45810         int64_t ret_ref = 0;
45811         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45812         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45813         return ret_ref;
45814 }
45815
45816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45817         LDKRawDataPart this_obj_conv;
45818         this_obj_conv.inner = untag_ptr(this_obj);
45819         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45821         RawDataPart_free(this_obj_conv);
45822 }
45823
45824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
45825         LDKRawDataPart this_ptr_conv;
45826         this_ptr_conv.inner = untag_ptr(this_ptr);
45827         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45829         this_ptr_conv.is_owned = false;
45830         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
45831         int64_t ret_ref = 0;
45832         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45833         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45834         return ret_ref;
45835 }
45836
45837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45838         LDKRawDataPart this_ptr_conv;
45839         this_ptr_conv.inner = untag_ptr(this_ptr);
45840         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45842         this_ptr_conv.is_owned = false;
45843         LDKPositiveTimestamp val_conv;
45844         val_conv.inner = untag_ptr(val);
45845         val_conv.is_owned = ptr_is_owned(val);
45846         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45847         val_conv = PositiveTimestamp_clone(&val_conv);
45848         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
45849 }
45850
45851 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45852         LDKRawDataPart a_conv;
45853         a_conv.inner = untag_ptr(a);
45854         a_conv.is_owned = ptr_is_owned(a);
45855         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45856         a_conv.is_owned = false;
45857         LDKRawDataPart b_conv;
45858         b_conv.inner = untag_ptr(b);
45859         b_conv.is_owned = ptr_is_owned(b);
45860         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45861         b_conv.is_owned = false;
45862         jboolean ret_conv = RawDataPart_eq(&a_conv, &b_conv);
45863         return ret_conv;
45864 }
45865
45866 static inline uint64_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
45867         LDKRawDataPart ret_var = RawDataPart_clone(arg);
45868         int64_t ret_ref = 0;
45869         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45870         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45871         return ret_ref;
45872 }
45873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45874         LDKRawDataPart arg_conv;
45875         arg_conv.inner = untag_ptr(arg);
45876         arg_conv.is_owned = ptr_is_owned(arg);
45877         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45878         arg_conv.is_owned = false;
45879         int64_t ret_conv = RawDataPart_clone_ptr(&arg_conv);
45880         return ret_conv;
45881 }
45882
45883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45884         LDKRawDataPart orig_conv;
45885         orig_conv.inner = untag_ptr(orig);
45886         orig_conv.is_owned = ptr_is_owned(orig);
45887         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45888         orig_conv.is_owned = false;
45889         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
45890         int64_t ret_ref = 0;
45891         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45892         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45893         return ret_ref;
45894 }
45895
45896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45897         LDKPositiveTimestamp this_obj_conv;
45898         this_obj_conv.inner = untag_ptr(this_obj);
45899         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45901         PositiveTimestamp_free(this_obj_conv);
45902 }
45903
45904 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45905         LDKPositiveTimestamp a_conv;
45906         a_conv.inner = untag_ptr(a);
45907         a_conv.is_owned = ptr_is_owned(a);
45908         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45909         a_conv.is_owned = false;
45910         LDKPositiveTimestamp b_conv;
45911         b_conv.inner = untag_ptr(b);
45912         b_conv.is_owned = ptr_is_owned(b);
45913         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45914         b_conv.is_owned = false;
45915         jboolean ret_conv = PositiveTimestamp_eq(&a_conv, &b_conv);
45916         return ret_conv;
45917 }
45918
45919 static inline uint64_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
45920         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
45921         int64_t ret_ref = 0;
45922         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45923         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45924         return ret_ref;
45925 }
45926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45927         LDKPositiveTimestamp arg_conv;
45928         arg_conv.inner = untag_ptr(arg);
45929         arg_conv.is_owned = ptr_is_owned(arg);
45930         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45931         arg_conv.is_owned = false;
45932         int64_t ret_conv = PositiveTimestamp_clone_ptr(&arg_conv);
45933         return ret_conv;
45934 }
45935
45936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45937         LDKPositiveTimestamp orig_conv;
45938         orig_conv.inner = untag_ptr(orig);
45939         orig_conv.is_owned = ptr_is_owned(orig);
45940         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45941         orig_conv.is_owned = false;
45942         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
45943         int64_t ret_ref = 0;
45944         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45945         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45946         return ret_ref;
45947 }
45948
45949 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45950         LDKSiPrefix* orig_conv = (LDKSiPrefix*)untag_ptr(orig);
45951         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
45952         return ret_conv;
45953 }
45954
45955 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
45956         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
45957         return ret_conv;
45958 }
45959
45960 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
45961         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
45962         return ret_conv;
45963 }
45964
45965 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
45966         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
45967         return ret_conv;
45968 }
45969
45970 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
45971         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
45972         return ret_conv;
45973 }
45974
45975 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45976         LDKSiPrefix* a_conv = (LDKSiPrefix*)untag_ptr(a);
45977         LDKSiPrefix* b_conv = (LDKSiPrefix*)untag_ptr(b);
45978         jboolean ret_conv = SiPrefix_eq(a_conv, b_conv);
45979         return ret_conv;
45980 }
45981
45982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
45983         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)untag_ptr(this_arg);
45984         int64_t ret_conv = SiPrefix_multiplier(this_arg_conv);
45985         return ret_conv;
45986 }
45987
45988 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45989         LDKCurrency* orig_conv = (LDKCurrency*)untag_ptr(orig);
45990         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
45991         return ret_conv;
45992 }
45993
45994 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
45995         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
45996         return ret_conv;
45997 }
45998
45999 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
46000         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
46001         return ret_conv;
46002 }
46003
46004 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
46005         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
46006         return ret_conv;
46007 }
46008
46009 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
46010         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
46011         return ret_conv;
46012 }
46013
46014 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
46015         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
46016         return ret_conv;
46017 }
46018
46019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) {
46020         LDKCurrency* o_conv = (LDKCurrency*)untag_ptr(o);
46021         int64_t ret_conv = Currency_hash(o_conv);
46022         return ret_conv;
46023 }
46024
46025 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46026         LDKCurrency* a_conv = (LDKCurrency*)untag_ptr(a);
46027         LDKCurrency* b_conv = (LDKCurrency*)untag_ptr(b);
46028         jboolean ret_conv = Currency_eq(a_conv, b_conv);
46029         return ret_conv;
46030 }
46031
46032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46033         LDKSha256 this_obj_conv;
46034         this_obj_conv.inner = untag_ptr(this_obj);
46035         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46037         Sha256_free(this_obj_conv);
46038 }
46039
46040 static inline uint64_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
46041         LDKSha256 ret_var = Sha256_clone(arg);
46042         int64_t ret_ref = 0;
46043         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46044         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46045         return ret_ref;
46046 }
46047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46048         LDKSha256 arg_conv;
46049         arg_conv.inner = untag_ptr(arg);
46050         arg_conv.is_owned = ptr_is_owned(arg);
46051         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46052         arg_conv.is_owned = false;
46053         int64_t ret_conv = Sha256_clone_ptr(&arg_conv);
46054         return ret_conv;
46055 }
46056
46057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46058         LDKSha256 orig_conv;
46059         orig_conv.inner = untag_ptr(orig);
46060         orig_conv.is_owned = ptr_is_owned(orig);
46061         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46062         orig_conv.is_owned = false;
46063         LDKSha256 ret_var = Sha256_clone(&orig_conv);
46064         int64_t ret_ref = 0;
46065         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46066         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46067         return ret_ref;
46068 }
46069
46070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) {
46071         LDKSha256 o_conv;
46072         o_conv.inner = untag_ptr(o);
46073         o_conv.is_owned = ptr_is_owned(o);
46074         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46075         o_conv.is_owned = false;
46076         int64_t ret_conv = Sha256_hash(&o_conv);
46077         return ret_conv;
46078 }
46079
46080 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46081         LDKSha256 a_conv;
46082         a_conv.inner = untag_ptr(a);
46083         a_conv.is_owned = ptr_is_owned(a);
46084         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46085         a_conv.is_owned = false;
46086         LDKSha256 b_conv;
46087         b_conv.inner = untag_ptr(b);
46088         b_conv.is_owned = ptr_is_owned(b);
46089         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46090         b_conv.is_owned = false;
46091         jboolean ret_conv = Sha256_eq(&a_conv, &b_conv);
46092         return ret_conv;
46093 }
46094
46095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46096         LDKDescription this_obj_conv;
46097         this_obj_conv.inner = untag_ptr(this_obj);
46098         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46100         Description_free(this_obj_conv);
46101 }
46102
46103 static inline uint64_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
46104         LDKDescription ret_var = Description_clone(arg);
46105         int64_t ret_ref = 0;
46106         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46107         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46108         return ret_ref;
46109 }
46110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46111         LDKDescription arg_conv;
46112         arg_conv.inner = untag_ptr(arg);
46113         arg_conv.is_owned = ptr_is_owned(arg);
46114         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46115         arg_conv.is_owned = false;
46116         int64_t ret_conv = Description_clone_ptr(&arg_conv);
46117         return ret_conv;
46118 }
46119
46120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46121         LDKDescription orig_conv;
46122         orig_conv.inner = untag_ptr(orig);
46123         orig_conv.is_owned = ptr_is_owned(orig);
46124         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46125         orig_conv.is_owned = false;
46126         LDKDescription ret_var = Description_clone(&orig_conv);
46127         int64_t ret_ref = 0;
46128         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46129         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46130         return ret_ref;
46131 }
46132
46133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) {
46134         LDKDescription o_conv;
46135         o_conv.inner = untag_ptr(o);
46136         o_conv.is_owned = ptr_is_owned(o);
46137         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46138         o_conv.is_owned = false;
46139         int64_t ret_conv = Description_hash(&o_conv);
46140         return ret_conv;
46141 }
46142
46143 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46144         LDKDescription a_conv;
46145         a_conv.inner = untag_ptr(a);
46146         a_conv.is_owned = ptr_is_owned(a);
46147         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46148         a_conv.is_owned = false;
46149         LDKDescription b_conv;
46150         b_conv.inner = untag_ptr(b);
46151         b_conv.is_owned = ptr_is_owned(b);
46152         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46153         b_conv.is_owned = false;
46154         jboolean ret_conv = Description_eq(&a_conv, &b_conv);
46155         return ret_conv;
46156 }
46157
46158 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46159         LDKPayeePubKey this_obj_conv;
46160         this_obj_conv.inner = untag_ptr(this_obj);
46161         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46163         PayeePubKey_free(this_obj_conv);
46164 }
46165
46166 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
46167         LDKPayeePubKey this_ptr_conv;
46168         this_ptr_conv.inner = untag_ptr(this_ptr);
46169         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46171         this_ptr_conv.is_owned = false;
46172         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
46173         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PayeePubKey_get_a(&this_ptr_conv).compressed_form);
46174         return ret_arr;
46175 }
46176
46177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
46178         LDKPayeePubKey this_ptr_conv;
46179         this_ptr_conv.inner = untag_ptr(this_ptr);
46180         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46182         this_ptr_conv.is_owned = false;
46183         LDKPublicKey val_ref;
46184         CHECK((*env)->GetArrayLength(env, val) == 33);
46185         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
46186         PayeePubKey_set_a(&this_ptr_conv, val_ref);
46187 }
46188
46189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
46190         LDKPublicKey a_arg_ref;
46191         CHECK((*env)->GetArrayLength(env, a_arg) == 33);
46192         (*env)->GetByteArrayRegion(env, a_arg, 0, 33, a_arg_ref.compressed_form);
46193         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
46194         int64_t ret_ref = 0;
46195         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46196         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46197         return ret_ref;
46198 }
46199
46200 static inline uint64_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
46201         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
46202         int64_t ret_ref = 0;
46203         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46204         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46205         return ret_ref;
46206 }
46207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46208         LDKPayeePubKey arg_conv;
46209         arg_conv.inner = untag_ptr(arg);
46210         arg_conv.is_owned = ptr_is_owned(arg);
46211         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46212         arg_conv.is_owned = false;
46213         int64_t ret_conv = PayeePubKey_clone_ptr(&arg_conv);
46214         return ret_conv;
46215 }
46216
46217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46218         LDKPayeePubKey orig_conv;
46219         orig_conv.inner = untag_ptr(orig);
46220         orig_conv.is_owned = ptr_is_owned(orig);
46221         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46222         orig_conv.is_owned = false;
46223         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
46224         int64_t ret_ref = 0;
46225         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46226         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46227         return ret_ref;
46228 }
46229
46230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) {
46231         LDKPayeePubKey o_conv;
46232         o_conv.inner = untag_ptr(o);
46233         o_conv.is_owned = ptr_is_owned(o);
46234         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46235         o_conv.is_owned = false;
46236         int64_t ret_conv = PayeePubKey_hash(&o_conv);
46237         return ret_conv;
46238 }
46239
46240 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46241         LDKPayeePubKey a_conv;
46242         a_conv.inner = untag_ptr(a);
46243         a_conv.is_owned = ptr_is_owned(a);
46244         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46245         a_conv.is_owned = false;
46246         LDKPayeePubKey b_conv;
46247         b_conv.inner = untag_ptr(b);
46248         b_conv.is_owned = ptr_is_owned(b);
46249         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46250         b_conv.is_owned = false;
46251         jboolean ret_conv = PayeePubKey_eq(&a_conv, &b_conv);
46252         return ret_conv;
46253 }
46254
46255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46256         LDKExpiryTime this_obj_conv;
46257         this_obj_conv.inner = untag_ptr(this_obj);
46258         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46260         ExpiryTime_free(this_obj_conv);
46261 }
46262
46263 static inline uint64_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
46264         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
46265         int64_t ret_ref = 0;
46266         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46267         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46268         return ret_ref;
46269 }
46270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46271         LDKExpiryTime arg_conv;
46272         arg_conv.inner = untag_ptr(arg);
46273         arg_conv.is_owned = ptr_is_owned(arg);
46274         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46275         arg_conv.is_owned = false;
46276         int64_t ret_conv = ExpiryTime_clone_ptr(&arg_conv);
46277         return ret_conv;
46278 }
46279
46280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46281         LDKExpiryTime orig_conv;
46282         orig_conv.inner = untag_ptr(orig);
46283         orig_conv.is_owned = ptr_is_owned(orig);
46284         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46285         orig_conv.is_owned = false;
46286         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
46287         int64_t ret_ref = 0;
46288         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46289         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46290         return ret_ref;
46291 }
46292
46293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) {
46294         LDKExpiryTime o_conv;
46295         o_conv.inner = untag_ptr(o);
46296         o_conv.is_owned = ptr_is_owned(o);
46297         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46298         o_conv.is_owned = false;
46299         int64_t ret_conv = ExpiryTime_hash(&o_conv);
46300         return ret_conv;
46301 }
46302
46303 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46304         LDKExpiryTime a_conv;
46305         a_conv.inner = untag_ptr(a);
46306         a_conv.is_owned = ptr_is_owned(a);
46307         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46308         a_conv.is_owned = false;
46309         LDKExpiryTime b_conv;
46310         b_conv.inner = untag_ptr(b);
46311         b_conv.is_owned = ptr_is_owned(b);
46312         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46313         b_conv.is_owned = false;
46314         jboolean ret_conv = ExpiryTime_eq(&a_conv, &b_conv);
46315         return ret_conv;
46316 }
46317
46318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46319         LDKMinFinalCltvExpiry this_obj_conv;
46320         this_obj_conv.inner = untag_ptr(this_obj);
46321         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46323         MinFinalCltvExpiry_free(this_obj_conv);
46324 }
46325
46326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
46327         LDKMinFinalCltvExpiry this_ptr_conv;
46328         this_ptr_conv.inner = untag_ptr(this_ptr);
46329         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46331         this_ptr_conv.is_owned = false;
46332         int64_t ret_conv = MinFinalCltvExpiry_get_a(&this_ptr_conv);
46333         return ret_conv;
46334 }
46335
46336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46337         LDKMinFinalCltvExpiry this_ptr_conv;
46338         this_ptr_conv.inner = untag_ptr(this_ptr);
46339         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46341         this_ptr_conv.is_owned = false;
46342         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
46343 }
46344
46345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
46346         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
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 MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
46354         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_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_MinFinalCltvExpiry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46361         LDKMinFinalCltvExpiry 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 = MinFinalCltvExpiry_clone_ptr(&arg_conv);
46367         return ret_conv;
46368 }
46369
46370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46371         LDKMinFinalCltvExpiry 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         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_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_MinFinalCltvExpiry_1hash(JNIEnv *env, jclass clz, int64_t o) {
46384         LDKMinFinalCltvExpiry 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 = MinFinalCltvExpiry_hash(&o_conv);
46390         return ret_conv;
46391 }
46392
46393 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46394         LDKMinFinalCltvExpiry 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         LDKMinFinalCltvExpiry 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 = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
46405         return ret_conv;
46406 }
46407
46408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
46409         if (!ptr_is_owned(this_ptr)) return;
46410         void* this_ptr_ptr = untag_ptr(this_ptr);
46411         CHECK_ACCESS(this_ptr_ptr);
46412         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
46413         FREE(untag_ptr(this_ptr));
46414         Fallback_free(this_ptr_conv);
46415 }
46416
46417 static inline uint64_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
46418         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
46419         *ret_copy = Fallback_clone(arg);
46420         int64_t ret_ref = tag_ptr(ret_copy, true);
46421         return ret_ref;
46422 }
46423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46424         LDKFallback* arg_conv = (LDKFallback*)untag_ptr(arg);
46425         int64_t ret_conv = Fallback_clone_ptr(arg_conv);
46426         return ret_conv;
46427 }
46428
46429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46430         LDKFallback* orig_conv = (LDKFallback*)untag_ptr(orig);
46431         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
46432         *ret_copy = Fallback_clone(orig_conv);
46433         int64_t ret_ref = tag_ptr(ret_copy, true);
46434         return ret_ref;
46435 }
46436
46437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
46438         
46439         LDKCVec_u8Z program_ref;
46440         program_ref.datalen = (*env)->GetArrayLength(env, program);
46441         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
46442         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
46443         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
46444         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
46445         int64_t ret_ref = tag_ptr(ret_copy, true);
46446         return ret_ref;
46447 }
46448
46449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
46450         LDKTwentyBytes a_ref;
46451         CHECK((*env)->GetArrayLength(env, a) == 20);
46452         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
46453         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
46454         *ret_copy = Fallback_pub_key_hash(a_ref);
46455         int64_t ret_ref = tag_ptr(ret_copy, true);
46456         return ret_ref;
46457 }
46458
46459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
46460         LDKTwentyBytes a_ref;
46461         CHECK((*env)->GetArrayLength(env, a) == 20);
46462         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
46463         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
46464         *ret_copy = Fallback_script_hash(a_ref);
46465         int64_t ret_ref = tag_ptr(ret_copy, true);
46466         return ret_ref;
46467 }
46468
46469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1hash(JNIEnv *env, jclass clz, int64_t o) {
46470         LDKFallback* o_conv = (LDKFallback*)untag_ptr(o);
46471         int64_t ret_conv = Fallback_hash(o_conv);
46472         return ret_conv;
46473 }
46474
46475 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46476         LDKFallback* a_conv = (LDKFallback*)untag_ptr(a);
46477         LDKFallback* b_conv = (LDKFallback*)untag_ptr(b);
46478         jboolean ret_conv = Fallback_eq(a_conv, b_conv);
46479         return ret_conv;
46480 }
46481
46482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46483         LDKInvoiceSignature this_obj_conv;
46484         this_obj_conv.inner = untag_ptr(this_obj);
46485         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46487         InvoiceSignature_free(this_obj_conv);
46488 }
46489
46490 static inline uint64_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
46491         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
46492         int64_t ret_ref = 0;
46493         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46494         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46495         return ret_ref;
46496 }
46497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46498         LDKInvoiceSignature arg_conv;
46499         arg_conv.inner = untag_ptr(arg);
46500         arg_conv.is_owned = ptr_is_owned(arg);
46501         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46502         arg_conv.is_owned = false;
46503         int64_t ret_conv = InvoiceSignature_clone_ptr(&arg_conv);
46504         return ret_conv;
46505 }
46506
46507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46508         LDKInvoiceSignature orig_conv;
46509         orig_conv.inner = untag_ptr(orig);
46510         orig_conv.is_owned = ptr_is_owned(orig);
46511         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46512         orig_conv.is_owned = false;
46513         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
46514         int64_t ret_ref = 0;
46515         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46516         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46517         return ret_ref;
46518 }
46519
46520 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46521         LDKInvoiceSignature a_conv;
46522         a_conv.inner = untag_ptr(a);
46523         a_conv.is_owned = ptr_is_owned(a);
46524         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46525         a_conv.is_owned = false;
46526         LDKInvoiceSignature b_conv;
46527         b_conv.inner = untag_ptr(b);
46528         b_conv.is_owned = ptr_is_owned(b);
46529         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46530         b_conv.is_owned = false;
46531         jboolean ret_conv = InvoiceSignature_eq(&a_conv, &b_conv);
46532         return ret_conv;
46533 }
46534
46535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46536         LDKPrivateRoute this_obj_conv;
46537         this_obj_conv.inner = untag_ptr(this_obj);
46538         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46540         PrivateRoute_free(this_obj_conv);
46541 }
46542
46543 static inline uint64_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
46544         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
46545         int64_t ret_ref = 0;
46546         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46547         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46548         return ret_ref;
46549 }
46550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46551         LDKPrivateRoute arg_conv;
46552         arg_conv.inner = untag_ptr(arg);
46553         arg_conv.is_owned = ptr_is_owned(arg);
46554         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46555         arg_conv.is_owned = false;
46556         int64_t ret_conv = PrivateRoute_clone_ptr(&arg_conv);
46557         return ret_conv;
46558 }
46559
46560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46561         LDKPrivateRoute orig_conv;
46562         orig_conv.inner = untag_ptr(orig);
46563         orig_conv.is_owned = ptr_is_owned(orig);
46564         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46565         orig_conv.is_owned = false;
46566         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
46567         int64_t ret_ref = 0;
46568         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46569         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46570         return ret_ref;
46571 }
46572
46573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) {
46574         LDKPrivateRoute o_conv;
46575         o_conv.inner = untag_ptr(o);
46576         o_conv.is_owned = ptr_is_owned(o);
46577         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46578         o_conv.is_owned = false;
46579         int64_t ret_conv = PrivateRoute_hash(&o_conv);
46580         return ret_conv;
46581 }
46582
46583 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46584         LDKPrivateRoute a_conv;
46585         a_conv.inner = untag_ptr(a);
46586         a_conv.is_owned = ptr_is_owned(a);
46587         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46588         a_conv.is_owned = false;
46589         LDKPrivateRoute b_conv;
46590         b_conv.inner = untag_ptr(b);
46591         b_conv.is_owned = ptr_is_owned(b);
46592         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46593         b_conv.is_owned = false;
46594         jboolean ret_conv = PrivateRoute_eq(&a_conv, &b_conv);
46595         return ret_conv;
46596 }
46597
46598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
46599         LDKSignedRawInvoice this_arg_conv;
46600         this_arg_conv.inner = untag_ptr(this_arg);
46601         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46603         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
46604         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
46605         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
46606         return tag_ptr(ret_conv, true);
46607 }
46608
46609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
46610         LDKSignedRawInvoice this_arg_conv;
46611         this_arg_conv.inner = untag_ptr(this_arg);
46612         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46614         this_arg_conv.is_owned = false;
46615         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
46616         int64_t ret_ref = 0;
46617         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46618         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46619         return ret_ref;
46620 }
46621
46622 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
46623         LDKSignedRawInvoice this_arg_conv;
46624         this_arg_conv.inner = untag_ptr(this_arg);
46625         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46627         this_arg_conv.is_owned = false;
46628         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
46629         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
46630         return ret_arr;
46631 }
46632
46633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
46634         LDKSignedRawInvoice this_arg_conv;
46635         this_arg_conv.inner = untag_ptr(this_arg);
46636         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46638         this_arg_conv.is_owned = false;
46639         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
46640         int64_t ret_ref = 0;
46641         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46642         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46643         return ret_ref;
46644 }
46645
46646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
46647         LDKSignedRawInvoice this_arg_conv;
46648         this_arg_conv.inner = untag_ptr(this_arg);
46649         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46651         this_arg_conv.is_owned = false;
46652         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
46653         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
46654         return tag_ptr(ret_conv, true);
46655 }
46656
46657 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
46658         LDKSignedRawInvoice this_arg_conv;
46659         this_arg_conv.inner = untag_ptr(this_arg);
46660         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46662         this_arg_conv.is_owned = false;
46663         jboolean ret_conv = SignedRawInvoice_check_signature(&this_arg_conv);
46664         return ret_conv;
46665 }
46666
46667 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
46668         LDKRawInvoice this_arg_conv;
46669         this_arg_conv.inner = untag_ptr(this_arg);
46670         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46672         this_arg_conv.is_owned = false;
46673         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
46674         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
46675         return ret_arr;
46676 }
46677
46678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
46679         LDKRawInvoice this_arg_conv;
46680         this_arg_conv.inner = untag_ptr(this_arg);
46681         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46683         this_arg_conv.is_owned = false;
46684         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
46685         int64_t ret_ref = 0;
46686         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46687         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46688         return ret_ref;
46689 }
46690
46691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
46692         LDKRawInvoice this_arg_conv;
46693         this_arg_conv.inner = untag_ptr(this_arg);
46694         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46696         this_arg_conv.is_owned = false;
46697         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
46698         int64_t ret_ref = 0;
46699         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46700         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46701         return ret_ref;
46702 }
46703
46704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
46705         LDKRawInvoice this_arg_conv;
46706         this_arg_conv.inner = untag_ptr(this_arg);
46707         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46709         this_arg_conv.is_owned = false;
46710         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
46711         int64_t ret_ref = 0;
46712         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46713         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46714         return ret_ref;
46715 }
46716
46717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
46718         LDKRawInvoice this_arg_conv;
46719         this_arg_conv.inner = untag_ptr(this_arg);
46720         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46722         this_arg_conv.is_owned = false;
46723         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
46724         int64_t ret_ref = 0;
46725         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46726         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46727         return ret_ref;
46728 }
46729
46730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
46731         LDKRawInvoice this_arg_conv;
46732         this_arg_conv.inner = untag_ptr(this_arg);
46733         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46735         this_arg_conv.is_owned = false;
46736         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
46737         int64_t ret_ref = 0;
46738         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46739         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46740         return ret_ref;
46741 }
46742
46743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
46744         LDKRawInvoice this_arg_conv;
46745         this_arg_conv.inner = untag_ptr(this_arg);
46746         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46748         this_arg_conv.is_owned = false;
46749         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
46750         int64_t ret_ref = 0;
46751         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46752         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46753         return ret_ref;
46754 }
46755
46756 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
46757         LDKRawInvoice this_arg_conv;
46758         this_arg_conv.inner = untag_ptr(this_arg);
46759         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46761         this_arg_conv.is_owned = false;
46762         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
46763         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
46764         return ret_arr;
46765 }
46766
46767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
46768         LDKRawInvoice this_arg_conv;
46769         this_arg_conv.inner = untag_ptr(this_arg);
46770         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46772         this_arg_conv.is_owned = false;
46773         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
46774         int64_t ret_ref = 0;
46775         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46776         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46777         return ret_ref;
46778 }
46779
46780 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
46781         LDKRawInvoice this_arg_conv;
46782         this_arg_conv.inner = untag_ptr(this_arg);
46783         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46785         this_arg_conv.is_owned = false;
46786         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
46787         int64_tArray ret_arr = NULL;
46788         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
46789         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
46790         for (size_t o = 0; o < ret_var.datalen; o++) {
46791                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
46792                 int64_t ret_conv_14_ref = 0;
46793                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
46794                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
46795                 ret_arr_ptr[o] = ret_conv_14_ref;
46796         }
46797         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
46798         FREE(ret_var.data);
46799         return ret_arr;
46800 }
46801
46802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
46803         LDKRawInvoice this_arg_conv;
46804         this_arg_conv.inner = untag_ptr(this_arg);
46805         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46807         this_arg_conv.is_owned = false;
46808         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
46809         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
46810         int64_t ret_ref = tag_ptr(ret_copy, true);
46811         return ret_ref;
46812 }
46813
46814 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
46815         LDKRawInvoice this_arg_conv;
46816         this_arg_conv.inner = untag_ptr(this_arg);
46817         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46819         this_arg_conv.is_owned = false;
46820         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
46821         return ret_conv;
46822 }
46823
46824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
46825         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
46826         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
46827         return tag_ptr(ret_conv, true);
46828 }
46829
46830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
46831         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
46832         *ret_conv = PositiveTimestamp_from_system_time(time);
46833         return tag_ptr(ret_conv, true);
46834 }
46835
46836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t duration) {
46837         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
46838         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
46839         return tag_ptr(ret_conv, true);
46840 }
46841
46842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
46843         LDKPositiveTimestamp this_arg_conv;
46844         this_arg_conv.inner = untag_ptr(this_arg);
46845         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46847         this_arg_conv.is_owned = false;
46848         int64_t ret_conv = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
46849         return ret_conv;
46850 }
46851
46852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
46853         LDKPositiveTimestamp this_arg_conv;
46854         this_arg_conv.inner = untag_ptr(this_arg);
46855         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46857         this_arg_conv.is_owned = false;
46858         int64_t ret_conv = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
46859         return ret_conv;
46860 }
46861
46862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
46863         LDKPositiveTimestamp this_arg_conv;
46864         this_arg_conv.inner = untag_ptr(this_arg);
46865         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46867         this_arg_conv.is_owned = false;
46868         int64_t ret_conv = PositiveTimestamp_as_time(&this_arg_conv);
46869         return ret_conv;
46870 }
46871
46872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
46873         LDKInvoice this_arg_conv;
46874         this_arg_conv.inner = untag_ptr(this_arg);
46875         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46877         this_arg_conv = Invoice_clone(&this_arg_conv);
46878         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
46879         int64_t ret_ref = 0;
46880         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46881         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46882         return ret_ref;
46883 }
46884
46885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
46886         LDKInvoice this_arg_conv;
46887         this_arg_conv.inner = untag_ptr(this_arg);
46888         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46890         this_arg_conv.is_owned = false;
46891         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
46892         *ret_conv = Invoice_check_signature(&this_arg_conv);
46893         return tag_ptr(ret_conv, true);
46894 }
46895
46896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
46897         LDKSignedRawInvoice signed_invoice_conv;
46898         signed_invoice_conv.inner = untag_ptr(signed_invoice);
46899         signed_invoice_conv.is_owned = ptr_is_owned(signed_invoice);
46900         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
46901         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
46902         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
46903         *ret_conv = Invoice_from_signed(signed_invoice_conv);
46904         return tag_ptr(ret_conv, true);
46905 }
46906
46907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
46908         LDKInvoice this_arg_conv;
46909         this_arg_conv.inner = untag_ptr(this_arg);
46910         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46912         this_arg_conv.is_owned = false;
46913         int64_t ret_conv = Invoice_timestamp(&this_arg_conv);
46914         return ret_conv;
46915 }
46916
46917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
46918         LDKInvoice this_arg_conv;
46919         this_arg_conv.inner = untag_ptr(this_arg);
46920         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46922         this_arg_conv.is_owned = false;
46923         int64_t ret_conv = Invoice_duration_since_epoch(&this_arg_conv);
46924         return ret_conv;
46925 }
46926
46927 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
46928         LDKInvoice this_arg_conv;
46929         this_arg_conv.inner = untag_ptr(this_arg);
46930         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46932         this_arg_conv.is_owned = false;
46933         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
46934         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
46935         return ret_arr;
46936 }
46937
46938 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
46939         LDKInvoice this_arg_conv;
46940         this_arg_conv.inner = untag_ptr(this_arg);
46941         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46943         this_arg_conv.is_owned = false;
46944         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
46945         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
46946         return ret_arr;
46947 }
46948
46949 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
46950         LDKInvoice this_arg_conv;
46951         this_arg_conv.inner = untag_ptr(this_arg);
46952         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46954         this_arg_conv.is_owned = false;
46955         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
46956         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_secret(&this_arg_conv));
46957         return ret_arr;
46958 }
46959
46960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
46961         LDKInvoice this_arg_conv;
46962         this_arg_conv.inner = untag_ptr(this_arg);
46963         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46965         this_arg_conv.is_owned = false;
46966         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
46967         int64_t ret_ref = 0;
46968         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46969         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46970         return ret_ref;
46971 }
46972
46973 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
46974         LDKInvoice this_arg_conv;
46975         this_arg_conv.inner = untag_ptr(this_arg);
46976         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46978         this_arg_conv.is_owned = false;
46979         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
46980         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
46981         return ret_arr;
46982 }
46983
46984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
46985         LDKInvoice this_arg_conv;
46986         this_arg_conv.inner = untag_ptr(this_arg);
46987         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46989         this_arg_conv.is_owned = false;
46990         int64_t ret_conv = Invoice_expiry_time(&this_arg_conv);
46991         return ret_conv;
46992 }
46993
46994 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
46995         LDKInvoice this_arg_conv;
46996         this_arg_conv.inner = untag_ptr(this_arg);
46997         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46999         this_arg_conv.is_owned = false;
47000         jboolean ret_conv = Invoice_is_expired(&this_arg_conv);
47001         return ret_conv;
47002 }
47003
47004 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1would_1expire(JNIEnv *env, jclass clz, int64_t this_arg, int64_t at_time) {
47005         LDKInvoice this_arg_conv;
47006         this_arg_conv.inner = untag_ptr(this_arg);
47007         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47009         this_arg_conv.is_owned = false;
47010         jboolean ret_conv = Invoice_would_expire(&this_arg_conv, at_time);
47011         return ret_conv;
47012 }
47013
47014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
47015         LDKInvoice this_arg_conv;
47016         this_arg_conv.inner = untag_ptr(this_arg);
47017         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47019         this_arg_conv.is_owned = false;
47020         int64_t ret_conv = Invoice_min_final_cltv_expiry(&this_arg_conv);
47021         return ret_conv;
47022 }
47023
47024 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
47025         LDKInvoice this_arg_conv;
47026         this_arg_conv.inner = untag_ptr(this_arg);
47027         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47029         this_arg_conv.is_owned = false;
47030         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
47031         int64_tArray ret_arr = NULL;
47032         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
47033         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
47034         for (size_t o = 0; o < ret_var.datalen; o++) {
47035                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
47036                 int64_t ret_conv_14_ref = 0;
47037                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
47038                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
47039                 ret_arr_ptr[o] = ret_conv_14_ref;
47040         }
47041         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
47042         FREE(ret_var.data);
47043         return ret_arr;
47044 }
47045
47046 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
47047         LDKInvoice this_arg_conv;
47048         this_arg_conv.inner = untag_ptr(this_arg);
47049         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47051         this_arg_conv.is_owned = false;
47052         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
47053         int64_tArray ret_arr = NULL;
47054         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
47055         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
47056         for (size_t l = 0; l < ret_var.datalen; l++) {
47057                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
47058                 int64_t ret_conv_11_ref = 0;
47059                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
47060                 ret_conv_11_ref = tag_ptr(ret_conv_11_var.inner, ret_conv_11_var.is_owned);
47061                 ret_arr_ptr[l] = ret_conv_11_ref;
47062         }
47063         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
47064         FREE(ret_var.data);
47065         return ret_arr;
47066 }
47067
47068 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
47069         LDKInvoice this_arg_conv;
47070         this_arg_conv.inner = untag_ptr(this_arg);
47071         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47073         this_arg_conv.is_owned = false;
47074         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
47075         return ret_conv;
47076 }
47077
47078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1milli_1satoshis(JNIEnv *env, jclass clz, int64_t this_arg) {
47079         LDKInvoice this_arg_conv;
47080         this_arg_conv.inner = untag_ptr(this_arg);
47081         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47083         this_arg_conv.is_owned = false;
47084         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
47085         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
47086         int64_t ret_ref = tag_ptr(ret_copy, true);
47087         return ret_ref;
47088 }
47089
47090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
47091         LDKStr description_conv = java_to_owned_str(env, description);
47092         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
47093         *ret_conv = Description_new(description_conv);
47094         return tag_ptr(ret_conv, true);
47095 }
47096
47097 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
47098         LDKDescription this_arg_conv;
47099         this_arg_conv.inner = untag_ptr(this_arg);
47100         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47102         this_arg_conv = Description_clone(&this_arg_conv);
47103         LDKStr ret_str = Description_into_inner(this_arg_conv);
47104         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
47105         Str_free(ret_str);
47106         return ret_conv;
47107 }
47108
47109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
47110         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
47111         int64_t ret_ref = 0;
47112         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47113         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47114         return ret_ref;
47115 }
47116
47117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
47118         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
47119         int64_t ret_ref = 0;
47120         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47121         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47122         return ret_ref;
47123 }
47124
47125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
47126         LDKExpiryTime this_arg_conv;
47127         this_arg_conv.inner = untag_ptr(this_arg);
47128         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47130         this_arg_conv.is_owned = false;
47131         int64_t ret_conv = ExpiryTime_as_seconds(&this_arg_conv);
47132         return ret_conv;
47133 }
47134
47135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
47136         LDKExpiryTime this_arg_conv;
47137         this_arg_conv.inner = untag_ptr(this_arg);
47138         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47140         this_arg_conv.is_owned = false;
47141         int64_t ret_conv = ExpiryTime_as_duration(&this_arg_conv);
47142         return ret_conv;
47143 }
47144
47145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
47146         LDKRouteHint hops_conv;
47147         hops_conv.inner = untag_ptr(hops);
47148         hops_conv.is_owned = ptr_is_owned(hops);
47149         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
47150         hops_conv = RouteHint_clone(&hops_conv);
47151         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
47152         *ret_conv = PrivateRoute_new(hops_conv);
47153         return tag_ptr(ret_conv, true);
47154 }
47155
47156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
47157         LDKPrivateRoute this_arg_conv;
47158         this_arg_conv.inner = untag_ptr(this_arg);
47159         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47161         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
47162         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
47163         int64_t ret_ref = 0;
47164         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47165         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47166         return ret_ref;
47167 }
47168
47169 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47170         LDKCreationError* orig_conv = (LDKCreationError*)untag_ptr(orig);
47171         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
47172         return ret_conv;
47173 }
47174
47175 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
47176         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
47177         return ret_conv;
47178 }
47179
47180 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
47181         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
47182         return ret_conv;
47183 }
47184
47185 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
47186         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
47187         return ret_conv;
47188 }
47189
47190 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1invalid_1amount(JNIEnv *env, jclass clz) {
47191         jclass ret_conv = LDKCreationError_to_java(env, CreationError_invalid_amount());
47192         return ret_conv;
47193 }
47194
47195 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1missing_1route_1hints(JNIEnv *env, jclass clz) {
47196         jclass ret_conv = LDKCreationError_to_java(env, CreationError_missing_route_hints());
47197         return ret_conv;
47198 }
47199
47200 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47201         LDKCreationError* a_conv = (LDKCreationError*)untag_ptr(a);
47202         LDKCreationError* b_conv = (LDKCreationError*)untag_ptr(b);
47203         jboolean ret_conv = CreationError_eq(a_conv, b_conv);
47204         return ret_conv;
47205 }
47206
47207 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
47208         LDKCreationError* o_conv = (LDKCreationError*)untag_ptr(o);
47209         LDKStr ret_str = CreationError_to_str(o_conv);
47210         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
47211         Str_free(ret_str);
47212         return ret_conv;
47213 }
47214
47215 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47216         LDKSemanticError* orig_conv = (LDKSemanticError*)untag_ptr(orig);
47217         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
47218         return ret_conv;
47219 }
47220
47221 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
47222         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
47223         return ret_conv;
47224 }
47225
47226 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
47227         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
47228         return ret_conv;
47229 }
47230
47231 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
47232         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
47233         return ret_conv;
47234 }
47235
47236 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
47237         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
47238         return ret_conv;
47239 }
47240
47241 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) {
47242         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret());
47243         return ret_conv;
47244 }
47245
47246 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
47247         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
47248         return ret_conv;
47249 }
47250
47251 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
47252         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
47253         return ret_conv;
47254 }
47255
47256 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
47257         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
47258         return ret_conv;
47259 }
47260
47261 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
47262         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
47263         return ret_conv;
47264 }
47265
47266 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) {
47267         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount());
47268         return ret_conv;
47269 }
47270
47271 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47272         LDKSemanticError* a_conv = (LDKSemanticError*)untag_ptr(a);
47273         LDKSemanticError* b_conv = (LDKSemanticError*)untag_ptr(b);
47274         jboolean ret_conv = SemanticError_eq(a_conv, b_conv);
47275         return ret_conv;
47276 }
47277
47278 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
47279         LDKSemanticError* o_conv = (LDKSemanticError*)untag_ptr(o);
47280         LDKStr ret_str = SemanticError_to_str(o_conv);
47281         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
47282         Str_free(ret_str);
47283         return ret_conv;
47284 }
47285
47286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47287         if (!ptr_is_owned(this_ptr)) return;
47288         void* this_ptr_ptr = untag_ptr(this_ptr);
47289         CHECK_ACCESS(this_ptr_ptr);
47290         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
47291         FREE(untag_ptr(this_ptr));
47292         SignOrCreationError_free(this_ptr_conv);
47293 }
47294
47295 static inline uint64_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
47296         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
47297         *ret_copy = SignOrCreationError_clone(arg);
47298         int64_t ret_ref = tag_ptr(ret_copy, true);
47299         return ret_ref;
47300 }
47301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47302         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)untag_ptr(arg);
47303         int64_t ret_conv = SignOrCreationError_clone_ptr(arg_conv);
47304         return ret_conv;
47305 }
47306
47307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47308         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)untag_ptr(orig);
47309         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
47310         *ret_copy = SignOrCreationError_clone(orig_conv);
47311         int64_t ret_ref = tag_ptr(ret_copy, true);
47312         return ret_ref;
47313 }
47314
47315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
47316         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
47317         *ret_copy = SignOrCreationError_sign_error();
47318         int64_t ret_ref = tag_ptr(ret_copy, true);
47319         return ret_ref;
47320 }
47321
47322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
47323         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
47324         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
47325         *ret_copy = SignOrCreationError_creation_error(a_conv);
47326         int64_t ret_ref = tag_ptr(ret_copy, true);
47327         return ret_ref;
47328 }
47329
47330 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47331         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)untag_ptr(a);
47332         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)untag_ptr(b);
47333         jboolean ret_conv = SignOrCreationError_eq(a_conv, b_conv);
47334         return ret_conv;
47335 }
47336
47337 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
47338         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)untag_ptr(o);
47339         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
47340         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
47341         Str_free(ret_str);
47342         return ret_conv;
47343 }
47344
47345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47346         LDKInvoicePayer this_obj_conv;
47347         this_obj_conv.inner = untag_ptr(this_obj);
47348         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47350         InvoicePayer_free(this_obj_conv);
47351 }
47352
47353 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47354         if (!ptr_is_owned(this_ptr)) return;
47355         void* this_ptr_ptr = untag_ptr(this_ptr);
47356         CHECK_ACCESS(this_ptr_ptr);
47357         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
47358         FREE(untag_ptr(this_ptr));
47359         Payer_free(this_ptr_conv);
47360 }
47361
47362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47363         if (!ptr_is_owned(this_ptr)) return;
47364         void* this_ptr_ptr = untag_ptr(this_ptr);
47365         CHECK_ACCESS(this_ptr_ptr);
47366         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
47367         FREE(untag_ptr(this_ptr));
47368         Router_free(this_ptr_conv);
47369 }
47370
47371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Retry_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47372         if (!ptr_is_owned(this_ptr)) return;
47373         void* this_ptr_ptr = untag_ptr(this_ptr);
47374         CHECK_ACCESS(this_ptr_ptr);
47375         LDKRetry this_ptr_conv = *(LDKRetry*)(this_ptr_ptr);
47376         FREE(untag_ptr(this_ptr));
47377         Retry_free(this_ptr_conv);
47378 }
47379
47380 static inline uint64_t Retry_clone_ptr(LDKRetry *NONNULL_PTR arg) {
47381         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
47382         *ret_copy = Retry_clone(arg);
47383         int64_t ret_ref = tag_ptr(ret_copy, true);
47384         return ret_ref;
47385 }
47386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47387         LDKRetry* arg_conv = (LDKRetry*)untag_ptr(arg);
47388         int64_t ret_conv = Retry_clone_ptr(arg_conv);
47389         return ret_conv;
47390 }
47391
47392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47393         LDKRetry* orig_conv = (LDKRetry*)untag_ptr(orig);
47394         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
47395         *ret_copy = Retry_clone(orig_conv);
47396         int64_t ret_ref = tag_ptr(ret_copy, true);
47397         return ret_ref;
47398 }
47399
47400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1attempts(JNIEnv *env, jclass clz, int64_t a) {
47401         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
47402         *ret_copy = Retry_attempts(a);
47403         int64_t ret_ref = tag_ptr(ret_copy, true);
47404         return ret_ref;
47405 }
47406
47407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1timeout(JNIEnv *env, jclass clz, int64_t a) {
47408         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
47409         *ret_copy = Retry_timeout(a);
47410         int64_t ret_ref = tag_ptr(ret_copy, true);
47411         return ret_ref;
47412 }
47413
47414 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Retry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47415         LDKRetry* a_conv = (LDKRetry*)untag_ptr(a);
47416         LDKRetry* b_conv = (LDKRetry*)untag_ptr(b);
47417         jboolean ret_conv = Retry_eq(a_conv, b_conv);
47418         return ret_conv;
47419 }
47420
47421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1hash(JNIEnv *env, jclass clz, int64_t o) {
47422         LDKRetry* o_conv = (LDKRetry*)untag_ptr(o);
47423         int64_t ret_conv = Retry_hash(o_conv);
47424         return ret_conv;
47425 }
47426
47427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47428         if (!ptr_is_owned(this_ptr)) return;
47429         void* this_ptr_ptr = untag_ptr(this_ptr);
47430         CHECK_ACCESS(this_ptr_ptr);
47431         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
47432         FREE(untag_ptr(this_ptr));
47433         PaymentError_free(this_ptr_conv);
47434 }
47435
47436 static inline uint64_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
47437         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
47438         *ret_copy = PaymentError_clone(arg);
47439         int64_t ret_ref = tag_ptr(ret_copy, true);
47440         return ret_ref;
47441 }
47442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47443         LDKPaymentError* arg_conv = (LDKPaymentError*)untag_ptr(arg);
47444         int64_t ret_conv = PaymentError_clone_ptr(arg_conv);
47445         return ret_conv;
47446 }
47447
47448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47449         LDKPaymentError* orig_conv = (LDKPaymentError*)untag_ptr(orig);
47450         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
47451         *ret_copy = PaymentError_clone(orig_conv);
47452         int64_t ret_ref = tag_ptr(ret_copy, true);
47453         return ret_ref;
47454 }
47455
47456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1invoice(JNIEnv *env, jclass clz, jstring a) {
47457         LDKStr a_conv = java_to_owned_str(env, a);
47458         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
47459         *ret_copy = PaymentError_invoice(a_conv);
47460         int64_t ret_ref = tag_ptr(ret_copy, true);
47461         return ret_ref;
47462 }
47463
47464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1routing(JNIEnv *env, jclass clz, int64_t a) {
47465         LDKLightningError a_conv;
47466         a_conv.inner = untag_ptr(a);
47467         a_conv.is_owned = ptr_is_owned(a);
47468         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47469         a_conv = LightningError_clone(&a_conv);
47470         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
47471         *ret_copy = PaymentError_routing(a_conv);
47472         int64_t ret_ref = tag_ptr(ret_copy, true);
47473         return ret_ref;
47474 }
47475
47476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1sending(JNIEnv *env, jclass clz, int64_t a) {
47477         void* a_ptr = untag_ptr(a);
47478         CHECK_ACCESS(a_ptr);
47479         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
47480         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(a));
47481         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
47482         *ret_copy = PaymentError_sending(a_conv);
47483         int64_t ret_ref = tag_ptr(ret_copy, true);
47484         return ret_ref;
47485 }
47486
47487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1new(JNIEnv *env, jclass clz, int64_t payer, int64_t router, int64_t scorer, int64_t logger, int64_t event_handler, int64_t retry) {
47488         void* payer_ptr = untag_ptr(payer);
47489         CHECK_ACCESS(payer_ptr);
47490         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
47491         if (payer_conv.free == LDKPayer_JCalls_free) {
47492                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47493                 LDKPayer_JCalls_cloned(&payer_conv);
47494         }
47495         void* router_ptr = untag_ptr(router);
47496         CHECK_ACCESS(router_ptr);
47497         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
47498         if (router_conv.free == LDKRouter_JCalls_free) {
47499                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47500                 LDKRouter_JCalls_cloned(&router_conv);
47501         }
47502         LDKMultiThreadedLockableScore scorer_conv;
47503         scorer_conv.inner = untag_ptr(scorer);
47504         scorer_conv.is_owned = ptr_is_owned(scorer);
47505         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
47506         scorer_conv.is_owned = false;
47507         void* logger_ptr = untag_ptr(logger);
47508         CHECK_ACCESS(logger_ptr);
47509         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
47510         if (logger_conv.free == LDKLogger_JCalls_free) {
47511                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47512                 LDKLogger_JCalls_cloned(&logger_conv);
47513         }
47514         void* event_handler_ptr = untag_ptr(event_handler);
47515         CHECK_ACCESS(event_handler_ptr);
47516         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
47517         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
47518                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47519                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
47520         }
47521         void* retry_ptr = untag_ptr(retry);
47522         CHECK_ACCESS(retry_ptr);
47523         LDKRetry retry_conv = *(LDKRetry*)(retry_ptr);
47524         retry_conv = Retry_clone((LDKRetry*)untag_ptr(retry));
47525         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_conv);
47526         int64_t ret_ref = 0;
47527         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47528         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47529         return ret_ref;
47530 }
47531
47532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice) {
47533         LDKInvoicePayer this_arg_conv;
47534         this_arg_conv.inner = untag_ptr(this_arg);
47535         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47537         this_arg_conv.is_owned = false;
47538         LDKInvoice invoice_conv;
47539         invoice_conv.inner = untag_ptr(invoice);
47540         invoice_conv.is_owned = ptr_is_owned(invoice);
47541         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
47542         invoice_conv.is_owned = false;
47543         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
47544         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
47545         return tag_ptr(ret_conv, true);
47546 }
47547
47548 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) {
47549         LDKInvoicePayer this_arg_conv;
47550         this_arg_conv.inner = untag_ptr(this_arg);
47551         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47553         this_arg_conv.is_owned = false;
47554         LDKInvoice invoice_conv;
47555         invoice_conv.inner = untag_ptr(invoice);
47556         invoice_conv.is_owned = ptr_is_owned(invoice);
47557         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
47558         invoice_conv.is_owned = false;
47559         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
47560         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
47561         return tag_ptr(ret_conv, true);
47562 }
47563
47564 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) {
47565         LDKInvoicePayer this_arg_conv;
47566         this_arg_conv.inner = untag_ptr(this_arg);
47567         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47569         this_arg_conv.is_owned = false;
47570         LDKPublicKey pubkey_ref;
47571         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
47572         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
47573         LDKThirtyTwoBytes payment_preimage_ref;
47574         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
47575         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
47576         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
47577         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
47578         return tag_ptr(ret_conv, true);
47579 }
47580
47581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1remove_1cached_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
47582         LDKInvoicePayer this_arg_conv;
47583         this_arg_conv.inner = untag_ptr(this_arg);
47584         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47586         this_arg_conv.is_owned = false;
47587         unsigned char payment_hash_arr[32];
47588         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
47589         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
47590         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
47591         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
47592 }
47593
47594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
47595         LDKInvoicePayer this_arg_conv;
47596         this_arg_conv.inner = untag_ptr(this_arg);
47597         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47599         this_arg_conv.is_owned = false;
47600         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
47601         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
47602         return tag_ptr(ret_ret, true);
47603 }
47604
47605 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) {
47606         void* amt_msat_ptr = untag_ptr(amt_msat);
47607         CHECK_ACCESS(amt_msat_ptr);
47608         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
47609         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
47610         LDKThirtyTwoBytes payment_hash_ref;
47611         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
47612         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
47613         LDKStr description_conv = java_to_owned_str(env, description);
47614         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
47615         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
47616         if (phantom_route_hints_constr.datalen > 0)
47617                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
47618         else
47619                 phantom_route_hints_constr.data = NULL;
47620         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
47621         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
47622                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
47623                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
47624                 phantom_route_hints_conv_19_conv.inner = untag_ptr(phantom_route_hints_conv_19);
47625                 phantom_route_hints_conv_19_conv.is_owned = ptr_is_owned(phantom_route_hints_conv_19);
47626                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
47627                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
47628                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
47629         }
47630         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
47631         void* keys_manager_ptr = untag_ptr(keys_manager);
47632         CHECK_ACCESS(keys_manager_ptr);
47633         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
47634         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
47635                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47636                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
47637         }
47638         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
47639         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
47640         *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);
47641         return tag_ptr(ret_conv, true);
47642 }
47643
47644 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) {
47645         void* amt_msat_ptr = untag_ptr(amt_msat);
47646         CHECK_ACCESS(amt_msat_ptr);
47647         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
47648         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
47649         LDKThirtyTwoBytes payment_hash_ref;
47650         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
47651         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
47652         LDKSha256 description_hash_conv;
47653         description_hash_conv.inner = untag_ptr(description_hash);
47654         description_hash_conv.is_owned = ptr_is_owned(description_hash);
47655         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
47656         description_hash_conv = Sha256_clone(&description_hash_conv);
47657         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
47658         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
47659         if (phantom_route_hints_constr.datalen > 0)
47660                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
47661         else
47662                 phantom_route_hints_constr.data = NULL;
47663         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
47664         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
47665                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
47666                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
47667                 phantom_route_hints_conv_19_conv.inner = untag_ptr(phantom_route_hints_conv_19);
47668                 phantom_route_hints_conv_19_conv.is_owned = ptr_is_owned(phantom_route_hints_conv_19);
47669                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
47670                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
47671                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
47672         }
47673         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
47674         void* keys_manager_ptr = untag_ptr(keys_manager);
47675         CHECK_ACCESS(keys_manager_ptr);
47676         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
47677         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
47678                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47679                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
47680         }
47681         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
47682         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
47683         *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);
47684         return tag_ptr(ret_conv, true);
47685 }
47686
47687 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) {
47688         LDKChannelManager channelmanager_conv;
47689         channelmanager_conv.inner = untag_ptr(channelmanager);
47690         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
47691         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
47692         channelmanager_conv.is_owned = false;
47693         void* keys_manager_ptr = untag_ptr(keys_manager);
47694         CHECK_ACCESS(keys_manager_ptr);
47695         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
47696         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
47697                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47698                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
47699         }
47700         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
47701         void* amt_msat_ptr = untag_ptr(amt_msat);
47702         CHECK_ACCESS(amt_msat_ptr);
47703         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
47704         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
47705         LDKStr description_conv = java_to_owned_str(env, description);
47706         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
47707         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv, invoice_expiry_delta_secs);
47708         return tag_ptr(ret_conv, true);
47709 }
47710
47711 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) {
47712         LDKChannelManager channelmanager_conv;
47713         channelmanager_conv.inner = untag_ptr(channelmanager);
47714         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
47715         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
47716         channelmanager_conv.is_owned = false;
47717         void* keys_manager_ptr = untag_ptr(keys_manager);
47718         CHECK_ACCESS(keys_manager_ptr);
47719         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
47720         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
47721                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47722                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
47723         }
47724         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
47725         void* amt_msat_ptr = untag_ptr(amt_msat);
47726         CHECK_ACCESS(amt_msat_ptr);
47727         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
47728         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
47729         LDKSha256 description_hash_conv;
47730         description_hash_conv.inner = untag_ptr(description_hash);
47731         description_hash_conv.is_owned = ptr_is_owned(description_hash);
47732         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
47733         description_hash_conv = Sha256_clone(&description_hash_conv);
47734         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
47735         *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);
47736         return tag_ptr(ret_conv, true);
47737 }
47738
47739 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) {
47740         LDKChannelManager channelmanager_conv;
47741         channelmanager_conv.inner = untag_ptr(channelmanager);
47742         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
47743         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
47744         channelmanager_conv.is_owned = false;
47745         void* keys_manager_ptr = untag_ptr(keys_manager);
47746         CHECK_ACCESS(keys_manager_ptr);
47747         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
47748         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
47749                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47750                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
47751         }
47752         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
47753         void* amt_msat_ptr = untag_ptr(amt_msat);
47754         CHECK_ACCESS(amt_msat_ptr);
47755         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
47756         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
47757         LDKSha256 description_hash_conv;
47758         description_hash_conv.inner = untag_ptr(description_hash);
47759         description_hash_conv.is_owned = ptr_is_owned(description_hash);
47760         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
47761         description_hash_conv = Sha256_clone(&description_hash_conv);
47762         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
47763         *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);
47764         return tag_ptr(ret_conv, true);
47765 }
47766
47767 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) {
47768         LDKChannelManager channelmanager_conv;
47769         channelmanager_conv.inner = untag_ptr(channelmanager);
47770         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
47771         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
47772         channelmanager_conv.is_owned = false;
47773         void* keys_manager_ptr = untag_ptr(keys_manager);
47774         CHECK_ACCESS(keys_manager_ptr);
47775         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
47776         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
47777                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47778                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
47779         }
47780         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
47781         void* amt_msat_ptr = untag_ptr(amt_msat);
47782         CHECK_ACCESS(amt_msat_ptr);
47783         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
47784         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
47785         LDKStr description_conv = java_to_owned_str(env, description);
47786         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
47787         *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);
47788         return tag_ptr(ret_conv, true);
47789 }
47790
47791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47792         LDKDefaultRouter this_obj_conv;
47793         this_obj_conv.inner = untag_ptr(this_obj);
47794         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47796         DefaultRouter_free(this_obj_conv);
47797 }
47798
47799 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) {
47800         LDKNetworkGraph network_graph_conv;
47801         network_graph_conv.inner = untag_ptr(network_graph);
47802         network_graph_conv.is_owned = ptr_is_owned(network_graph);
47803         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
47804         network_graph_conv.is_owned = false;
47805         void* logger_ptr = untag_ptr(logger);
47806         CHECK_ACCESS(logger_ptr);
47807         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
47808         if (logger_conv.free == LDKLogger_JCalls_free) {
47809                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47810                 LDKLogger_JCalls_cloned(&logger_conv);
47811         }
47812         LDKThirtyTwoBytes random_seed_bytes_ref;
47813         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
47814         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_ref.data);
47815         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref);
47816         int64_t ret_ref = 0;
47817         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47818         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47819         return ret_ref;
47820 }
47821
47822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1as_1Router(JNIEnv *env, jclass clz, int64_t this_arg) {
47823         LDKDefaultRouter this_arg_conv;
47824         this_arg_conv.inner = untag_ptr(this_arg);
47825         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47827         this_arg_conv.is_owned = false;
47828         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
47829         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
47830         return tag_ptr(ret_ret, true);
47831 }
47832
47833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Payer(JNIEnv *env, jclass clz, int64_t this_arg) {
47834         LDKChannelManager this_arg_conv;
47835         this_arg_conv.inner = untag_ptr(this_arg);
47836         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47838         this_arg_conv.is_owned = false;
47839         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
47840         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
47841         return tag_ptr(ret_ret, true);
47842 }
47843
47844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
47845         LDKStr s_conv = java_to_owned_str(env, s);
47846         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
47847         *ret_conv = SiPrefix_from_str(s_conv);
47848         return tag_ptr(ret_conv, true);
47849 }
47850
47851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
47852         LDKStr s_conv = java_to_owned_str(env, s);
47853         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
47854         *ret_conv = Invoice_from_str(s_conv);
47855         return tag_ptr(ret_conv, true);
47856 }
47857
47858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
47859         LDKStr s_conv = java_to_owned_str(env, s);
47860         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
47861         *ret_conv = SignedRawInvoice_from_str(s_conv);
47862         return tag_ptr(ret_conv, true);
47863 }
47864
47865 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
47866         LDKParseError* o_conv = (LDKParseError*)untag_ptr(o);
47867         LDKStr ret_str = ParseError_to_str(o_conv);
47868         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
47869         Str_free(ret_str);
47870         return ret_conv;
47871 }
47872
47873 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
47874         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)untag_ptr(o);
47875         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
47876         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
47877         Str_free(ret_str);
47878         return ret_conv;
47879 }
47880
47881 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
47882         LDKInvoice o_conv;
47883         o_conv.inner = untag_ptr(o);
47884         o_conv.is_owned = ptr_is_owned(o);
47885         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
47886         o_conv.is_owned = false;
47887         LDKStr ret_str = Invoice_to_str(&o_conv);
47888         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
47889         Str_free(ret_str);
47890         return ret_conv;
47891 }
47892
47893 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
47894         LDKSignedRawInvoice o_conv;
47895         o_conv.inner = untag_ptr(o);
47896         o_conv.is_owned = ptr_is_owned(o);
47897         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
47898         o_conv.is_owned = false;
47899         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
47900         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
47901         Str_free(ret_str);
47902         return ret_conv;
47903 }
47904
47905 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
47906         LDKCurrency* o_conv = (LDKCurrency*)untag_ptr(o);
47907         LDKStr ret_str = Currency_to_str(o_conv);
47908         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
47909         Str_free(ret_str);
47910         return ret_conv;
47911 }
47912
47913 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
47914         LDKSiPrefix* o_conv = (LDKSiPrefix*)untag_ptr(o);
47915         LDKStr ret_str = SiPrefix_to_str(o_conv);
47916         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
47917         Str_free(ret_str);
47918         return ret_conv;
47919 }
47920
47921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47922         LDKRapidGossipSync this_obj_conv;
47923         this_obj_conv.inner = untag_ptr(this_obj);
47924         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47926         RapidGossipSync_free(this_obj_conv);
47927 }
47928
47929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1new(JNIEnv *env, jclass clz, int64_t network_graph) {
47930         LDKNetworkGraph network_graph_conv;
47931         network_graph_conv.inner = untag_ptr(network_graph);
47932         network_graph_conv.is_owned = ptr_is_owned(network_graph);
47933         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
47934         network_graph_conv.is_owned = false;
47935         LDKRapidGossipSync ret_var = RapidGossipSync_new(&network_graph_conv);
47936         int64_t ret_ref = 0;
47937         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47938         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47939         return ret_ref;
47940 }
47941
47942 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) {
47943         LDKRapidGossipSync this_arg_conv;
47944         this_arg_conv.inner = untag_ptr(this_arg);
47945         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47947         this_arg_conv.is_owned = false;
47948         LDKStr sync_path_conv = java_to_owned_str(env, sync_path);
47949         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
47950         *ret_conv = RapidGossipSync_sync_network_graph_with_file_path(&this_arg_conv, sync_path_conv);
47951         return tag_ptr(ret_conv, true);
47952 }
47953
47954 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1is_1initial_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_arg) {
47955         LDKRapidGossipSync this_arg_conv;
47956         this_arg_conv.inner = untag_ptr(this_arg);
47957         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47959         this_arg_conv.is_owned = false;
47960         jboolean ret_conv = RapidGossipSync_is_initial_sync_complete(&this_arg_conv);
47961         return ret_conv;
47962 }
47963
47964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47965         if (!ptr_is_owned(this_ptr)) return;
47966         void* this_ptr_ptr = untag_ptr(this_ptr);
47967         CHECK_ACCESS(this_ptr_ptr);
47968         LDKGraphSyncError this_ptr_conv = *(LDKGraphSyncError*)(this_ptr_ptr);
47969         FREE(untag_ptr(this_ptr));
47970         GraphSyncError_free(this_ptr_conv);
47971 }
47972
47973 static inline uint64_t GraphSyncError_clone_ptr(LDKGraphSyncError *NONNULL_PTR arg) {
47974         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
47975         *ret_copy = GraphSyncError_clone(arg);
47976         int64_t ret_ref = tag_ptr(ret_copy, true);
47977         return ret_ref;
47978 }
47979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47980         LDKGraphSyncError* arg_conv = (LDKGraphSyncError*)untag_ptr(arg);
47981         int64_t ret_conv = GraphSyncError_clone_ptr(arg_conv);
47982         return ret_conv;
47983 }
47984
47985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47986         LDKGraphSyncError* orig_conv = (LDKGraphSyncError*)untag_ptr(orig);
47987         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
47988         *ret_copy = GraphSyncError_clone(orig_conv);
47989         int64_t ret_ref = tag_ptr(ret_copy, true);
47990         return ret_ref;
47991 }
47992
47993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1decode_1error(JNIEnv *env, jclass clz, int64_t a) {
47994         LDKDecodeError a_conv;
47995         a_conv.inner = untag_ptr(a);
47996         a_conv.is_owned = ptr_is_owned(a);
47997         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47998         a_conv = DecodeError_clone(&a_conv);
47999         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
48000         *ret_copy = GraphSyncError_decode_error(a_conv);
48001         int64_t ret_ref = tag_ptr(ret_copy, true);
48002         return ret_ref;
48003 }
48004
48005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1lightning_1error(JNIEnv *env, jclass clz, int64_t a) {
48006         LDKLightningError a_conv;
48007         a_conv.inner = untag_ptr(a);
48008         a_conv.is_owned = ptr_is_owned(a);
48009         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48010         a_conv = LightningError_clone(&a_conv);
48011         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
48012         *ret_copy = GraphSyncError_lightning_error(a_conv);
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_RapidGossipSync_1update_1network_1graph(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray update_data) {
48018         LDKRapidGossipSync this_arg_conv;
48019         this_arg_conv.inner = untag_ptr(this_arg);
48020         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48022         this_arg_conv.is_owned = false;
48023         LDKu8slice update_data_ref;
48024         update_data_ref.datalen = (*env)->GetArrayLength(env, update_data);
48025         update_data_ref.data = (*env)->GetByteArrayElements (env, update_data, NULL);
48026         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
48027         *ret_conv = RapidGossipSync_update_network_graph(&this_arg_conv, update_data_ref);
48028         (*env)->ReleaseByteArrayElements(env, update_data, (int8_t*)update_data_ref.data, 0);
48029         return tag_ptr(ret_conv, true);
48030 }
48031