Merge pull request #120 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 LDKChannelMonitorUpdateStatus LDKChannelMonitorUpdateStatus_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 ChannelMonitorUpdateStatus.ordinal() from rust threw an exception.");
287         }
288         switch (ord) {
289                 case 0: return LDKChannelMonitorUpdateStatus_Completed;
290                 case 1: return LDKChannelMonitorUpdateStatus_InProgress;
291                 case 2: return LDKChannelMonitorUpdateStatus_PermanentFailure;
292         }
293         (*env)->FatalError(env, "A call to ChannelMonitorUpdateStatus.ordinal() from rust returned an invalid value.");
294         abort(); // Unreachable, but will let the compiler know we don't return here
295 }
296 static jclass ChannelMonitorUpdateStatus_class = NULL;
297 static jfieldID ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_Completed = NULL;
298 static jfieldID ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_InProgress = NULL;
299 static jfieldID ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_PermanentFailure = NULL;
300 JNIEXPORT void JNICALL Java_org_ldk_enums_ChannelMonitorUpdateStatus_init (JNIEnv *env, jclass clz) {
301         ChannelMonitorUpdateStatus_class = (*env)->NewGlobalRef(env, clz);
302         CHECK(ChannelMonitorUpdateStatus_class != NULL);
303         ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_Completed = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateStatus_class, "LDKChannelMonitorUpdateStatus_Completed", "Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
304         CHECK(ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_Completed != NULL);
305         ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_InProgress = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateStatus_class, "LDKChannelMonitorUpdateStatus_InProgress", "Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
306         CHECK(ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_InProgress != NULL);
307         ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_PermanentFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateStatus_class, "LDKChannelMonitorUpdateStatus_PermanentFailure", "Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
308         CHECK(ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_PermanentFailure != NULL);
309 }
310 static inline jclass LDKChannelMonitorUpdateStatus_to_java(JNIEnv *env, LDKChannelMonitorUpdateStatus val) {
311         switch (val) {
312                 case LDKChannelMonitorUpdateStatus_Completed:
313                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateStatus_class, ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_Completed);
314                 case LDKChannelMonitorUpdateStatus_InProgress:
315                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateStatus_class, ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_InProgress);
316                 case LDKChannelMonitorUpdateStatus_PermanentFailure:
317                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateStatus_class, ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_PermanentFailure);
318                 default: abort();
319         }
320 }
321
322 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass clz) {
323         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
324         if (UNLIKELY((*env)->ExceptionCheck(env))) {
325                 (*env)->ExceptionDescribe(env);
326                 (*env)->FatalError(env, "A call to ConfirmationTarget.ordinal() from rust threw an exception.");
327         }
328         switch (ord) {
329                 case 0: return LDKConfirmationTarget_Background;
330                 case 1: return LDKConfirmationTarget_Normal;
331                 case 2: return LDKConfirmationTarget_HighPriority;
332         }
333         (*env)->FatalError(env, "A call to ConfirmationTarget.ordinal() from rust returned an invalid value.");
334         abort(); // Unreachable, but will let the compiler know we don't return here
335 }
336 static jclass ConfirmationTarget_class = NULL;
337 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Background = NULL;
338 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
339 static jfieldID ConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
340 JNIEXPORT void JNICALL Java_org_ldk_enums_ConfirmationTarget_init (JNIEnv *env, jclass clz) {
341         ConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
342         CHECK(ConfirmationTarget_class != NULL);
343         ConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/ConfirmationTarget;");
344         CHECK(ConfirmationTarget_LDKConfirmationTarget_Background != NULL);
345         ConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/ConfirmationTarget;");
346         CHECK(ConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
347         ConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/ConfirmationTarget;");
348         CHECK(ConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
349 }
350 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
351         switch (val) {
352                 case LDKConfirmationTarget_Background:
353                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Background);
354                 case LDKConfirmationTarget_Normal:
355                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Normal);
356                 case LDKConfirmationTarget_HighPriority:
357                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_HighPriority);
358                 default: abort();
359         }
360 }
361
362 static inline LDKCreationError LDKCreationError_from_java(JNIEnv *env, jclass clz) {
363         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
364         if (UNLIKELY((*env)->ExceptionCheck(env))) {
365                 (*env)->ExceptionDescribe(env);
366                 (*env)->FatalError(env, "A call to CreationError.ordinal() from rust threw an exception.");
367         }
368         switch (ord) {
369                 case 0: return LDKCreationError_DescriptionTooLong;
370                 case 1: return LDKCreationError_RouteTooLong;
371                 case 2: return LDKCreationError_TimestampOutOfBounds;
372                 case 3: return LDKCreationError_InvalidAmount;
373                 case 4: return LDKCreationError_MissingRouteHints;
374         }
375         (*env)->FatalError(env, "A call to CreationError.ordinal() from rust returned an invalid value.");
376         abort(); // Unreachable, but will let the compiler know we don't return here
377 }
378 static jclass CreationError_class = NULL;
379 static jfieldID CreationError_LDKCreationError_DescriptionTooLong = NULL;
380 static jfieldID CreationError_LDKCreationError_RouteTooLong = NULL;
381 static jfieldID CreationError_LDKCreationError_TimestampOutOfBounds = NULL;
382 static jfieldID CreationError_LDKCreationError_InvalidAmount = NULL;
383 static jfieldID CreationError_LDKCreationError_MissingRouteHints = NULL;
384 JNIEXPORT void JNICALL Java_org_ldk_enums_CreationError_init (JNIEnv *env, jclass clz) {
385         CreationError_class = (*env)->NewGlobalRef(env, clz);
386         CHECK(CreationError_class != NULL);
387         CreationError_LDKCreationError_DescriptionTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_DescriptionTooLong", "Lorg/ldk/enums/CreationError;");
388         CHECK(CreationError_LDKCreationError_DescriptionTooLong != NULL);
389         CreationError_LDKCreationError_RouteTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_RouteTooLong", "Lorg/ldk/enums/CreationError;");
390         CHECK(CreationError_LDKCreationError_RouteTooLong != NULL);
391         CreationError_LDKCreationError_TimestampOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_TimestampOutOfBounds", "Lorg/ldk/enums/CreationError;");
392         CHECK(CreationError_LDKCreationError_TimestampOutOfBounds != NULL);
393         CreationError_LDKCreationError_InvalidAmount = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_InvalidAmount", "Lorg/ldk/enums/CreationError;");
394         CHECK(CreationError_LDKCreationError_InvalidAmount != NULL);
395         CreationError_LDKCreationError_MissingRouteHints = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_MissingRouteHints", "Lorg/ldk/enums/CreationError;");
396         CHECK(CreationError_LDKCreationError_MissingRouteHints != NULL);
397 }
398 static inline jclass LDKCreationError_to_java(JNIEnv *env, LDKCreationError val) {
399         switch (val) {
400                 case LDKCreationError_DescriptionTooLong:
401                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_DescriptionTooLong);
402                 case LDKCreationError_RouteTooLong:
403                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_RouteTooLong);
404                 case LDKCreationError_TimestampOutOfBounds:
405                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_TimestampOutOfBounds);
406                 case LDKCreationError_InvalidAmount:
407                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_InvalidAmount);
408                 case LDKCreationError_MissingRouteHints:
409                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_MissingRouteHints);
410                 default: abort();
411         }
412 }
413
414 static inline LDKCurrency LDKCurrency_from_java(JNIEnv *env, jclass clz) {
415         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
416         if (UNLIKELY((*env)->ExceptionCheck(env))) {
417                 (*env)->ExceptionDescribe(env);
418                 (*env)->FatalError(env, "A call to Currency.ordinal() from rust threw an exception.");
419         }
420         switch (ord) {
421                 case 0: return LDKCurrency_Bitcoin;
422                 case 1: return LDKCurrency_BitcoinTestnet;
423                 case 2: return LDKCurrency_Regtest;
424                 case 3: return LDKCurrency_Simnet;
425                 case 4: return LDKCurrency_Signet;
426         }
427         (*env)->FatalError(env, "A call to Currency.ordinal() from rust returned an invalid value.");
428         abort(); // Unreachable, but will let the compiler know we don't return here
429 }
430 static jclass Currency_class = NULL;
431 static jfieldID Currency_LDKCurrency_Bitcoin = NULL;
432 static jfieldID Currency_LDKCurrency_BitcoinTestnet = NULL;
433 static jfieldID Currency_LDKCurrency_Regtest = NULL;
434 static jfieldID Currency_LDKCurrency_Simnet = NULL;
435 static jfieldID Currency_LDKCurrency_Signet = NULL;
436 JNIEXPORT void JNICALL Java_org_ldk_enums_Currency_init (JNIEnv *env, jclass clz) {
437         Currency_class = (*env)->NewGlobalRef(env, clz);
438         CHECK(Currency_class != NULL);
439         Currency_LDKCurrency_Bitcoin = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Bitcoin", "Lorg/ldk/enums/Currency;");
440         CHECK(Currency_LDKCurrency_Bitcoin != NULL);
441         Currency_LDKCurrency_BitcoinTestnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_BitcoinTestnet", "Lorg/ldk/enums/Currency;");
442         CHECK(Currency_LDKCurrency_BitcoinTestnet != NULL);
443         Currency_LDKCurrency_Regtest = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Regtest", "Lorg/ldk/enums/Currency;");
444         CHECK(Currency_LDKCurrency_Regtest != NULL);
445         Currency_LDKCurrency_Simnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Simnet", "Lorg/ldk/enums/Currency;");
446         CHECK(Currency_LDKCurrency_Simnet != NULL);
447         Currency_LDKCurrency_Signet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Signet", "Lorg/ldk/enums/Currency;");
448         CHECK(Currency_LDKCurrency_Signet != NULL);
449 }
450 static inline jclass LDKCurrency_to_java(JNIEnv *env, LDKCurrency val) {
451         switch (val) {
452                 case LDKCurrency_Bitcoin:
453                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Bitcoin);
454                 case LDKCurrency_BitcoinTestnet:
455                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_BitcoinTestnet);
456                 case LDKCurrency_Regtest:
457                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Regtest);
458                 case LDKCurrency_Simnet:
459                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Simnet);
460                 case LDKCurrency_Signet:
461                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Signet);
462                 default: abort();
463         }
464 }
465
466 static inline LDKIOError LDKIOError_from_java(JNIEnv *env, jclass clz) {
467         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
468         if (UNLIKELY((*env)->ExceptionCheck(env))) {
469                 (*env)->ExceptionDescribe(env);
470                 (*env)->FatalError(env, "A call to IOError.ordinal() from rust threw an exception.");
471         }
472         switch (ord) {
473                 case 0: return LDKIOError_NotFound;
474                 case 1: return LDKIOError_PermissionDenied;
475                 case 2: return LDKIOError_ConnectionRefused;
476                 case 3: return LDKIOError_ConnectionReset;
477                 case 4: return LDKIOError_ConnectionAborted;
478                 case 5: return LDKIOError_NotConnected;
479                 case 6: return LDKIOError_AddrInUse;
480                 case 7: return LDKIOError_AddrNotAvailable;
481                 case 8: return LDKIOError_BrokenPipe;
482                 case 9: return LDKIOError_AlreadyExists;
483                 case 10: return LDKIOError_WouldBlock;
484                 case 11: return LDKIOError_InvalidInput;
485                 case 12: return LDKIOError_InvalidData;
486                 case 13: return LDKIOError_TimedOut;
487                 case 14: return LDKIOError_WriteZero;
488                 case 15: return LDKIOError_Interrupted;
489                 case 16: return LDKIOError_Other;
490                 case 17: return LDKIOError_UnexpectedEof;
491         }
492         (*env)->FatalError(env, "A call to IOError.ordinal() from rust returned an invalid value.");
493         abort(); // Unreachable, but will let the compiler know we don't return here
494 }
495 static jclass IOError_class = NULL;
496 static jfieldID IOError_LDKIOError_NotFound = NULL;
497 static jfieldID IOError_LDKIOError_PermissionDenied = NULL;
498 static jfieldID IOError_LDKIOError_ConnectionRefused = NULL;
499 static jfieldID IOError_LDKIOError_ConnectionReset = NULL;
500 static jfieldID IOError_LDKIOError_ConnectionAborted = NULL;
501 static jfieldID IOError_LDKIOError_NotConnected = NULL;
502 static jfieldID IOError_LDKIOError_AddrInUse = NULL;
503 static jfieldID IOError_LDKIOError_AddrNotAvailable = NULL;
504 static jfieldID IOError_LDKIOError_BrokenPipe = NULL;
505 static jfieldID IOError_LDKIOError_AlreadyExists = NULL;
506 static jfieldID IOError_LDKIOError_WouldBlock = NULL;
507 static jfieldID IOError_LDKIOError_InvalidInput = NULL;
508 static jfieldID IOError_LDKIOError_InvalidData = NULL;
509 static jfieldID IOError_LDKIOError_TimedOut = NULL;
510 static jfieldID IOError_LDKIOError_WriteZero = NULL;
511 static jfieldID IOError_LDKIOError_Interrupted = NULL;
512 static jfieldID IOError_LDKIOError_Other = NULL;
513 static jfieldID IOError_LDKIOError_UnexpectedEof = NULL;
514 JNIEXPORT void JNICALL Java_org_ldk_enums_IOError_init (JNIEnv *env, jclass clz) {
515         IOError_class = (*env)->NewGlobalRef(env, clz);
516         CHECK(IOError_class != NULL);
517         IOError_LDKIOError_NotFound = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotFound", "Lorg/ldk/enums/IOError;");
518         CHECK(IOError_LDKIOError_NotFound != NULL);
519         IOError_LDKIOError_PermissionDenied = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_PermissionDenied", "Lorg/ldk/enums/IOError;");
520         CHECK(IOError_LDKIOError_PermissionDenied != NULL);
521         IOError_LDKIOError_ConnectionRefused = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionRefused", "Lorg/ldk/enums/IOError;");
522         CHECK(IOError_LDKIOError_ConnectionRefused != NULL);
523         IOError_LDKIOError_ConnectionReset = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionReset", "Lorg/ldk/enums/IOError;");
524         CHECK(IOError_LDKIOError_ConnectionReset != NULL);
525         IOError_LDKIOError_ConnectionAborted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionAborted", "Lorg/ldk/enums/IOError;");
526         CHECK(IOError_LDKIOError_ConnectionAborted != NULL);
527         IOError_LDKIOError_NotConnected = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotConnected", "Lorg/ldk/enums/IOError;");
528         CHECK(IOError_LDKIOError_NotConnected != NULL);
529         IOError_LDKIOError_AddrInUse = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrInUse", "Lorg/ldk/enums/IOError;");
530         CHECK(IOError_LDKIOError_AddrInUse != NULL);
531         IOError_LDKIOError_AddrNotAvailable = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrNotAvailable", "Lorg/ldk/enums/IOError;");
532         CHECK(IOError_LDKIOError_AddrNotAvailable != NULL);
533         IOError_LDKIOError_BrokenPipe = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_BrokenPipe", "Lorg/ldk/enums/IOError;");
534         CHECK(IOError_LDKIOError_BrokenPipe != NULL);
535         IOError_LDKIOError_AlreadyExists = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AlreadyExists", "Lorg/ldk/enums/IOError;");
536         CHECK(IOError_LDKIOError_AlreadyExists != NULL);
537         IOError_LDKIOError_WouldBlock = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WouldBlock", "Lorg/ldk/enums/IOError;");
538         CHECK(IOError_LDKIOError_WouldBlock != NULL);
539         IOError_LDKIOError_InvalidInput = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidInput", "Lorg/ldk/enums/IOError;");
540         CHECK(IOError_LDKIOError_InvalidInput != NULL);
541         IOError_LDKIOError_InvalidData = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidData", "Lorg/ldk/enums/IOError;");
542         CHECK(IOError_LDKIOError_InvalidData != NULL);
543         IOError_LDKIOError_TimedOut = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_TimedOut", "Lorg/ldk/enums/IOError;");
544         CHECK(IOError_LDKIOError_TimedOut != NULL);
545         IOError_LDKIOError_WriteZero = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WriteZero", "Lorg/ldk/enums/IOError;");
546         CHECK(IOError_LDKIOError_WriteZero != NULL);
547         IOError_LDKIOError_Interrupted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Interrupted", "Lorg/ldk/enums/IOError;");
548         CHECK(IOError_LDKIOError_Interrupted != NULL);
549         IOError_LDKIOError_Other = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Other", "Lorg/ldk/enums/IOError;");
550         CHECK(IOError_LDKIOError_Other != NULL);
551         IOError_LDKIOError_UnexpectedEof = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_UnexpectedEof", "Lorg/ldk/enums/IOError;");
552         CHECK(IOError_LDKIOError_UnexpectedEof != NULL);
553 }
554 static inline jclass LDKIOError_to_java(JNIEnv *env, LDKIOError val) {
555         switch (val) {
556                 case LDKIOError_NotFound:
557                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotFound);
558                 case LDKIOError_PermissionDenied:
559                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_PermissionDenied);
560                 case LDKIOError_ConnectionRefused:
561                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionRefused);
562                 case LDKIOError_ConnectionReset:
563                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionReset);
564                 case LDKIOError_ConnectionAborted:
565                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionAborted);
566                 case LDKIOError_NotConnected:
567                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotConnected);
568                 case LDKIOError_AddrInUse:
569                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrInUse);
570                 case LDKIOError_AddrNotAvailable:
571                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrNotAvailable);
572                 case LDKIOError_BrokenPipe:
573                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_BrokenPipe);
574                 case LDKIOError_AlreadyExists:
575                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AlreadyExists);
576                 case LDKIOError_WouldBlock:
577                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WouldBlock);
578                 case LDKIOError_InvalidInput:
579                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidInput);
580                 case LDKIOError_InvalidData:
581                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidData);
582                 case LDKIOError_TimedOut:
583                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_TimedOut);
584                 case LDKIOError_WriteZero:
585                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WriteZero);
586                 case LDKIOError_Interrupted:
587                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Interrupted);
588                 case LDKIOError_Other:
589                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Other);
590                 case LDKIOError_UnexpectedEof:
591                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_UnexpectedEof);
592                 default: abort();
593         }
594 }
595
596 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) {
597         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
598         if (UNLIKELY((*env)->ExceptionCheck(env))) {
599                 (*env)->ExceptionDescribe(env);
600                 (*env)->FatalError(env, "A call to Level.ordinal() from rust threw an exception.");
601         }
602         switch (ord) {
603                 case 0: return LDKLevel_Gossip;
604                 case 1: return LDKLevel_Trace;
605                 case 2: return LDKLevel_Debug;
606                 case 3: return LDKLevel_Info;
607                 case 4: return LDKLevel_Warn;
608                 case 5: return LDKLevel_Error;
609         }
610         (*env)->FatalError(env, "A call to Level.ordinal() from rust returned an invalid value.");
611         abort(); // Unreachable, but will let the compiler know we don't return here
612 }
613 static jclass Level_class = NULL;
614 static jfieldID Level_LDKLevel_Gossip = NULL;
615 static jfieldID Level_LDKLevel_Trace = NULL;
616 static jfieldID Level_LDKLevel_Debug = NULL;
617 static jfieldID Level_LDKLevel_Info = NULL;
618 static jfieldID Level_LDKLevel_Warn = NULL;
619 static jfieldID Level_LDKLevel_Error = NULL;
620 JNIEXPORT void JNICALL Java_org_ldk_enums_Level_init (JNIEnv *env, jclass clz) {
621         Level_class = (*env)->NewGlobalRef(env, clz);
622         CHECK(Level_class != NULL);
623         Level_LDKLevel_Gossip = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Gossip", "Lorg/ldk/enums/Level;");
624         CHECK(Level_LDKLevel_Gossip != NULL);
625         Level_LDKLevel_Trace = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Trace", "Lorg/ldk/enums/Level;");
626         CHECK(Level_LDKLevel_Trace != NULL);
627         Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;");
628         CHECK(Level_LDKLevel_Debug != NULL);
629         Level_LDKLevel_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;");
630         CHECK(Level_LDKLevel_Info != NULL);
631         Level_LDKLevel_Warn = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Warn", "Lorg/ldk/enums/Level;");
632         CHECK(Level_LDKLevel_Warn != NULL);
633         Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;");
634         CHECK(Level_LDKLevel_Error != NULL);
635 }
636 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
637         switch (val) {
638                 case LDKLevel_Gossip:
639                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Gossip);
640                 case LDKLevel_Trace:
641                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Trace);
642                 case LDKLevel_Debug:
643                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug);
644                 case LDKLevel_Info:
645                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info);
646                 case LDKLevel_Warn:
647                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn);
648                 case LDKLevel_Error:
649                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error);
650                 default: abort();
651         }
652 }
653
654 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
655         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
656         if (UNLIKELY((*env)->ExceptionCheck(env))) {
657                 (*env)->ExceptionDescribe(env);
658                 (*env)->FatalError(env, "A call to Network.ordinal() from rust threw an exception.");
659         }
660         switch (ord) {
661                 case 0: return LDKNetwork_Bitcoin;
662                 case 1: return LDKNetwork_Testnet;
663                 case 2: return LDKNetwork_Regtest;
664                 case 3: return LDKNetwork_Signet;
665         }
666         (*env)->FatalError(env, "A call to Network.ordinal() from rust returned an invalid value.");
667         abort(); // Unreachable, but will let the compiler know we don't return here
668 }
669 static jclass Network_class = NULL;
670 static jfieldID Network_LDKNetwork_Bitcoin = NULL;
671 static jfieldID Network_LDKNetwork_Testnet = NULL;
672 static jfieldID Network_LDKNetwork_Regtest = NULL;
673 static jfieldID Network_LDKNetwork_Signet = NULL;
674 JNIEXPORT void JNICALL Java_org_ldk_enums_Network_init (JNIEnv *env, jclass clz) {
675         Network_class = (*env)->NewGlobalRef(env, clz);
676         CHECK(Network_class != NULL);
677         Network_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/Network;");
678         CHECK(Network_LDKNetwork_Bitcoin != NULL);
679         Network_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/Network;");
680         CHECK(Network_LDKNetwork_Testnet != NULL);
681         Network_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/Network;");
682         CHECK(Network_LDKNetwork_Regtest != NULL);
683         Network_LDKNetwork_Signet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Signet", "Lorg/ldk/enums/Network;");
684         CHECK(Network_LDKNetwork_Signet != NULL);
685 }
686 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
687         switch (val) {
688                 case LDKNetwork_Bitcoin:
689                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Bitcoin);
690                 case LDKNetwork_Testnet:
691                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Testnet);
692                 case LDKNetwork_Regtest:
693                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Regtest);
694                 case LDKNetwork_Signet:
695                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Signet);
696                 default: abort();
697         }
698 }
699
700 static inline LDKRecipient LDKRecipient_from_java(JNIEnv *env, jclass clz) {
701         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
702         if (UNLIKELY((*env)->ExceptionCheck(env))) {
703                 (*env)->ExceptionDescribe(env);
704                 (*env)->FatalError(env, "A call to Recipient.ordinal() from rust threw an exception.");
705         }
706         switch (ord) {
707                 case 0: return LDKRecipient_Node;
708                 case 1: return LDKRecipient_PhantomNode;
709         }
710         (*env)->FatalError(env, "A call to Recipient.ordinal() from rust returned an invalid value.");
711         abort(); // Unreachable, but will let the compiler know we don't return here
712 }
713 static jclass Recipient_class = NULL;
714 static jfieldID Recipient_LDKRecipient_Node = NULL;
715 static jfieldID Recipient_LDKRecipient_PhantomNode = NULL;
716 JNIEXPORT void JNICALL Java_org_ldk_enums_Recipient_init (JNIEnv *env, jclass clz) {
717         Recipient_class = (*env)->NewGlobalRef(env, clz);
718         CHECK(Recipient_class != NULL);
719         Recipient_LDKRecipient_Node = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_Node", "Lorg/ldk/enums/Recipient;");
720         CHECK(Recipient_LDKRecipient_Node != NULL);
721         Recipient_LDKRecipient_PhantomNode = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_PhantomNode", "Lorg/ldk/enums/Recipient;");
722         CHECK(Recipient_LDKRecipient_PhantomNode != NULL);
723 }
724 static inline jclass LDKRecipient_to_java(JNIEnv *env, LDKRecipient val) {
725         switch (val) {
726                 case LDKRecipient_Node:
727                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_Node);
728                 case LDKRecipient_PhantomNode:
729                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_PhantomNode);
730                 default: abort();
731         }
732 }
733
734 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
735         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
736         if (UNLIKELY((*env)->ExceptionCheck(env))) {
737                 (*env)->ExceptionDescribe(env);
738                 (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust threw an exception.");
739         }
740         switch (ord) {
741                 case 0: return LDKSecp256k1Error_IncorrectSignature;
742                 case 1: return LDKSecp256k1Error_InvalidMessage;
743                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
744                 case 3: return LDKSecp256k1Error_InvalidSignature;
745                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
746                 case 5: return LDKSecp256k1Error_InvalidSharedSecret;
747                 case 6: return LDKSecp256k1Error_InvalidRecoveryId;
748                 case 7: return LDKSecp256k1Error_InvalidTweak;
749                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
750                 case 9: return LDKSecp256k1Error_InvalidPublicKeySum;
751                 case 10: return LDKSecp256k1Error_InvalidParityValue;
752         }
753         (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust returned an invalid value.");
754         abort(); // Unreachable, but will let the compiler know we don't return here
755 }
756 static jclass Secp256k1Error_class = NULL;
757 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
758 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
759 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
760 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
761 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
762 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret = NULL;
763 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
764 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
765 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
766 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum = NULL;
767 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidParityValue = NULL;
768 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
769         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
770         CHECK(Secp256k1Error_class != NULL);
771         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
772         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
773         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
774         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
775         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
776         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
777         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
778         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
779         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
780         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
781         Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSharedSecret", "Lorg/ldk/enums/Secp256k1Error;");
782         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret != NULL);
783         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
784         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
785         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
786         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
787         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
788         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
789         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKeySum", "Lorg/ldk/enums/Secp256k1Error;");
790         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum != NULL);
791         Secp256k1Error_LDKSecp256k1Error_InvalidParityValue = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidParityValue", "Lorg/ldk/enums/Secp256k1Error;");
792         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidParityValue != NULL);
793 }
794 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
795         switch (val) {
796                 case LDKSecp256k1Error_IncorrectSignature:
797                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
798                 case LDKSecp256k1Error_InvalidMessage:
799                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
800                 case LDKSecp256k1Error_InvalidPublicKey:
801                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
802                 case LDKSecp256k1Error_InvalidSignature:
803                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
804                 case LDKSecp256k1Error_InvalidSecretKey:
805                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
806                 case LDKSecp256k1Error_InvalidSharedSecret:
807                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret);
808                 case LDKSecp256k1Error_InvalidRecoveryId:
809                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
810                 case LDKSecp256k1Error_InvalidTweak:
811                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
812                 case LDKSecp256k1Error_NotEnoughMemory:
813                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
814                 case LDKSecp256k1Error_InvalidPublicKeySum:
815                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum);
816                 case LDKSecp256k1Error_InvalidParityValue:
817                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidParityValue);
818                 default: abort();
819         }
820 }
821
822 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
823         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
824         if (UNLIKELY((*env)->ExceptionCheck(env))) {
825                 (*env)->ExceptionDescribe(env);
826                 (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust threw an exception.");
827         }
828         switch (ord) {
829                 case 0: return LDKSemanticError_NoPaymentHash;
830                 case 1: return LDKSemanticError_MultiplePaymentHashes;
831                 case 2: return LDKSemanticError_NoDescription;
832                 case 3: return LDKSemanticError_MultipleDescriptions;
833                 case 4: return LDKSemanticError_NoPaymentSecret;
834                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
835                 case 6: return LDKSemanticError_InvalidFeatures;
836                 case 7: return LDKSemanticError_InvalidRecoveryId;
837                 case 8: return LDKSemanticError_InvalidSignature;
838                 case 9: return LDKSemanticError_ImpreciseAmount;
839         }
840         (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust returned an invalid value.");
841         abort(); // Unreachable, but will let the compiler know we don't return here
842 }
843 static jclass SemanticError_class = NULL;
844 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
845 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
846 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
847 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
848 static jfieldID SemanticError_LDKSemanticError_NoPaymentSecret = NULL;
849 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
850 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
851 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
852 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
853 static jfieldID SemanticError_LDKSemanticError_ImpreciseAmount = NULL;
854 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
855         SemanticError_class = (*env)->NewGlobalRef(env, clz);
856         CHECK(SemanticError_class != NULL);
857         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
858         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
859         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
860         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
861         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
862         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
863         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
864         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
865         SemanticError_LDKSemanticError_NoPaymentSecret = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentSecret", "Lorg/ldk/enums/SemanticError;");
866         CHECK(SemanticError_LDKSemanticError_NoPaymentSecret != NULL);
867         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
868         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
869         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
870         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
871         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
872         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
873         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
874         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
875         SemanticError_LDKSemanticError_ImpreciseAmount = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_ImpreciseAmount", "Lorg/ldk/enums/SemanticError;");
876         CHECK(SemanticError_LDKSemanticError_ImpreciseAmount != NULL);
877 }
878 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
879         switch (val) {
880                 case LDKSemanticError_NoPaymentHash:
881                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
882                 case LDKSemanticError_MultiplePaymentHashes:
883                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
884                 case LDKSemanticError_NoDescription:
885                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
886                 case LDKSemanticError_MultipleDescriptions:
887                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
888                 case LDKSemanticError_NoPaymentSecret:
889                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentSecret);
890                 case LDKSemanticError_MultiplePaymentSecrets:
891                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
892                 case LDKSemanticError_InvalidFeatures:
893                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
894                 case LDKSemanticError_InvalidRecoveryId:
895                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
896                 case LDKSemanticError_InvalidSignature:
897                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
898                 case LDKSemanticError_ImpreciseAmount:
899                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_ImpreciseAmount);
900                 default: abort();
901         }
902 }
903
904 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
905         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
906         if (UNLIKELY((*env)->ExceptionCheck(env))) {
907                 (*env)->ExceptionDescribe(env);
908                 (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust threw an exception.");
909         }
910         switch (ord) {
911                 case 0: return LDKSiPrefix_Milli;
912                 case 1: return LDKSiPrefix_Micro;
913                 case 2: return LDKSiPrefix_Nano;
914                 case 3: return LDKSiPrefix_Pico;
915         }
916         (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust returned an invalid value.");
917         abort(); // Unreachable, but will let the compiler know we don't return here
918 }
919 static jclass SiPrefix_class = NULL;
920 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
921 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
922 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
923 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
924 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
925         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
926         CHECK(SiPrefix_class != NULL);
927         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
928         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
929         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
930         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
931         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
932         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
933         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
934         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
935 }
936 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
937         switch (val) {
938                 case LDKSiPrefix_Milli:
939                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
940                 case LDKSiPrefix_Micro:
941                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
942                 case LDKSiPrefix_Nano:
943                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
944                 case LDKSiPrefix_Pico:
945                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
946                 default: abort();
947         }
948 }
949
950 struct LDKThirtyTwoBytes BigEndianScalar_get_bytes (struct LDKBigEndianScalar* thing) {
951         LDKThirtyTwoBytes ret = { .data = *thing->big_endian_bytes };
952         return ret;
953 }
954 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BigEndianScalar_1get_1bytes(JNIEnv *env, jclass clz, int64_t thing) {
955         LDKBigEndianScalar* thing_conv = (LDKBigEndianScalar*)untag_ptr(thing);
956         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
957         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BigEndianScalar_get_bytes(thing_conv).data);
958         return ret_arr;
959 }
960
961 static void BigEndianScalar_free (struct LDKBigEndianScalar thing) {}
962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigEndianScalar_1free(JNIEnv *env, jclass clz, int64_t thing) {
963         if (!ptr_is_owned(thing)) return;
964         void* thing_ptr = untag_ptr(thing);
965         CHECK_ACCESS(thing_ptr);
966         LDKBigEndianScalar thing_conv = *(LDKBigEndianScalar*)(thing_ptr);
967         FREE(untag_ptr(thing));
968         BigEndianScalar_free(thing_conv);
969 }
970
971 static jclass LDKBech32Error_MissingSeparator_class = NULL;
972 static jmethodID LDKBech32Error_MissingSeparator_meth = NULL;
973 static jclass LDKBech32Error_InvalidChecksum_class = NULL;
974 static jmethodID LDKBech32Error_InvalidChecksum_meth = NULL;
975 static jclass LDKBech32Error_InvalidLength_class = NULL;
976 static jmethodID LDKBech32Error_InvalidLength_meth = NULL;
977 static jclass LDKBech32Error_InvalidChar_class = NULL;
978 static jmethodID LDKBech32Error_InvalidChar_meth = NULL;
979 static jclass LDKBech32Error_InvalidData_class = NULL;
980 static jmethodID LDKBech32Error_InvalidData_meth = NULL;
981 static jclass LDKBech32Error_InvalidPadding_class = NULL;
982 static jmethodID LDKBech32Error_InvalidPadding_meth = NULL;
983 static jclass LDKBech32Error_MixedCase_class = NULL;
984 static jmethodID LDKBech32Error_MixedCase_meth = NULL;
985 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBech32Error_init (JNIEnv *env, jclass clz) {
986         LDKBech32Error_MissingSeparator_class =
987                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MissingSeparator"));
988         CHECK(LDKBech32Error_MissingSeparator_class != NULL);
989         LDKBech32Error_MissingSeparator_meth = (*env)->GetMethodID(env, LDKBech32Error_MissingSeparator_class, "<init>", "()V");
990         CHECK(LDKBech32Error_MissingSeparator_meth != NULL);
991         LDKBech32Error_InvalidChecksum_class =
992                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChecksum"));
993         CHECK(LDKBech32Error_InvalidChecksum_class != NULL);
994         LDKBech32Error_InvalidChecksum_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChecksum_class, "<init>", "()V");
995         CHECK(LDKBech32Error_InvalidChecksum_meth != NULL);
996         LDKBech32Error_InvalidLength_class =
997                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidLength"));
998         CHECK(LDKBech32Error_InvalidLength_class != NULL);
999         LDKBech32Error_InvalidLength_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidLength_class, "<init>", "()V");
1000         CHECK(LDKBech32Error_InvalidLength_meth != NULL);
1001         LDKBech32Error_InvalidChar_class =
1002                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChar"));
1003         CHECK(LDKBech32Error_InvalidChar_class != NULL);
1004         LDKBech32Error_InvalidChar_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChar_class, "<init>", "(I)V");
1005         CHECK(LDKBech32Error_InvalidChar_meth != NULL);
1006         LDKBech32Error_InvalidData_class =
1007                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidData"));
1008         CHECK(LDKBech32Error_InvalidData_class != NULL);
1009         LDKBech32Error_InvalidData_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidData_class, "<init>", "(B)V");
1010         CHECK(LDKBech32Error_InvalidData_meth != NULL);
1011         LDKBech32Error_InvalidPadding_class =
1012                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidPadding"));
1013         CHECK(LDKBech32Error_InvalidPadding_class != NULL);
1014         LDKBech32Error_InvalidPadding_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidPadding_class, "<init>", "()V");
1015         CHECK(LDKBech32Error_InvalidPadding_meth != NULL);
1016         LDKBech32Error_MixedCase_class =
1017                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MixedCase"));
1018         CHECK(LDKBech32Error_MixedCase_class != NULL);
1019         LDKBech32Error_MixedCase_meth = (*env)->GetMethodID(env, LDKBech32Error_MixedCase_class, "<init>", "()V");
1020         CHECK(LDKBech32Error_MixedCase_meth != NULL);
1021 }
1022 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBech32Error_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1023         LDKBech32Error *obj = (LDKBech32Error*)untag_ptr(ptr);
1024         switch(obj->tag) {
1025                 case LDKBech32Error_MissingSeparator: {
1026                         return (*env)->NewObject(env, LDKBech32Error_MissingSeparator_class, LDKBech32Error_MissingSeparator_meth);
1027                 }
1028                 case LDKBech32Error_InvalidChecksum: {
1029                         return (*env)->NewObject(env, LDKBech32Error_InvalidChecksum_class, LDKBech32Error_InvalidChecksum_meth);
1030                 }
1031                 case LDKBech32Error_InvalidLength: {
1032                         return (*env)->NewObject(env, LDKBech32Error_InvalidLength_class, LDKBech32Error_InvalidLength_meth);
1033                 }
1034                 case LDKBech32Error_InvalidChar: {
1035                         int32_t invalid_char_conv = obj->invalid_char;
1036                         return (*env)->NewObject(env, LDKBech32Error_InvalidChar_class, LDKBech32Error_InvalidChar_meth, invalid_char_conv);
1037                 }
1038                 case LDKBech32Error_InvalidData: {
1039                         int8_t invalid_data_conv = obj->invalid_data;
1040                         return (*env)->NewObject(env, LDKBech32Error_InvalidData_class, LDKBech32Error_InvalidData_meth, invalid_data_conv);
1041                 }
1042                 case LDKBech32Error_InvalidPadding: {
1043                         return (*env)->NewObject(env, LDKBech32Error_InvalidPadding_class, LDKBech32Error_InvalidPadding_meth);
1044                 }
1045                 case LDKBech32Error_MixedCase: {
1046                         return (*env)->NewObject(env, LDKBech32Error_MixedCase_class, LDKBech32Error_MixedCase_meth);
1047                 }
1048                 default: abort();
1049         }
1050 }
1051 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
1052         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
1053         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
1054         return ret;
1055 }
1056 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) {
1057         LDKTxOut* thing_conv = (LDKTxOut*)untag_ptr(thing);
1058         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
1059         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
1060         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
1061         CVec_u8Z_free(ret_var);
1062         return ret_arr;
1063 }
1064
1065 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) {
1066         LDKTxOut* thing_conv = (LDKTxOut*)untag_ptr(thing);
1067         int64_t ret_conv = TxOut_get_value(thing_conv);
1068         return ret_conv;
1069 }
1070
1071 static inline struct LDKBlindedRoute CResult_BlindedRouteNoneZ_get_ok(LDKCResult_BlindedRouteNoneZ *NONNULL_PTR owner){
1072         LDKBlindedRoute ret = *owner->contents.result;
1073         ret.is_owned = false;
1074         return ret;
1075 }
1076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1077         LDKCResult_BlindedRouteNoneZ* owner_conv = (LDKCResult_BlindedRouteNoneZ*)untag_ptr(owner);
1078         LDKBlindedRoute ret_var = CResult_BlindedRouteNoneZ_get_ok(owner_conv);
1079         int64_t ret_ref = 0;
1080         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1081         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1082         return ret_ref;
1083 }
1084
1085 static inline void CResult_BlindedRouteNoneZ_get_err(LDKCResult_BlindedRouteNoneZ *NONNULL_PTR owner){
1086 CHECK(!owner->result_ok);
1087         return *owner->contents.err;
1088 }
1089 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1090         LDKCResult_BlindedRouteNoneZ* owner_conv = (LDKCResult_BlindedRouteNoneZ*)untag_ptr(owner);
1091         CResult_BlindedRouteNoneZ_get_err(owner_conv);
1092 }
1093
1094 static jclass LDKDecodeError_UnknownVersion_class = NULL;
1095 static jmethodID LDKDecodeError_UnknownVersion_meth = NULL;
1096 static jclass LDKDecodeError_UnknownRequiredFeature_class = NULL;
1097 static jmethodID LDKDecodeError_UnknownRequiredFeature_meth = NULL;
1098 static jclass LDKDecodeError_InvalidValue_class = NULL;
1099 static jmethodID LDKDecodeError_InvalidValue_meth = NULL;
1100 static jclass LDKDecodeError_ShortRead_class = NULL;
1101 static jmethodID LDKDecodeError_ShortRead_meth = NULL;
1102 static jclass LDKDecodeError_BadLengthDescriptor_class = NULL;
1103 static jmethodID LDKDecodeError_BadLengthDescriptor_meth = NULL;
1104 static jclass LDKDecodeError_Io_class = NULL;
1105 static jmethodID LDKDecodeError_Io_meth = NULL;
1106 static jclass LDKDecodeError_UnsupportedCompression_class = NULL;
1107 static jmethodID LDKDecodeError_UnsupportedCompression_meth = NULL;
1108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKDecodeError_init (JNIEnv *env, jclass clz) {
1109         LDKDecodeError_UnknownVersion_class =
1110                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$UnknownVersion"));
1111         CHECK(LDKDecodeError_UnknownVersion_class != NULL);
1112         LDKDecodeError_UnknownVersion_meth = (*env)->GetMethodID(env, LDKDecodeError_UnknownVersion_class, "<init>", "()V");
1113         CHECK(LDKDecodeError_UnknownVersion_meth != NULL);
1114         LDKDecodeError_UnknownRequiredFeature_class =
1115                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$UnknownRequiredFeature"));
1116         CHECK(LDKDecodeError_UnknownRequiredFeature_class != NULL);
1117         LDKDecodeError_UnknownRequiredFeature_meth = (*env)->GetMethodID(env, LDKDecodeError_UnknownRequiredFeature_class, "<init>", "()V");
1118         CHECK(LDKDecodeError_UnknownRequiredFeature_meth != NULL);
1119         LDKDecodeError_InvalidValue_class =
1120                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$InvalidValue"));
1121         CHECK(LDKDecodeError_InvalidValue_class != NULL);
1122         LDKDecodeError_InvalidValue_meth = (*env)->GetMethodID(env, LDKDecodeError_InvalidValue_class, "<init>", "()V");
1123         CHECK(LDKDecodeError_InvalidValue_meth != NULL);
1124         LDKDecodeError_ShortRead_class =
1125                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$ShortRead"));
1126         CHECK(LDKDecodeError_ShortRead_class != NULL);
1127         LDKDecodeError_ShortRead_meth = (*env)->GetMethodID(env, LDKDecodeError_ShortRead_class, "<init>", "()V");
1128         CHECK(LDKDecodeError_ShortRead_meth != NULL);
1129         LDKDecodeError_BadLengthDescriptor_class =
1130                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$BadLengthDescriptor"));
1131         CHECK(LDKDecodeError_BadLengthDescriptor_class != NULL);
1132         LDKDecodeError_BadLengthDescriptor_meth = (*env)->GetMethodID(env, LDKDecodeError_BadLengthDescriptor_class, "<init>", "()V");
1133         CHECK(LDKDecodeError_BadLengthDescriptor_meth != NULL);
1134         LDKDecodeError_Io_class =
1135                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$Io"));
1136         CHECK(LDKDecodeError_Io_class != NULL);
1137         LDKDecodeError_Io_meth = (*env)->GetMethodID(env, LDKDecodeError_Io_class, "<init>", "(Lorg/ldk/enums/IOError;)V");
1138         CHECK(LDKDecodeError_Io_meth != NULL);
1139         LDKDecodeError_UnsupportedCompression_class =
1140                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$UnsupportedCompression"));
1141         CHECK(LDKDecodeError_UnsupportedCompression_class != NULL);
1142         LDKDecodeError_UnsupportedCompression_meth = (*env)->GetMethodID(env, LDKDecodeError_UnsupportedCompression_class, "<init>", "()V");
1143         CHECK(LDKDecodeError_UnsupportedCompression_meth != NULL);
1144 }
1145 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKDecodeError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1146         LDKDecodeError *obj = (LDKDecodeError*)untag_ptr(ptr);
1147         switch(obj->tag) {
1148                 case LDKDecodeError_UnknownVersion: {
1149                         return (*env)->NewObject(env, LDKDecodeError_UnknownVersion_class, LDKDecodeError_UnknownVersion_meth);
1150                 }
1151                 case LDKDecodeError_UnknownRequiredFeature: {
1152                         return (*env)->NewObject(env, LDKDecodeError_UnknownRequiredFeature_class, LDKDecodeError_UnknownRequiredFeature_meth);
1153                 }
1154                 case LDKDecodeError_InvalidValue: {
1155                         return (*env)->NewObject(env, LDKDecodeError_InvalidValue_class, LDKDecodeError_InvalidValue_meth);
1156                 }
1157                 case LDKDecodeError_ShortRead: {
1158                         return (*env)->NewObject(env, LDKDecodeError_ShortRead_class, LDKDecodeError_ShortRead_meth);
1159                 }
1160                 case LDKDecodeError_BadLengthDescriptor: {
1161                         return (*env)->NewObject(env, LDKDecodeError_BadLengthDescriptor_class, LDKDecodeError_BadLengthDescriptor_meth);
1162                 }
1163                 case LDKDecodeError_Io: {
1164                         jclass io_conv = LDKIOError_to_java(env, obj->io);
1165                         return (*env)->NewObject(env, LDKDecodeError_Io_class, LDKDecodeError_Io_meth, io_conv);
1166                 }
1167                 case LDKDecodeError_UnsupportedCompression: {
1168                         return (*env)->NewObject(env, LDKDecodeError_UnsupportedCompression_class, LDKDecodeError_UnsupportedCompression_meth);
1169                 }
1170                 default: abort();
1171         }
1172 }
1173 static inline struct LDKBlindedRoute CResult_BlindedRouteDecodeErrorZ_get_ok(LDKCResult_BlindedRouteDecodeErrorZ *NONNULL_PTR owner){
1174         LDKBlindedRoute ret = *owner->contents.result;
1175         ret.is_owned = false;
1176         return ret;
1177 }
1178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1179         LDKCResult_BlindedRouteDecodeErrorZ* owner_conv = (LDKCResult_BlindedRouteDecodeErrorZ*)untag_ptr(owner);
1180         LDKBlindedRoute ret_var = CResult_BlindedRouteDecodeErrorZ_get_ok(owner_conv);
1181         int64_t ret_ref = 0;
1182         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1183         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1184         return ret_ref;
1185 }
1186
1187 static inline struct LDKDecodeError CResult_BlindedRouteDecodeErrorZ_get_err(LDKCResult_BlindedRouteDecodeErrorZ *NONNULL_PTR owner){
1188 CHECK(!owner->result_ok);
1189         return DecodeError_clone(&*owner->contents.err);
1190 }
1191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1192         LDKCResult_BlindedRouteDecodeErrorZ* owner_conv = (LDKCResult_BlindedRouteDecodeErrorZ*)untag_ptr(owner);
1193         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1194         *ret_copy = CResult_BlindedRouteDecodeErrorZ_get_err(owner_conv);
1195         int64_t ret_ref = tag_ptr(ret_copy, true);
1196         return ret_ref;
1197 }
1198
1199 static inline struct LDKBlindedHop CResult_BlindedHopDecodeErrorZ_get_ok(LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR owner){
1200         LDKBlindedHop ret = *owner->contents.result;
1201         ret.is_owned = false;
1202         return ret;
1203 }
1204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1205         LDKCResult_BlindedHopDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(owner);
1206         LDKBlindedHop ret_var = CResult_BlindedHopDecodeErrorZ_get_ok(owner_conv);
1207         int64_t ret_ref = 0;
1208         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1209         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1210         return ret_ref;
1211 }
1212
1213 static inline struct LDKDecodeError CResult_BlindedHopDecodeErrorZ_get_err(LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR owner){
1214 CHECK(!owner->result_ok);
1215         return DecodeError_clone(&*owner->contents.err);
1216 }
1217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1218         LDKCResult_BlindedHopDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(owner);
1219         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1220         *ret_copy = CResult_BlindedHopDecodeErrorZ_get_err(owner_conv);
1221         int64_t ret_ref = tag_ptr(ret_copy, true);
1222         return ret_ref;
1223 }
1224
1225 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
1226 CHECK(owner->result_ok);
1227         return *owner->contents.result;
1228 }
1229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1230         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)untag_ptr(owner);
1231         CResult_NoneNoneZ_get_ok(owner_conv);
1232 }
1233
1234 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
1235 CHECK(!owner->result_ok);
1236         return *owner->contents.err;
1237 }
1238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1239         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)untag_ptr(owner);
1240         CResult_NoneNoneZ_get_err(owner_conv);
1241 }
1242
1243 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
1244         LDKCounterpartyCommitmentSecrets ret = *owner->contents.result;
1245         ret.is_owned = false;
1246         return ret;
1247 }
1248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1249         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(owner);
1250         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
1251         int64_t ret_ref = 0;
1252         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1253         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1254         return ret_ref;
1255 }
1256
1257 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
1258 CHECK(!owner->result_ok);
1259         return DecodeError_clone(&*owner->contents.err);
1260 }
1261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1262         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(owner);
1263         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1264         *ret_copy = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
1265         int64_t ret_ref = tag_ptr(ret_copy, true);
1266         return ret_ref;
1267 }
1268
1269 static inline struct LDKSecretKey CResult_SecretKeyErrorZ_get_ok(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
1270 CHECK(owner->result_ok);
1271         return *owner->contents.result;
1272 }
1273 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1274         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)untag_ptr(owner);
1275         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
1276         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyErrorZ_get_ok(owner_conv).bytes);
1277         return ret_arr;
1278 }
1279
1280 static inline enum LDKSecp256k1Error CResult_SecretKeyErrorZ_get_err(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
1281 CHECK(!owner->result_ok);
1282         return *owner->contents.err;
1283 }
1284 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1285         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)untag_ptr(owner);
1286         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_SecretKeyErrorZ_get_err(owner_conv));
1287         return ret_conv;
1288 }
1289
1290 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
1291 CHECK(owner->result_ok);
1292         return *owner->contents.result;
1293 }
1294 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1295         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(owner);
1296         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
1297         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form);
1298         return ret_arr;
1299 }
1300
1301 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
1302 CHECK(!owner->result_ok);
1303         return *owner->contents.err;
1304 }
1305 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1306         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(owner);
1307         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PublicKeyErrorZ_get_err(owner_conv));
1308         return ret_conv;
1309 }
1310
1311 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1312         LDKTxCreationKeys ret = *owner->contents.result;
1313         ret.is_owned = false;
1314         return ret;
1315 }
1316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1317         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(owner);
1318         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_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_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *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_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1330         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(owner);
1331         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1332         *ret_copy = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
1333         int64_t ret_ref = tag_ptr(ret_copy, true);
1334         return ret_ref;
1335 }
1336
1337 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1338         LDKChannelPublicKeys ret = *owner->contents.result;
1339         ret.is_owned = false;
1340         return ret;
1341 }
1342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1343         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(owner);
1344         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_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_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *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_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1356         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(owner);
1357         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1358         *ret_copy = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
1359         int64_t ret_ref = tag_ptr(ret_copy, true);
1360         return ret_ref;
1361 }
1362
1363 static inline struct LDKTxCreationKeys CResult_TxCreationKeysErrorZ_get_ok(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
1364         LDKTxCreationKeys ret = *owner->contents.result;
1365         ret.is_owned = false;
1366         return ret;
1367 }
1368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1369         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)untag_ptr(owner);
1370         LDKTxCreationKeys ret_var = CResult_TxCreationKeysErrorZ_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, ret_var.is_owned);
1374         return ret_ref;
1375 }
1376
1377 static inline enum LDKSecp256k1Error CResult_TxCreationKeysErrorZ_get_err(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
1378 CHECK(!owner->result_ok);
1379         return *owner->contents.err;
1380 }
1381 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1382         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)untag_ptr(owner);
1383         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_TxCreationKeysErrorZ_get_err(owner_conv));
1384         return ret_conv;
1385 }
1386
1387 static jclass LDKCOption_u32Z_Some_class = NULL;
1388 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
1389 static jclass LDKCOption_u32Z_None_class = NULL;
1390 static jmethodID LDKCOption_u32Z_None_meth = NULL;
1391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
1392         LDKCOption_u32Z_Some_class =
1393                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$Some"));
1394         CHECK(LDKCOption_u32Z_Some_class != NULL);
1395         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
1396         CHECK(LDKCOption_u32Z_Some_meth != NULL);
1397         LDKCOption_u32Z_None_class =
1398                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$None"));
1399         CHECK(LDKCOption_u32Z_None_class != NULL);
1400         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
1401         CHECK(LDKCOption_u32Z_None_meth != NULL);
1402 }
1403 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1404         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)untag_ptr(ptr);
1405         switch(obj->tag) {
1406                 case LDKCOption_u32Z_Some: {
1407                         int32_t some_conv = obj->some;
1408                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, some_conv);
1409                 }
1410                 case LDKCOption_u32Z_None: {
1411                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
1412                 }
1413                 default: abort();
1414         }
1415 }
1416 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1417         LDKHTLCOutputInCommitment ret = *owner->contents.result;
1418         ret.is_owned = false;
1419         return ret;
1420 }
1421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1422         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(owner);
1423         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
1424         int64_t ret_ref = 0;
1425         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1426         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1427         return ret_ref;
1428 }
1429
1430 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1431 CHECK(!owner->result_ok);
1432         return DecodeError_clone(&*owner->contents.err);
1433 }
1434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1435         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(owner);
1436         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1437         *ret_copy = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
1438         int64_t ret_ref = tag_ptr(ret_copy, true);
1439         return ret_ref;
1440 }
1441
1442 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1443         LDKCounterpartyChannelTransactionParameters ret = *owner->contents.result;
1444         ret.is_owned = false;
1445         return ret;
1446 }
1447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1448         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1449         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1450         int64_t ret_ref = 0;
1451         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1452         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1453         return ret_ref;
1454 }
1455
1456 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1457 CHECK(!owner->result_ok);
1458         return DecodeError_clone(&*owner->contents.err);
1459 }
1460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1461         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1462         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1463         *ret_copy = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1464         int64_t ret_ref = tag_ptr(ret_copy, true);
1465         return ret_ref;
1466 }
1467
1468 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1469         LDKChannelTransactionParameters ret = *owner->contents.result;
1470         ret.is_owned = false;
1471         return ret;
1472 }
1473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1474         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1475         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1476         int64_t ret_ref = 0;
1477         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1478         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1479         return ret_ref;
1480 }
1481
1482 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1483 CHECK(!owner->result_ok);
1484         return DecodeError_clone(&*owner->contents.err);
1485 }
1486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1487         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1488         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1489         *ret_copy = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1490         int64_t ret_ref = tag_ptr(ret_copy, true);
1491         return ret_ref;
1492 }
1493
1494 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1495         LDKHolderCommitmentTransaction ret = *owner->contents.result;
1496         ret.is_owned = false;
1497         return ret;
1498 }
1499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1500         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1501         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1502         int64_t ret_ref = 0;
1503         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1504         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1505         return ret_ref;
1506 }
1507
1508 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1509 CHECK(!owner->result_ok);
1510         return DecodeError_clone(&*owner->contents.err);
1511 }
1512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1513         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1514         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1515         *ret_copy = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1516         int64_t ret_ref = tag_ptr(ret_copy, true);
1517         return ret_ref;
1518 }
1519
1520 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1521         LDKBuiltCommitmentTransaction ret = *owner->contents.result;
1522         ret.is_owned = false;
1523         return ret;
1524 }
1525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1526         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1527         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1528         int64_t ret_ref = 0;
1529         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1530         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1531         return ret_ref;
1532 }
1533
1534 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1535 CHECK(!owner->result_ok);
1536         return DecodeError_clone(&*owner->contents.err);
1537 }
1538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1539         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1540         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1541         *ret_copy = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1542         int64_t ret_ref = tag_ptr(ret_copy, true);
1543         return ret_ref;
1544 }
1545
1546 static inline struct LDKTrustedClosingTransaction CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1547         LDKTrustedClosingTransaction ret = *owner->contents.result;
1548         ret.is_owned = false;
1549         return ret;
1550 }
1551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1552         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(owner);
1553         LDKTrustedClosingTransaction ret_var = CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
1554         int64_t ret_ref = 0;
1555         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1556         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1557         return ret_ref;
1558 }
1559
1560 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1561 CHECK(!owner->result_ok);
1562         return *owner->contents.err;
1563 }
1564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1565         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(owner);
1566         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
1567 }
1568
1569 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1570         LDKCommitmentTransaction ret = *owner->contents.result;
1571         ret.is_owned = false;
1572         return ret;
1573 }
1574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1575         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1576         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1577         int64_t ret_ref = 0;
1578         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1579         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1580         return ret_ref;
1581 }
1582
1583 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1584 CHECK(!owner->result_ok);
1585         return DecodeError_clone(&*owner->contents.err);
1586 }
1587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1588         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1589         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1590         *ret_copy = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1591         int64_t ret_ref = tag_ptr(ret_copy, true);
1592         return ret_ref;
1593 }
1594
1595 static inline struct LDKTrustedCommitmentTransaction CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1596         LDKTrustedCommitmentTransaction ret = *owner->contents.result;
1597         ret.is_owned = false;
1598         return ret;
1599 }
1600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1601         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(owner);
1602         LDKTrustedCommitmentTransaction ret_var = CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
1603         int64_t ret_ref = 0;
1604         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1605         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1606         return ret_ref;
1607 }
1608
1609 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1610 CHECK(!owner->result_ok);
1611         return *owner->contents.err;
1612 }
1613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1614         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(owner);
1615         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
1616 }
1617
1618 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1619 CHECK(owner->result_ok);
1620         return *owner->contents.result;
1621 }
1622 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1623         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(owner);
1624         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
1625         jobjectArray ret_arr = NULL;
1626         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
1627         ;
1628         for (size_t i = 0; i < ret_var.datalen; i++) {
1629                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
1630                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
1631                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
1632         }
1633         
1634         return ret_arr;
1635 }
1636
1637 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1638 CHECK(!owner->result_ok);
1639         return *owner->contents.err;
1640 }
1641 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1642         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(owner);
1643         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
1644 }
1645
1646 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1647         LDKShutdownScript ret = *owner->contents.result;
1648         ret.is_owned = false;
1649         return ret;
1650 }
1651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1652         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(owner);
1653         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
1654         int64_t ret_ref = 0;
1655         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1656         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1657         return ret_ref;
1658 }
1659
1660 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1661 CHECK(!owner->result_ok);
1662         return DecodeError_clone(&*owner->contents.err);
1663 }
1664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1665         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(owner);
1666         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1667         *ret_copy = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
1668         int64_t ret_ref = tag_ptr(ret_copy, true);
1669         return ret_ref;
1670 }
1671
1672 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1673         LDKShutdownScript ret = *owner->contents.result;
1674         ret.is_owned = false;
1675         return ret;
1676 }
1677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1678         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(owner);
1679         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
1680         int64_t ret_ref = 0;
1681         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1682         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1683         return ret_ref;
1684 }
1685
1686 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1687         LDKInvalidShutdownScript ret = *owner->contents.err;
1688         ret.is_owned = false;
1689         return ret;
1690 }
1691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1692         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(owner);
1693         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
1694         int64_t ret_ref = 0;
1695         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1696         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1697         return ret_ref;
1698 }
1699
1700 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1701         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1702         for (size_t i = 0; i < ret.datalen; i++) {
1703                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1704         }
1705         return ret;
1706 }
1707 typedef struct LDKScore_JCalls {
1708         atomic_size_t refcnt;
1709         JavaVM *vm;
1710         jweak o;
1711         jmethodID channel_penalty_msat_meth;
1712         jmethodID payment_path_failed_meth;
1713         jmethodID payment_path_successful_meth;
1714         jmethodID probe_failed_meth;
1715         jmethodID probe_successful_meth;
1716         jmethodID write_meth;
1717 } LDKScore_JCalls;
1718 static void LDKScore_JCalls_free(void* this_arg) {
1719         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1720         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1721                 JNIEnv *env;
1722                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1723                 if (get_jenv_res == JNI_EDETACHED) {
1724                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1725                 } else {
1726                         DO_ASSERT(get_jenv_res == JNI_OK);
1727                 }
1728                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1729                 if (get_jenv_res == JNI_EDETACHED) {
1730                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1731                 }
1732                 FREE(j_calls);
1733         }
1734 }
1735 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target, LDKChannelUsage usage) {
1736         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1737         JNIEnv *env;
1738         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1739         if (get_jenv_res == JNI_EDETACHED) {
1740                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1741         } else {
1742                 DO_ASSERT(get_jenv_res == JNI_OK);
1743         }
1744         int64_t short_channel_id_conv = short_channel_id;
1745         LDKNodeId source_var = *source;
1746         int64_t source_ref = 0;
1747         source_var = NodeId_clone(&source_var);
1748         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
1749         source_ref = tag_ptr(source_var.inner, source_var.is_owned);
1750         LDKNodeId target_var = *target;
1751         int64_t target_ref = 0;
1752         target_var = NodeId_clone(&target_var);
1753         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
1754         target_ref = tag_ptr(target_var.inner, target_var.is_owned);
1755         LDKChannelUsage usage_var = usage;
1756         int64_t usage_ref = 0;
1757         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_var);
1758         usage_ref = tag_ptr(usage_var.inner, usage_var.is_owned);
1759         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1760         CHECK(obj != NULL);
1761         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id_conv, source_ref, target_ref, usage_ref);
1762         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1763                 (*env)->ExceptionDescribe(env);
1764                 (*env)->FatalError(env, "A call to channel_penalty_msat in LDKScore from rust threw an exception.");
1765         }
1766         if (get_jenv_res == JNI_EDETACHED) {
1767                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1768         }
1769         return ret;
1770 }
1771 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
1772         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1773         JNIEnv *env;
1774         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1775         if (get_jenv_res == JNI_EDETACHED) {
1776                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1777         } else {
1778                 DO_ASSERT(get_jenv_res == JNI_OK);
1779         }
1780         LDKCVec_RouteHopZ path_var = path;
1781         int64_tArray path_arr = NULL;
1782         path_arr = (*env)->NewLongArray(env, path_var.datalen);
1783         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
1784         for (size_t k = 0; k < path_var.datalen; k++) {
1785                 LDKRouteHop path_conv_10_var = path_var.data[k];
1786                 int64_t path_conv_10_ref = 0;
1787                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1788                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
1789                 path_arr_ptr[k] = path_conv_10_ref;
1790         }
1791         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
1792         FREE(path_var.data);
1793         int64_t short_channel_id_conv = short_channel_id;
1794         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1795         CHECK(obj != NULL);
1796         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_failed_meth, path_arr, short_channel_id_conv);
1797         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1798                 (*env)->ExceptionDescribe(env);
1799                 (*env)->FatalError(env, "A call to payment_path_failed in LDKScore from rust threw an exception.");
1800         }
1801         if (get_jenv_res == JNI_EDETACHED) {
1802                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1803         }
1804 }
1805 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
1806         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1807         JNIEnv *env;
1808         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1809         if (get_jenv_res == JNI_EDETACHED) {
1810                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1811         } else {
1812                 DO_ASSERT(get_jenv_res == JNI_OK);
1813         }
1814         LDKCVec_RouteHopZ path_var = path;
1815         int64_tArray path_arr = NULL;
1816         path_arr = (*env)->NewLongArray(env, path_var.datalen);
1817         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
1818         for (size_t k = 0; k < path_var.datalen; k++) {
1819                 LDKRouteHop path_conv_10_var = path_var.data[k];
1820                 int64_t path_conv_10_ref = 0;
1821                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1822                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
1823                 path_arr_ptr[k] = path_conv_10_ref;
1824         }
1825         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
1826         FREE(path_var.data);
1827         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1828         CHECK(obj != NULL);
1829         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_successful_meth, path_arr);
1830         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1831                 (*env)->ExceptionDescribe(env);
1832                 (*env)->FatalError(env, "A call to payment_path_successful in LDKScore from rust threw an exception.");
1833         }
1834         if (get_jenv_res == JNI_EDETACHED) {
1835                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1836         }
1837 }
1838 void probe_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
1839         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1840         JNIEnv *env;
1841         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1842         if (get_jenv_res == JNI_EDETACHED) {
1843                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1844         } else {
1845                 DO_ASSERT(get_jenv_res == JNI_OK);
1846         }
1847         LDKCVec_RouteHopZ path_var = path;
1848         int64_tArray path_arr = NULL;
1849         path_arr = (*env)->NewLongArray(env, path_var.datalen);
1850         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
1851         for (size_t k = 0; k < path_var.datalen; k++) {
1852                 LDKRouteHop path_conv_10_var = path_var.data[k];
1853                 int64_t path_conv_10_ref = 0;
1854                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1855                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
1856                 path_arr_ptr[k] = path_conv_10_ref;
1857         }
1858         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
1859         FREE(path_var.data);
1860         int64_t short_channel_id_conv = short_channel_id;
1861         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1862         CHECK(obj != NULL);
1863         (*env)->CallVoidMethod(env, obj, j_calls->probe_failed_meth, path_arr, short_channel_id_conv);
1864         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1865                 (*env)->ExceptionDescribe(env);
1866                 (*env)->FatalError(env, "A call to probe_failed in LDKScore from rust threw an exception.");
1867         }
1868         if (get_jenv_res == JNI_EDETACHED) {
1869                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1870         }
1871 }
1872 void probe_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
1873         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1874         JNIEnv *env;
1875         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1876         if (get_jenv_res == JNI_EDETACHED) {
1877                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1878         } else {
1879                 DO_ASSERT(get_jenv_res == JNI_OK);
1880         }
1881         LDKCVec_RouteHopZ path_var = path;
1882         int64_tArray path_arr = NULL;
1883         path_arr = (*env)->NewLongArray(env, path_var.datalen);
1884         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
1885         for (size_t k = 0; k < path_var.datalen; k++) {
1886                 LDKRouteHop path_conv_10_var = path_var.data[k];
1887                 int64_t path_conv_10_ref = 0;
1888                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1889                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
1890                 path_arr_ptr[k] = path_conv_10_ref;
1891         }
1892         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
1893         FREE(path_var.data);
1894         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1895         CHECK(obj != NULL);
1896         (*env)->CallVoidMethod(env, obj, j_calls->probe_successful_meth, path_arr);
1897         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1898                 (*env)->ExceptionDescribe(env);
1899                 (*env)->FatalError(env, "A call to probe_successful in LDKScore from rust threw an exception.");
1900         }
1901         if (get_jenv_res == JNI_EDETACHED) {
1902                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1903         }
1904 }
1905 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
1906         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1907         JNIEnv *env;
1908         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1909         if (get_jenv_res == JNI_EDETACHED) {
1910                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1911         } else {
1912                 DO_ASSERT(get_jenv_res == JNI_OK);
1913         }
1914         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1915         CHECK(obj != NULL);
1916         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
1917         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1918                 (*env)->ExceptionDescribe(env);
1919                 (*env)->FatalError(env, "A call to write in LDKScore from rust threw an exception.");
1920         }
1921         LDKCVec_u8Z ret_ref;
1922         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
1923         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
1924         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
1925         if (get_jenv_res == JNI_EDETACHED) {
1926                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1927         }
1928         return ret_ref;
1929 }
1930 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
1931         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
1932         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1933 }
1934 static inline LDKScore LDKScore_init (JNIEnv *env, jclass clz, jobject o) {
1935         jclass c = (*env)->GetObjectClass(env, o);
1936         CHECK(c != NULL);
1937         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
1938         atomic_init(&calls->refcnt, 1);
1939         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1940         calls->o = (*env)->NewWeakGlobalRef(env, o);
1941         calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(JJJJ)J");
1942         CHECK(calls->channel_penalty_msat_meth != NULL);
1943         calls->payment_path_failed_meth = (*env)->GetMethodID(env, c, "payment_path_failed", "([JJ)V");
1944         CHECK(calls->payment_path_failed_meth != NULL);
1945         calls->payment_path_successful_meth = (*env)->GetMethodID(env, c, "payment_path_successful", "([J)V");
1946         CHECK(calls->payment_path_successful_meth != NULL);
1947         calls->probe_failed_meth = (*env)->GetMethodID(env, c, "probe_failed", "([JJ)V");
1948         CHECK(calls->probe_failed_meth != NULL);
1949         calls->probe_successful_meth = (*env)->GetMethodID(env, c, "probe_successful", "([J)V");
1950         CHECK(calls->probe_successful_meth != NULL);
1951         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
1952         CHECK(calls->write_meth != NULL);
1953
1954         LDKScore ret = {
1955                 .this_arg = (void*) calls,
1956                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
1957                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
1958                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
1959                 .probe_failed = probe_failed_LDKScore_jcall,
1960                 .probe_successful = probe_successful_LDKScore_jcall,
1961                 .write = write_LDKScore_jcall,
1962                 .free = LDKScore_JCalls_free,
1963         };
1964         return ret;
1965 }
1966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKScore_1new(JNIEnv *env, jclass clz, jobject o) {
1967         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
1968         *res_ptr = LDKScore_init(env, clz, o);
1969         return tag_ptr(res_ptr, true);
1970 }
1971 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) {
1972         void* this_arg_ptr = untag_ptr(this_arg);
1973         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
1974         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
1975         LDKNodeId source_conv;
1976         source_conv.inner = untag_ptr(source);
1977         source_conv.is_owned = ptr_is_owned(source);
1978         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
1979         source_conv.is_owned = false;
1980         LDKNodeId target_conv;
1981         target_conv.inner = untag_ptr(target);
1982         target_conv.is_owned = ptr_is_owned(target);
1983         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
1984         target_conv.is_owned = false;
1985         LDKChannelUsage usage_conv;
1986         usage_conv.inner = untag_ptr(usage);
1987         usage_conv.is_owned = ptr_is_owned(usage);
1988         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_conv);
1989         usage_conv = ChannelUsage_clone(&usage_conv);
1990         int64_t ret_conv = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv, usage_conv);
1991         return ret_conv;
1992 }
1993
1994 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) {
1995         void* this_arg_ptr = untag_ptr(this_arg);
1996         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
1997         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
1998         LDKCVec_RouteHopZ path_constr;
1999         path_constr.datalen = (*env)->GetArrayLength(env, path);
2000         if (path_constr.datalen > 0)
2001                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
2002         else
2003                 path_constr.data = NULL;
2004         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
2005         for (size_t k = 0; k < path_constr.datalen; k++) {
2006                 int64_t path_conv_10 = path_vals[k];
2007                 LDKRouteHop path_conv_10_conv;
2008                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
2009                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
2010                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
2011                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
2012                 path_constr.data[k] = path_conv_10_conv;
2013         }
2014         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
2015         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
2016 }
2017
2018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
2019         void* this_arg_ptr = untag_ptr(this_arg);
2020         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2021         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2022         LDKCVec_RouteHopZ path_constr;
2023         path_constr.datalen = (*env)->GetArrayLength(env, path);
2024         if (path_constr.datalen > 0)
2025                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
2026         else
2027                 path_constr.data = NULL;
2028         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
2029         for (size_t k = 0; k < path_constr.datalen; k++) {
2030                 int64_t path_conv_10 = path_vals[k];
2031                 LDKRouteHop path_conv_10_conv;
2032                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
2033                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
2034                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
2035                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
2036                 path_constr.data[k] = path_conv_10_conv;
2037         }
2038         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
2039         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
2040 }
2041
2042 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) {
2043         void* this_arg_ptr = untag_ptr(this_arg);
2044         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2045         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2046         LDKCVec_RouteHopZ path_constr;
2047         path_constr.datalen = (*env)->GetArrayLength(env, path);
2048         if (path_constr.datalen > 0)
2049                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
2050         else
2051                 path_constr.data = NULL;
2052         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
2053         for (size_t k = 0; k < path_constr.datalen; k++) {
2054                 int64_t path_conv_10 = path_vals[k];
2055                 LDKRouteHop path_conv_10_conv;
2056                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
2057                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
2058                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
2059                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
2060                 path_constr.data[k] = path_conv_10_conv;
2061         }
2062         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
2063         (this_arg_conv->probe_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
2064 }
2065
2066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1probe_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
2067         void* this_arg_ptr = untag_ptr(this_arg);
2068         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2069         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2070         LDKCVec_RouteHopZ path_constr;
2071         path_constr.datalen = (*env)->GetArrayLength(env, path);
2072         if (path_constr.datalen > 0)
2073                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
2074         else
2075                 path_constr.data = NULL;
2076         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
2077         for (size_t k = 0; k < path_constr.datalen; k++) {
2078                 int64_t path_conv_10 = path_vals[k];
2079                 LDKRouteHop path_conv_10_conv;
2080                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
2081                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
2082                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
2083                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
2084                 path_constr.data[k] = path_conv_10_conv;
2085         }
2086         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
2087         (this_arg_conv->probe_successful)(this_arg_conv->this_arg, path_constr);
2088 }
2089
2090 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Score_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2091         void* this_arg_ptr = untag_ptr(this_arg);
2092         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2093         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2094         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2095         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2096         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2097         CVec_u8Z_free(ret_var);
2098         return ret_arr;
2099 }
2100
2101 typedef struct LDKLockableScore_JCalls {
2102         atomic_size_t refcnt;
2103         JavaVM *vm;
2104         jweak o;
2105         jmethodID lock_meth;
2106 } LDKLockableScore_JCalls;
2107 static void LDKLockableScore_JCalls_free(void* this_arg) {
2108         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
2109         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2110                 JNIEnv *env;
2111                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2112                 if (get_jenv_res == JNI_EDETACHED) {
2113                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2114                 } else {
2115                         DO_ASSERT(get_jenv_res == JNI_OK);
2116                 }
2117                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2118                 if (get_jenv_res == JNI_EDETACHED) {
2119                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2120                 }
2121                 FREE(j_calls);
2122         }
2123 }
2124 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
2125         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
2126         JNIEnv *env;
2127         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2128         if (get_jenv_res == JNI_EDETACHED) {
2129                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2130         } else {
2131                 DO_ASSERT(get_jenv_res == JNI_OK);
2132         }
2133         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2134         CHECK(obj != NULL);
2135         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->lock_meth);
2136         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2137                 (*env)->ExceptionDescribe(env);
2138                 (*env)->FatalError(env, "A call to lock in LDKLockableScore from rust threw an exception.");
2139         }
2140         void* ret_ptr = untag_ptr(ret);
2141         CHECK_ACCESS(ret_ptr);
2142         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
2143         if (ret_conv.free == LDKScore_JCalls_free) {
2144                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
2145                 LDKScore_JCalls_cloned(&ret_conv);
2146         }// WARNING: we may need a move here but no clone is available for LDKScore
2147         
2148         if (get_jenv_res == JNI_EDETACHED) {
2149                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2150         }
2151         return ret_conv;
2152 }
2153 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
2154         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
2155         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2156 }
2157 static inline LDKLockableScore LDKLockableScore_init (JNIEnv *env, jclass clz, jobject o) {
2158         jclass c = (*env)->GetObjectClass(env, o);
2159         CHECK(c != NULL);
2160         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
2161         atomic_init(&calls->refcnt, 1);
2162         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2163         calls->o = (*env)->NewWeakGlobalRef(env, o);
2164         calls->lock_meth = (*env)->GetMethodID(env, c, "lock", "()J");
2165         CHECK(calls->lock_meth != NULL);
2166
2167         LDKLockableScore ret = {
2168                 .this_arg = (void*) calls,
2169                 .lock = lock_LDKLockableScore_jcall,
2170                 .free = LDKLockableScore_JCalls_free,
2171         };
2172         return ret;
2173 }
2174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLockableScore_1new(JNIEnv *env, jclass clz, jobject o) {
2175         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
2176         *res_ptr = LDKLockableScore_init(env, clz, o);
2177         return tag_ptr(res_ptr, true);
2178 }
2179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockableScore_1lock(JNIEnv *env, jclass clz, int64_t this_arg) {
2180         void* this_arg_ptr = untag_ptr(this_arg);
2181         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2182         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
2183         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
2184         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
2185         return tag_ptr(ret_ret, true);
2186 }
2187
2188 typedef struct LDKWriteableScore_JCalls {
2189         atomic_size_t refcnt;
2190         JavaVM *vm;
2191         jweak o;
2192         LDKLockableScore_JCalls* LockableScore;
2193         jmethodID write_meth;
2194 } LDKWriteableScore_JCalls;
2195 static void LDKWriteableScore_JCalls_free(void* this_arg) {
2196         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) this_arg;
2197         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2198                 JNIEnv *env;
2199                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2200                 if (get_jenv_res == JNI_EDETACHED) {
2201                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2202                 } else {
2203                         DO_ASSERT(get_jenv_res == JNI_OK);
2204                 }
2205                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2206                 if (get_jenv_res == JNI_EDETACHED) {
2207                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2208                 }
2209                 FREE(j_calls);
2210         }
2211 }
2212 LDKCVec_u8Z write_LDKWriteableScore_jcall(const void* this_arg) {
2213         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) this_arg;
2214         JNIEnv *env;
2215         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2216         if (get_jenv_res == JNI_EDETACHED) {
2217                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2218         } else {
2219                 DO_ASSERT(get_jenv_res == JNI_OK);
2220         }
2221         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2222         CHECK(obj != NULL);
2223         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
2224         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2225                 (*env)->ExceptionDescribe(env);
2226                 (*env)->FatalError(env, "A call to write in LDKWriteableScore from rust threw an exception.");
2227         }
2228         LDKCVec_u8Z ret_ref;
2229         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
2230         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2231         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
2232         if (get_jenv_res == JNI_EDETACHED) {
2233                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2234         }
2235         return ret_ref;
2236 }
2237 static void LDKWriteableScore_JCalls_cloned(LDKWriteableScore* new_obj) {
2238         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) new_obj->this_arg;
2239         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2240         atomic_fetch_add_explicit(&j_calls->LockableScore->refcnt, 1, memory_order_release);
2241 }
2242 static inline LDKWriteableScore LDKWriteableScore_init (JNIEnv *env, jclass clz, jobject o, jobject LockableScore) {
2243         jclass c = (*env)->GetObjectClass(env, o);
2244         CHECK(c != NULL);
2245         LDKWriteableScore_JCalls *calls = MALLOC(sizeof(LDKWriteableScore_JCalls), "LDKWriteableScore_JCalls");
2246         atomic_init(&calls->refcnt, 1);
2247         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2248         calls->o = (*env)->NewWeakGlobalRef(env, o);
2249         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
2250         CHECK(calls->write_meth != NULL);
2251
2252         LDKWriteableScore ret = {
2253                 .this_arg = (void*) calls,
2254                 .write = write_LDKWriteableScore_jcall,
2255                 .free = LDKWriteableScore_JCalls_free,
2256                 .LockableScore = LDKLockableScore_init(env, clz, LockableScore),
2257         };
2258         calls->LockableScore = ret.LockableScore.this_arg;
2259         return ret;
2260 }
2261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWriteableScore_1new(JNIEnv *env, jclass clz, jobject o, jobject LockableScore) {
2262         LDKWriteableScore *res_ptr = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
2263         *res_ptr = LDKWriteableScore_init(env, clz, o, LockableScore);
2264         return tag_ptr(res_ptr, true);
2265 }
2266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWriteableScore_1get_1LockableScore(JNIEnv *env, jclass clz, int64_t arg) {
2267         LDKWriteableScore *inp = (LDKWriteableScore *)untag_ptr(arg);
2268         return tag_ptr(&inp->LockableScore, false);
2269 }
2270 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WriteableScore_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2271         void* this_arg_ptr = untag_ptr(this_arg);
2272         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2273         LDKWriteableScore* this_arg_conv = (LDKWriteableScore*)this_arg_ptr;
2274         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2275         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2276         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2277         CVec_u8Z_free(ret_var);
2278         return ret_arr;
2279 }
2280
2281 static jclass LDKCOption_WriteableScoreZ_Some_class = NULL;
2282 static jmethodID LDKCOption_WriteableScoreZ_Some_meth = NULL;
2283 static jclass LDKCOption_WriteableScoreZ_None_class = NULL;
2284 static jmethodID LDKCOption_WriteableScoreZ_None_meth = NULL;
2285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1WriteableScoreZ_init (JNIEnv *env, jclass clz) {
2286         LDKCOption_WriteableScoreZ_Some_class =
2287                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_WriteableScoreZ$Some"));
2288         CHECK(LDKCOption_WriteableScoreZ_Some_class != NULL);
2289         LDKCOption_WriteableScoreZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_WriteableScoreZ_Some_class, "<init>", "(J)V");
2290         CHECK(LDKCOption_WriteableScoreZ_Some_meth != NULL);
2291         LDKCOption_WriteableScoreZ_None_class =
2292                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_WriteableScoreZ$None"));
2293         CHECK(LDKCOption_WriteableScoreZ_None_class != NULL);
2294         LDKCOption_WriteableScoreZ_None_meth = (*env)->GetMethodID(env, LDKCOption_WriteableScoreZ_None_class, "<init>", "()V");
2295         CHECK(LDKCOption_WriteableScoreZ_None_meth != NULL);
2296 }
2297 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1WriteableScoreZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2298         LDKCOption_WriteableScoreZ *obj = (LDKCOption_WriteableScoreZ*)untag_ptr(ptr);
2299         switch(obj->tag) {
2300                 case LDKCOption_WriteableScoreZ_Some: {
2301                         LDKWriteableScore* some_ret = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
2302                         *some_ret = obj->some;
2303                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
2304                         if ((*some_ret).free == LDKWriteableScore_JCalls_free) {
2305                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
2306                                 LDKWriteableScore_JCalls_cloned(&(*some_ret));
2307                         }
2308                         return (*env)->NewObject(env, LDKCOption_WriteableScoreZ_Some_class, LDKCOption_WriteableScoreZ_Some_meth, tag_ptr(some_ret, true));
2309                 }
2310                 case LDKCOption_WriteableScoreZ_None: {
2311                         return (*env)->NewObject(env, LDKCOption_WriteableScoreZ_None_class, LDKCOption_WriteableScoreZ_None_meth);
2312                 }
2313                 default: abort();
2314         }
2315 }
2316 static inline void CResult_NoneErrorZ_get_ok(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
2317 CHECK(owner->result_ok);
2318         return *owner->contents.result;
2319 }
2320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2321         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)untag_ptr(owner);
2322         CResult_NoneErrorZ_get_ok(owner_conv);
2323 }
2324
2325 static inline enum LDKIOError CResult_NoneErrorZ_get_err(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
2326 CHECK(!owner->result_ok);
2327         return *owner->contents.err;
2328 }
2329 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2330         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)untag_ptr(owner);
2331         jclass ret_conv = LDKIOError_to_java(env, CResult_NoneErrorZ_get_err(owner_conv));
2332         return ret_conv;
2333 }
2334
2335 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
2336         LDKRouteHop ret = *owner->contents.result;
2337         ret.is_owned = false;
2338         return ret;
2339 }
2340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2341         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(owner);
2342         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
2343         int64_t ret_ref = 0;
2344         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2345         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2346         return ret_ref;
2347 }
2348
2349 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
2350 CHECK(!owner->result_ok);
2351         return DecodeError_clone(&*owner->contents.err);
2352 }
2353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2354         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(owner);
2355         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2356         *ret_copy = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
2357         int64_t ret_ref = tag_ptr(ret_copy, true);
2358         return ret_ref;
2359 }
2360
2361 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
2362         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
2363         for (size_t i = 0; i < ret.datalen; i++) {
2364                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
2365         }
2366         return ret;
2367 }
2368 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
2369         LDKRoute ret = *owner->contents.result;
2370         ret.is_owned = false;
2371         return ret;
2372 }
2373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2374         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(owner);
2375         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
2376         int64_t ret_ref = 0;
2377         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2378         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2379         return ret_ref;
2380 }
2381
2382 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
2383 CHECK(!owner->result_ok);
2384         return DecodeError_clone(&*owner->contents.err);
2385 }
2386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2387         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(owner);
2388         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2389         *ret_copy = CResult_RouteDecodeErrorZ_get_err(owner_conv);
2390         int64_t ret_ref = tag_ptr(ret_copy, true);
2391         return ret_ref;
2392 }
2393
2394 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
2395         LDKRouteParameters ret = *owner->contents.result;
2396         ret.is_owned = false;
2397         return ret;
2398 }
2399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2400         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(owner);
2401         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
2402         int64_t ret_ref = 0;
2403         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2404         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2405         return ret_ref;
2406 }
2407
2408 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
2409 CHECK(!owner->result_ok);
2410         return DecodeError_clone(&*owner->contents.err);
2411 }
2412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2413         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(owner);
2414         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2415         *ret_copy = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
2416         int64_t ret_ref = tag_ptr(ret_copy, true);
2417         return ret_ref;
2418 }
2419
2420 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
2421         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
2422         for (size_t i = 0; i < ret.datalen; i++) {
2423                 ret.data[i] = RouteHint_clone(&orig->data[i]);
2424         }
2425         return ret;
2426 }
2427 static jclass LDKCOption_u64Z_Some_class = NULL;
2428 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
2429 static jclass LDKCOption_u64Z_None_class = NULL;
2430 static jmethodID LDKCOption_u64Z_None_meth = NULL;
2431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
2432         LDKCOption_u64Z_Some_class =
2433                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$Some"));
2434         CHECK(LDKCOption_u64Z_Some_class != NULL);
2435         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
2436         CHECK(LDKCOption_u64Z_Some_meth != NULL);
2437         LDKCOption_u64Z_None_class =
2438                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$None"));
2439         CHECK(LDKCOption_u64Z_None_class != NULL);
2440         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
2441         CHECK(LDKCOption_u64Z_None_meth != NULL);
2442 }
2443 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2444         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)untag_ptr(ptr);
2445         switch(obj->tag) {
2446                 case LDKCOption_u64Z_Some: {
2447                         int64_t some_conv = obj->some;
2448                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, some_conv);
2449                 }
2450                 case LDKCOption_u64Z_None: {
2451                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
2452                 }
2453                 default: abort();
2454         }
2455 }
2456 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
2457         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
2458         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
2459         return ret;
2460 }
2461 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
2462         LDKPaymentParameters ret = *owner->contents.result;
2463         ret.is_owned = false;
2464         return ret;
2465 }
2466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2467         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(owner);
2468         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
2469         int64_t ret_ref = 0;
2470         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2471         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2472         return ret_ref;
2473 }
2474
2475 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
2476 CHECK(!owner->result_ok);
2477         return DecodeError_clone(&*owner->contents.err);
2478 }
2479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2480         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(owner);
2481         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2482         *ret_copy = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
2483         int64_t ret_ref = tag_ptr(ret_copy, true);
2484         return ret_ref;
2485 }
2486
2487 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
2488         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
2489         for (size_t i = 0; i < ret.datalen; i++) {
2490                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
2491         }
2492         return ret;
2493 }
2494 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
2495         LDKRouteHint ret = *owner->contents.result;
2496         ret.is_owned = false;
2497         return ret;
2498 }
2499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2500         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(owner);
2501         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
2502         int64_t ret_ref = 0;
2503         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2504         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2505         return ret_ref;
2506 }
2507
2508 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
2509 CHECK(!owner->result_ok);
2510         return DecodeError_clone(&*owner->contents.err);
2511 }
2512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2513         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(owner);
2514         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2515         *ret_copy = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
2516         int64_t ret_ref = tag_ptr(ret_copy, true);
2517         return ret_ref;
2518 }
2519
2520 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
2521         LDKRouteHintHop ret = *owner->contents.result;
2522         ret.is_owned = false;
2523         return ret;
2524 }
2525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2526         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(owner);
2527         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
2528         int64_t ret_ref = 0;
2529         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2530         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2531         return ret_ref;
2532 }
2533
2534 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
2535 CHECK(!owner->result_ok);
2536         return DecodeError_clone(&*owner->contents.err);
2537 }
2538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2539         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(owner);
2540         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2541         *ret_copy = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
2542         int64_t ret_ref = tag_ptr(ret_copy, true);
2543         return ret_ref;
2544 }
2545
2546 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
2547         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
2548         for (size_t i = 0; i < ret.datalen; i++) {
2549                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
2550         }
2551         return ret;
2552 }
2553 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
2554         LDKRoute ret = *owner->contents.result;
2555         ret.is_owned = false;
2556         return ret;
2557 }
2558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2559         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(owner);
2560         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
2561         int64_t ret_ref = 0;
2562         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2563         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2564         return ret_ref;
2565 }
2566
2567 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
2568         LDKLightningError ret = *owner->contents.err;
2569         ret.is_owned = false;
2570         return ret;
2571 }
2572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2573         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(owner);
2574         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
2575         int64_t ret_ref = 0;
2576         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2577         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2578         return ret_ref;
2579 }
2580
2581 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
2582 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
2583 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
2584 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
2585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
2586         LDKPaymentPurpose_InvoicePayment_class =
2587                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment"));
2588         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
2589         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[B)V");
2590         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
2591         LDKPaymentPurpose_SpontaneousPayment_class =
2592                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment"));
2593         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
2594         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
2595         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
2596 }
2597 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2598         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)untag_ptr(ptr);
2599         switch(obj->tag) {
2600                 case LDKPaymentPurpose_InvoicePayment: {
2601                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
2602                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
2603                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
2604                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
2605                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr);
2606                 }
2607                 case LDKPaymentPurpose_SpontaneousPayment: {
2608                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
2609                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
2610                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
2611                 }
2612                 default: abort();
2613         }
2614 }
2615 static inline struct LDKPaymentPurpose CResult_PaymentPurposeDecodeErrorZ_get_ok(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
2616 CHECK(owner->result_ok);
2617         return PaymentPurpose_clone(&*owner->contents.result);
2618 }
2619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2620         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(owner);
2621         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
2622         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_ok(owner_conv);
2623         int64_t ret_ref = tag_ptr(ret_copy, true);
2624         return ret_ref;
2625 }
2626
2627 static inline struct LDKDecodeError CResult_PaymentPurposeDecodeErrorZ_get_err(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
2628 CHECK(!owner->result_ok);
2629         return DecodeError_clone(&*owner->contents.err);
2630 }
2631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2632         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(owner);
2633         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2634         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_err(owner_conv);
2635         int64_t ret_ref = tag_ptr(ret_copy, true);
2636         return ret_ref;
2637 }
2638
2639 static jclass LDKClosureReason_CounterpartyForceClosed_class = NULL;
2640 static jmethodID LDKClosureReason_CounterpartyForceClosed_meth = NULL;
2641 static jclass LDKClosureReason_HolderForceClosed_class = NULL;
2642 static jmethodID LDKClosureReason_HolderForceClosed_meth = NULL;
2643 static jclass LDKClosureReason_CooperativeClosure_class = NULL;
2644 static jmethodID LDKClosureReason_CooperativeClosure_meth = NULL;
2645 static jclass LDKClosureReason_CommitmentTxConfirmed_class = NULL;
2646 static jmethodID LDKClosureReason_CommitmentTxConfirmed_meth = NULL;
2647 static jclass LDKClosureReason_FundingTimedOut_class = NULL;
2648 static jmethodID LDKClosureReason_FundingTimedOut_meth = NULL;
2649 static jclass LDKClosureReason_ProcessingError_class = NULL;
2650 static jmethodID LDKClosureReason_ProcessingError_meth = NULL;
2651 static jclass LDKClosureReason_DisconnectedPeer_class = NULL;
2652 static jmethodID LDKClosureReason_DisconnectedPeer_meth = NULL;
2653 static jclass LDKClosureReason_OutdatedChannelManager_class = NULL;
2654 static jmethodID LDKClosureReason_OutdatedChannelManager_meth = NULL;
2655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init (JNIEnv *env, jclass clz) {
2656         LDKClosureReason_CounterpartyForceClosed_class =
2657                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CounterpartyForceClosed"));
2658         CHECK(LDKClosureReason_CounterpartyForceClosed_class != NULL);
2659         LDKClosureReason_CounterpartyForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_CounterpartyForceClosed_class, "<init>", "(Ljava/lang/String;)V");
2660         CHECK(LDKClosureReason_CounterpartyForceClosed_meth != NULL);
2661         LDKClosureReason_HolderForceClosed_class =
2662                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$HolderForceClosed"));
2663         CHECK(LDKClosureReason_HolderForceClosed_class != NULL);
2664         LDKClosureReason_HolderForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_HolderForceClosed_class, "<init>", "()V");
2665         CHECK(LDKClosureReason_HolderForceClosed_meth != NULL);
2666         LDKClosureReason_CooperativeClosure_class =
2667                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CooperativeClosure"));
2668         CHECK(LDKClosureReason_CooperativeClosure_class != NULL);
2669         LDKClosureReason_CooperativeClosure_meth = (*env)->GetMethodID(env, LDKClosureReason_CooperativeClosure_class, "<init>", "()V");
2670         CHECK(LDKClosureReason_CooperativeClosure_meth != NULL);
2671         LDKClosureReason_CommitmentTxConfirmed_class =
2672                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CommitmentTxConfirmed"));
2673         CHECK(LDKClosureReason_CommitmentTxConfirmed_class != NULL);
2674         LDKClosureReason_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKClosureReason_CommitmentTxConfirmed_class, "<init>", "()V");
2675         CHECK(LDKClosureReason_CommitmentTxConfirmed_meth != NULL);
2676         LDKClosureReason_FundingTimedOut_class =
2677                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$FundingTimedOut"));
2678         CHECK(LDKClosureReason_FundingTimedOut_class != NULL);
2679         LDKClosureReason_FundingTimedOut_meth = (*env)->GetMethodID(env, LDKClosureReason_FundingTimedOut_class, "<init>", "()V");
2680         CHECK(LDKClosureReason_FundingTimedOut_meth != NULL);
2681         LDKClosureReason_ProcessingError_class =
2682                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$ProcessingError"));
2683         CHECK(LDKClosureReason_ProcessingError_class != NULL);
2684         LDKClosureReason_ProcessingError_meth = (*env)->GetMethodID(env, LDKClosureReason_ProcessingError_class, "<init>", "(Ljava/lang/String;)V");
2685         CHECK(LDKClosureReason_ProcessingError_meth != NULL);
2686         LDKClosureReason_DisconnectedPeer_class =
2687                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$DisconnectedPeer"));
2688         CHECK(LDKClosureReason_DisconnectedPeer_class != NULL);
2689         LDKClosureReason_DisconnectedPeer_meth = (*env)->GetMethodID(env, LDKClosureReason_DisconnectedPeer_class, "<init>", "()V");
2690         CHECK(LDKClosureReason_DisconnectedPeer_meth != NULL);
2691         LDKClosureReason_OutdatedChannelManager_class =
2692                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$OutdatedChannelManager"));
2693         CHECK(LDKClosureReason_OutdatedChannelManager_class != NULL);
2694         LDKClosureReason_OutdatedChannelManager_meth = (*env)->GetMethodID(env, LDKClosureReason_OutdatedChannelManager_class, "<init>", "()V");
2695         CHECK(LDKClosureReason_OutdatedChannelManager_meth != NULL);
2696 }
2697 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2698         LDKClosureReason *obj = (LDKClosureReason*)untag_ptr(ptr);
2699         switch(obj->tag) {
2700                 case LDKClosureReason_CounterpartyForceClosed: {
2701                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
2702                         jstring peer_msg_conv = str_ref_to_java(env, peer_msg_str.chars, peer_msg_str.len);
2703                         return (*env)->NewObject(env, LDKClosureReason_CounterpartyForceClosed_class, LDKClosureReason_CounterpartyForceClosed_meth, peer_msg_conv);
2704                 }
2705                 case LDKClosureReason_HolderForceClosed: {
2706                         return (*env)->NewObject(env, LDKClosureReason_HolderForceClosed_class, LDKClosureReason_HolderForceClosed_meth);
2707                 }
2708                 case LDKClosureReason_CooperativeClosure: {
2709                         return (*env)->NewObject(env, LDKClosureReason_CooperativeClosure_class, LDKClosureReason_CooperativeClosure_meth);
2710                 }
2711                 case LDKClosureReason_CommitmentTxConfirmed: {
2712                         return (*env)->NewObject(env, LDKClosureReason_CommitmentTxConfirmed_class, LDKClosureReason_CommitmentTxConfirmed_meth);
2713                 }
2714                 case LDKClosureReason_FundingTimedOut: {
2715                         return (*env)->NewObject(env, LDKClosureReason_FundingTimedOut_class, LDKClosureReason_FundingTimedOut_meth);
2716                 }
2717                 case LDKClosureReason_ProcessingError: {
2718                         LDKStr err_str = obj->processing_error.err;
2719                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2720                         return (*env)->NewObject(env, LDKClosureReason_ProcessingError_class, LDKClosureReason_ProcessingError_meth, err_conv);
2721                 }
2722                 case LDKClosureReason_DisconnectedPeer: {
2723                         return (*env)->NewObject(env, LDKClosureReason_DisconnectedPeer_class, LDKClosureReason_DisconnectedPeer_meth);
2724                 }
2725                 case LDKClosureReason_OutdatedChannelManager: {
2726                         return (*env)->NewObject(env, LDKClosureReason_OutdatedChannelManager_class, LDKClosureReason_OutdatedChannelManager_meth);
2727                 }
2728                 default: abort();
2729         }
2730 }
2731 static jclass LDKCOption_ClosureReasonZ_Some_class = NULL;
2732 static jmethodID LDKCOption_ClosureReasonZ_Some_meth = NULL;
2733 static jclass LDKCOption_ClosureReasonZ_None_class = NULL;
2734 static jmethodID LDKCOption_ClosureReasonZ_None_meth = NULL;
2735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ClosureReasonZ_init (JNIEnv *env, jclass clz) {
2736         LDKCOption_ClosureReasonZ_Some_class =
2737                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$Some"));
2738         CHECK(LDKCOption_ClosureReasonZ_Some_class != NULL);
2739         LDKCOption_ClosureReasonZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_Some_class, "<init>", "(J)V");
2740         CHECK(LDKCOption_ClosureReasonZ_Some_meth != NULL);
2741         LDKCOption_ClosureReasonZ_None_class =
2742                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$None"));
2743         CHECK(LDKCOption_ClosureReasonZ_None_class != NULL);
2744         LDKCOption_ClosureReasonZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_None_class, "<init>", "()V");
2745         CHECK(LDKCOption_ClosureReasonZ_None_meth != NULL);
2746 }
2747 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ClosureReasonZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2748         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)untag_ptr(ptr);
2749         switch(obj->tag) {
2750                 case LDKCOption_ClosureReasonZ_Some: {
2751                         int64_t some_ref = tag_ptr(&obj->some, false);
2752                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_Some_class, LDKCOption_ClosureReasonZ_Some_meth, some_ref);
2753                 }
2754                 case LDKCOption_ClosureReasonZ_None: {
2755                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_None_class, LDKCOption_ClosureReasonZ_None_meth);
2756                 }
2757                 default: abort();
2758         }
2759 }
2760 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2761 CHECK(owner->result_ok);
2762         return COption_ClosureReasonZ_clone(&*owner->contents.result);
2763 }
2764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2765         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(owner);
2766         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
2767         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
2768         int64_t ret_ref = tag_ptr(ret_copy, true);
2769         return ret_ref;
2770 }
2771
2772 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2773 CHECK(!owner->result_ok);
2774         return DecodeError_clone(&*owner->contents.err);
2775 }
2776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2777         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(owner);
2778         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2779         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
2780         int64_t ret_ref = tag_ptr(ret_copy, true);
2781         return ret_ref;
2782 }
2783
2784 static jclass LDKHTLCDestination_NextHopChannel_class = NULL;
2785 static jmethodID LDKHTLCDestination_NextHopChannel_meth = NULL;
2786 static jclass LDKHTLCDestination_UnknownNextHop_class = NULL;
2787 static jmethodID LDKHTLCDestination_UnknownNextHop_meth = NULL;
2788 static jclass LDKHTLCDestination_FailedPayment_class = NULL;
2789 static jmethodID LDKHTLCDestination_FailedPayment_meth = NULL;
2790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCDestination_init (JNIEnv *env, jclass clz) {
2791         LDKHTLCDestination_NextHopChannel_class =
2792                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$NextHopChannel"));
2793         CHECK(LDKHTLCDestination_NextHopChannel_class != NULL);
2794         LDKHTLCDestination_NextHopChannel_meth = (*env)->GetMethodID(env, LDKHTLCDestination_NextHopChannel_class, "<init>", "([B[B)V");
2795         CHECK(LDKHTLCDestination_NextHopChannel_meth != NULL);
2796         LDKHTLCDestination_UnknownNextHop_class =
2797                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$UnknownNextHop"));
2798         CHECK(LDKHTLCDestination_UnknownNextHop_class != NULL);
2799         LDKHTLCDestination_UnknownNextHop_meth = (*env)->GetMethodID(env, LDKHTLCDestination_UnknownNextHop_class, "<init>", "(J)V");
2800         CHECK(LDKHTLCDestination_UnknownNextHop_meth != NULL);
2801         LDKHTLCDestination_FailedPayment_class =
2802                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$FailedPayment"));
2803         CHECK(LDKHTLCDestination_FailedPayment_class != NULL);
2804         LDKHTLCDestination_FailedPayment_meth = (*env)->GetMethodID(env, LDKHTLCDestination_FailedPayment_class, "<init>", "([B)V");
2805         CHECK(LDKHTLCDestination_FailedPayment_meth != NULL);
2806 }
2807 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCDestination_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2808         LDKHTLCDestination *obj = (LDKHTLCDestination*)untag_ptr(ptr);
2809         switch(obj->tag) {
2810                 case LDKHTLCDestination_NextHopChannel: {
2811                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2812                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->next_hop_channel.node_id.compressed_form);
2813                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2814                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->next_hop_channel.channel_id.data);
2815                         return (*env)->NewObject(env, LDKHTLCDestination_NextHopChannel_class, LDKHTLCDestination_NextHopChannel_meth, node_id_arr, channel_id_arr);
2816                 }
2817                 case LDKHTLCDestination_UnknownNextHop: {
2818                         int64_t requested_forward_scid_conv = obj->unknown_next_hop.requested_forward_scid;
2819                         return (*env)->NewObject(env, LDKHTLCDestination_UnknownNextHop_class, LDKHTLCDestination_UnknownNextHop_meth, requested_forward_scid_conv);
2820                 }
2821                 case LDKHTLCDestination_FailedPayment: {
2822                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2823                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->failed_payment.payment_hash.data);
2824                         return (*env)->NewObject(env, LDKHTLCDestination_FailedPayment_class, LDKHTLCDestination_FailedPayment_meth, payment_hash_arr);
2825                 }
2826                 default: abort();
2827         }
2828 }
2829 static jclass LDKCOption_HTLCDestinationZ_Some_class = NULL;
2830 static jmethodID LDKCOption_HTLCDestinationZ_Some_meth = NULL;
2831 static jclass LDKCOption_HTLCDestinationZ_None_class = NULL;
2832 static jmethodID LDKCOption_HTLCDestinationZ_None_meth = NULL;
2833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1HTLCDestinationZ_init (JNIEnv *env, jclass clz) {
2834         LDKCOption_HTLCDestinationZ_Some_class =
2835                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCDestinationZ$Some"));
2836         CHECK(LDKCOption_HTLCDestinationZ_Some_class != NULL);
2837         LDKCOption_HTLCDestinationZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_HTLCDestinationZ_Some_class, "<init>", "(J)V");
2838         CHECK(LDKCOption_HTLCDestinationZ_Some_meth != NULL);
2839         LDKCOption_HTLCDestinationZ_None_class =
2840                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCDestinationZ$None"));
2841         CHECK(LDKCOption_HTLCDestinationZ_None_class != NULL);
2842         LDKCOption_HTLCDestinationZ_None_meth = (*env)->GetMethodID(env, LDKCOption_HTLCDestinationZ_None_class, "<init>", "()V");
2843         CHECK(LDKCOption_HTLCDestinationZ_None_meth != NULL);
2844 }
2845 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1HTLCDestinationZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2846         LDKCOption_HTLCDestinationZ *obj = (LDKCOption_HTLCDestinationZ*)untag_ptr(ptr);
2847         switch(obj->tag) {
2848                 case LDKCOption_HTLCDestinationZ_Some: {
2849                         int64_t some_ref = tag_ptr(&obj->some, false);
2850                         return (*env)->NewObject(env, LDKCOption_HTLCDestinationZ_Some_class, LDKCOption_HTLCDestinationZ_Some_meth, some_ref);
2851                 }
2852                 case LDKCOption_HTLCDestinationZ_None: {
2853                         return (*env)->NewObject(env, LDKCOption_HTLCDestinationZ_None_class, LDKCOption_HTLCDestinationZ_None_meth);
2854                 }
2855                 default: abort();
2856         }
2857 }
2858 static inline struct LDKCOption_HTLCDestinationZ CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
2859 CHECK(owner->result_ok);
2860         return COption_HTLCDestinationZ_clone(&*owner->contents.result);
2861 }
2862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2863         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(owner);
2864         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
2865         *ret_copy = CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(owner_conv);
2866         int64_t ret_ref = tag_ptr(ret_copy, true);
2867         return ret_ref;
2868 }
2869
2870 static inline struct LDKDecodeError CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
2871 CHECK(!owner->result_ok);
2872         return DecodeError_clone(&*owner->contents.err);
2873 }
2874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2875         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(owner);
2876         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2877         *ret_copy = CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(owner_conv);
2878         int64_t ret_ref = tag_ptr(ret_copy, true);
2879         return ret_ref;
2880 }
2881
2882 static jclass LDKNetworkUpdate_ChannelUpdateMessage_class = NULL;
2883 static jmethodID LDKNetworkUpdate_ChannelUpdateMessage_meth = NULL;
2884 static jclass LDKNetworkUpdate_ChannelFailure_class = NULL;
2885 static jmethodID LDKNetworkUpdate_ChannelFailure_meth = NULL;
2886 static jclass LDKNetworkUpdate_NodeFailure_class = NULL;
2887 static jmethodID LDKNetworkUpdate_NodeFailure_meth = NULL;
2888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetworkUpdate_init (JNIEnv *env, jclass clz) {
2889         LDKNetworkUpdate_ChannelUpdateMessage_class =
2890                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelUpdateMessage"));
2891         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_class != NULL);
2892         LDKNetworkUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
2893         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_meth != NULL);
2894         LDKNetworkUpdate_ChannelFailure_class =
2895                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelFailure"));
2896         CHECK(LDKNetworkUpdate_ChannelFailure_class != NULL);
2897         LDKNetworkUpdate_ChannelFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelFailure_class, "<init>", "(JZ)V");
2898         CHECK(LDKNetworkUpdate_ChannelFailure_meth != NULL);
2899         LDKNetworkUpdate_NodeFailure_class =
2900                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$NodeFailure"));
2901         CHECK(LDKNetworkUpdate_NodeFailure_class != NULL);
2902         LDKNetworkUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_NodeFailure_class, "<init>", "([BZ)V");
2903         CHECK(LDKNetworkUpdate_NodeFailure_meth != NULL);
2904 }
2905 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2906         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)untag_ptr(ptr);
2907         switch(obj->tag) {
2908                 case LDKNetworkUpdate_ChannelUpdateMessage: {
2909                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
2910                         int64_t msg_ref = 0;
2911                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2912                         msg_ref = tag_ptr(msg_var.inner, false);
2913                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelUpdateMessage_class, LDKNetworkUpdate_ChannelUpdateMessage_meth, msg_ref);
2914                 }
2915                 case LDKNetworkUpdate_ChannelFailure: {
2916                         int64_t short_channel_id_conv = obj->channel_failure.short_channel_id;
2917                         jboolean is_permanent_conv = obj->channel_failure.is_permanent;
2918                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelFailure_class, LDKNetworkUpdate_ChannelFailure_meth, short_channel_id_conv, is_permanent_conv);
2919                 }
2920                 case LDKNetworkUpdate_NodeFailure: {
2921                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2922                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
2923                         jboolean is_permanent_conv = obj->node_failure.is_permanent;
2924                         return (*env)->NewObject(env, LDKNetworkUpdate_NodeFailure_class, LDKNetworkUpdate_NodeFailure_meth, node_id_arr, is_permanent_conv);
2925                 }
2926                 default: abort();
2927         }
2928 }
2929 static jclass LDKCOption_NetworkUpdateZ_Some_class = NULL;
2930 static jmethodID LDKCOption_NetworkUpdateZ_Some_meth = NULL;
2931 static jclass LDKCOption_NetworkUpdateZ_None_class = NULL;
2932 static jmethodID LDKCOption_NetworkUpdateZ_None_meth = NULL;
2933 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetworkUpdateZ_init (JNIEnv *env, jclass clz) {
2934         LDKCOption_NetworkUpdateZ_Some_class =
2935                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$Some"));
2936         CHECK(LDKCOption_NetworkUpdateZ_Some_class != NULL);
2937         LDKCOption_NetworkUpdateZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_Some_class, "<init>", "(J)V");
2938         CHECK(LDKCOption_NetworkUpdateZ_Some_meth != NULL);
2939         LDKCOption_NetworkUpdateZ_None_class =
2940                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$None"));
2941         CHECK(LDKCOption_NetworkUpdateZ_None_class != NULL);
2942         LDKCOption_NetworkUpdateZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_None_class, "<init>", "()V");
2943         CHECK(LDKCOption_NetworkUpdateZ_None_meth != NULL);
2944 }
2945 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetworkUpdateZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2946         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)untag_ptr(ptr);
2947         switch(obj->tag) {
2948                 case LDKCOption_NetworkUpdateZ_Some: {
2949                         int64_t some_ref = tag_ptr(&obj->some, false);
2950                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_Some_class, LDKCOption_NetworkUpdateZ_Some_meth, some_ref);
2951                 }
2952                 case LDKCOption_NetworkUpdateZ_None: {
2953                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_None_class, LDKCOption_NetworkUpdateZ_None_meth);
2954                 }
2955                 default: abort();
2956         }
2957 }
2958 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
2959 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
2960 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
2961 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
2962 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
2963 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
2964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
2965         LDKSpendableOutputDescriptor_StaticOutput_class =
2966                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput"));
2967         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
2968         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
2969         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
2970         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
2971                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput"));
2972         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
2973         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
2974         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
2975         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
2976                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput"));
2977         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
2978         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
2979         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
2980 }
2981 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2982         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)untag_ptr(ptr);
2983         switch(obj->tag) {
2984                 case LDKSpendableOutputDescriptor_StaticOutput: {
2985                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
2986                         int64_t outpoint_ref = 0;
2987                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
2988                         outpoint_ref = tag_ptr(outpoint_var.inner, false);
2989                         LDKTxOut* output_ref = &obj->static_output.output;
2990                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, tag_ptr(output_ref, false));
2991                 }
2992                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
2993                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
2994                         int64_t delayed_payment_output_ref = 0;
2995                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
2996                         delayed_payment_output_ref = tag_ptr(delayed_payment_output_var.inner, false);
2997                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
2998                 }
2999                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
3000                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
3001                         int64_t static_payment_output_ref = 0;
3002                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
3003                         static_payment_output_ref = tag_ptr(static_payment_output_var.inner, false);
3004                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
3005                 }
3006                 default: abort();
3007         }
3008 }
3009 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
3010         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
3011         for (size_t i = 0; i < ret.datalen; i++) {
3012                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
3013         }
3014         return ret;
3015 }
3016 static jclass LDKEvent_FundingGenerationReady_class = NULL;
3017 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
3018 static jclass LDKEvent_PaymentReceived_class = NULL;
3019 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
3020 static jclass LDKEvent_PaymentClaimed_class = NULL;
3021 static jmethodID LDKEvent_PaymentClaimed_meth = NULL;
3022 static jclass LDKEvent_PaymentSent_class = NULL;
3023 static jmethodID LDKEvent_PaymentSent_meth = NULL;
3024 static jclass LDKEvent_PaymentFailed_class = NULL;
3025 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
3026 static jclass LDKEvent_PaymentPathSuccessful_class = NULL;
3027 static jmethodID LDKEvent_PaymentPathSuccessful_meth = NULL;
3028 static jclass LDKEvent_PaymentPathFailed_class = NULL;
3029 static jmethodID LDKEvent_PaymentPathFailed_meth = NULL;
3030 static jclass LDKEvent_ProbeSuccessful_class = NULL;
3031 static jmethodID LDKEvent_ProbeSuccessful_meth = NULL;
3032 static jclass LDKEvent_ProbeFailed_class = NULL;
3033 static jmethodID LDKEvent_ProbeFailed_meth = NULL;
3034 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
3035 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
3036 static jclass LDKEvent_SpendableOutputs_class = NULL;
3037 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
3038 static jclass LDKEvent_PaymentForwarded_class = NULL;
3039 static jmethodID LDKEvent_PaymentForwarded_meth = NULL;
3040 static jclass LDKEvent_ChannelClosed_class = NULL;
3041 static jmethodID LDKEvent_ChannelClosed_meth = NULL;
3042 static jclass LDKEvent_DiscardFunding_class = NULL;
3043 static jmethodID LDKEvent_DiscardFunding_meth = NULL;
3044 static jclass LDKEvent_OpenChannelRequest_class = NULL;
3045 static jmethodID LDKEvent_OpenChannelRequest_meth = NULL;
3046 static jclass LDKEvent_HTLCHandlingFailed_class = NULL;
3047 static jmethodID LDKEvent_HTLCHandlingFailed_meth = NULL;
3048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
3049         LDKEvent_FundingGenerationReady_class =
3050                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$FundingGenerationReady"));
3051         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
3052         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([B[BJ[BJ)V");
3053         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
3054         LDKEvent_PaymentReceived_class =
3055                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentReceived"));
3056         CHECK(LDKEvent_PaymentReceived_class != NULL);
3057         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([BJJ)V");
3058         CHECK(LDKEvent_PaymentReceived_meth != NULL);
3059         LDKEvent_PaymentClaimed_class =
3060                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentClaimed"));
3061         CHECK(LDKEvent_PaymentClaimed_class != NULL);
3062         LDKEvent_PaymentClaimed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentClaimed_class, "<init>", "([BJJ)V");
3063         CHECK(LDKEvent_PaymentClaimed_meth != NULL);
3064         LDKEvent_PaymentSent_class =
3065                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentSent"));
3066         CHECK(LDKEvent_PaymentSent_class != NULL);
3067         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B[BJ)V");
3068         CHECK(LDKEvent_PaymentSent_meth != NULL);
3069         LDKEvent_PaymentFailed_class =
3070                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentFailed"));
3071         CHECK(LDKEvent_PaymentFailed_class != NULL);
3072         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([B[B)V");
3073         CHECK(LDKEvent_PaymentFailed_meth != NULL);
3074         LDKEvent_PaymentPathSuccessful_class =
3075                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathSuccessful"));
3076         CHECK(LDKEvent_PaymentPathSuccessful_class != NULL);
3077         LDKEvent_PaymentPathSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathSuccessful_class, "<init>", "([B[B[J)V");
3078         CHECK(LDKEvent_PaymentPathSuccessful_meth != NULL);
3079         LDKEvent_PaymentPathFailed_class =
3080                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathFailed"));
3081         CHECK(LDKEvent_PaymentPathFailed_class != NULL);
3082         LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "<init>", "([B[BZJZ[JJJ)V");
3083         CHECK(LDKEvent_PaymentPathFailed_meth != NULL);
3084         LDKEvent_ProbeSuccessful_class =
3085                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ProbeSuccessful"));
3086         CHECK(LDKEvent_ProbeSuccessful_class != NULL);
3087         LDKEvent_ProbeSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_ProbeSuccessful_class, "<init>", "([B[B[J)V");
3088         CHECK(LDKEvent_ProbeSuccessful_meth != NULL);
3089         LDKEvent_ProbeFailed_class =
3090                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ProbeFailed"));
3091         CHECK(LDKEvent_ProbeFailed_class != NULL);
3092         LDKEvent_ProbeFailed_meth = (*env)->GetMethodID(env, LDKEvent_ProbeFailed_class, "<init>", "([B[B[JJ)V");
3093         CHECK(LDKEvent_ProbeFailed_meth != NULL);
3094         LDKEvent_PendingHTLCsForwardable_class =
3095                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable"));
3096         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
3097         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
3098         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
3099         LDKEvent_SpendableOutputs_class =
3100                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$SpendableOutputs"));
3101         CHECK(LDKEvent_SpendableOutputs_class != NULL);
3102         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
3103         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
3104         LDKEvent_PaymentForwarded_class =
3105                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentForwarded"));
3106         CHECK(LDKEvent_PaymentForwarded_class != NULL);
3107         LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "<init>", "([B[BJZ)V");
3108         CHECK(LDKEvent_PaymentForwarded_meth != NULL);
3109         LDKEvent_ChannelClosed_class =
3110                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ChannelClosed"));
3111         CHECK(LDKEvent_ChannelClosed_class != NULL);
3112         LDKEvent_ChannelClosed_meth = (*env)->GetMethodID(env, LDKEvent_ChannelClosed_class, "<init>", "([BJJ)V");
3113         CHECK(LDKEvent_ChannelClosed_meth != NULL);
3114         LDKEvent_DiscardFunding_class =
3115                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$DiscardFunding"));
3116         CHECK(LDKEvent_DiscardFunding_class != NULL);
3117         LDKEvent_DiscardFunding_meth = (*env)->GetMethodID(env, LDKEvent_DiscardFunding_class, "<init>", "([B[B)V");
3118         CHECK(LDKEvent_DiscardFunding_meth != NULL);
3119         LDKEvent_OpenChannelRequest_class =
3120                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$OpenChannelRequest"));
3121         CHECK(LDKEvent_OpenChannelRequest_class != NULL);
3122         LDKEvent_OpenChannelRequest_meth = (*env)->GetMethodID(env, LDKEvent_OpenChannelRequest_class, "<init>", "([B[BJJJ)V");
3123         CHECK(LDKEvent_OpenChannelRequest_meth != NULL);
3124         LDKEvent_HTLCHandlingFailed_class =
3125                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$HTLCHandlingFailed"));
3126         CHECK(LDKEvent_HTLCHandlingFailed_class != NULL);
3127         LDKEvent_HTLCHandlingFailed_meth = (*env)->GetMethodID(env, LDKEvent_HTLCHandlingFailed_class, "<init>", "([BJ)V");
3128         CHECK(LDKEvent_HTLCHandlingFailed_meth != NULL);
3129 }
3130 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3131         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
3132         switch(obj->tag) {
3133                 case LDKEvent_FundingGenerationReady: {
3134                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
3135                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
3136                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
3137                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->funding_generation_ready.counterparty_node_id.compressed_form);
3138                         int64_t channel_value_satoshis_conv = obj->funding_generation_ready.channel_value_satoshis;
3139                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
3140                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
3141                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
3142                         int64_t user_channel_id_conv = obj->funding_generation_ready.user_channel_id;
3143                         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);
3144                 }
3145                 case LDKEvent_PaymentReceived: {
3146                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3147                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
3148                         int64_t amount_msat_conv = obj->payment_received.amount_msat;
3149                         int64_t purpose_ref = tag_ptr(&obj->payment_received.purpose, false);
3150                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, amount_msat_conv, purpose_ref);
3151                 }
3152                 case LDKEvent_PaymentClaimed: {
3153                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3154                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_claimed.payment_hash.data);
3155                         int64_t amount_msat_conv = obj->payment_claimed.amount_msat;
3156                         int64_t purpose_ref = tag_ptr(&obj->payment_claimed.purpose, false);
3157                         return (*env)->NewObject(env, LDKEvent_PaymentClaimed_class, LDKEvent_PaymentClaimed_meth, payment_hash_arr, amount_msat_conv, purpose_ref);
3158                 }
3159                 case LDKEvent_PaymentSent: {
3160                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3161                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_sent.payment_id.data);
3162                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
3163                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
3164                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3165                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_sent.payment_hash.data);
3166                         int64_t fee_paid_msat_ref = tag_ptr(&obj->payment_sent.fee_paid_msat, false);
3167                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_id_arr, payment_preimage_arr, payment_hash_arr, fee_paid_msat_ref);
3168                 }
3169                 case LDKEvent_PaymentFailed: {
3170                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3171                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_failed.payment_id.data);
3172                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3173                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
3174                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_id_arr, payment_hash_arr);
3175                 }
3176                 case LDKEvent_PaymentPathSuccessful: {
3177                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3178                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_successful.payment_id.data);
3179                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3180                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_successful.payment_hash.data);
3181                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
3182                         int64_tArray path_arr = NULL;
3183                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
3184                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
3185                         for (size_t k = 0; k < path_var.datalen; k++) {
3186                                 LDKRouteHop path_conv_10_var = path_var.data[k];
3187                                 int64_t path_conv_10_ref = 0;
3188                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
3189                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
3190                                 path_arr_ptr[k] = path_conv_10_ref;
3191                         }
3192                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
3193                         return (*env)->NewObject(env, LDKEvent_PaymentPathSuccessful_class, LDKEvent_PaymentPathSuccessful_meth, payment_id_arr, payment_hash_arr, path_arr);
3194                 }
3195                 case LDKEvent_PaymentPathFailed: {
3196                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3197                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_failed.payment_id.data);
3198                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3199                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_failed.payment_hash.data);
3200                         jboolean payment_failed_permanently_conv = obj->payment_path_failed.payment_failed_permanently;
3201                         int64_t network_update_ref = tag_ptr(&obj->payment_path_failed.network_update, false);
3202                         jboolean all_paths_failed_conv = obj->payment_path_failed.all_paths_failed;
3203                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
3204                         int64_tArray path_arr = NULL;
3205                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
3206                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
3207                         for (size_t k = 0; k < path_var.datalen; k++) {
3208                                 LDKRouteHop path_conv_10_var = path_var.data[k];
3209                                 int64_t path_conv_10_ref = 0;
3210                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
3211                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
3212                                 path_arr_ptr[k] = path_conv_10_ref;
3213                         }
3214                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
3215                         int64_t short_channel_id_ref = tag_ptr(&obj->payment_path_failed.short_channel_id, false);
3216                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
3217                         int64_t retry_ref = 0;
3218                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
3219                         retry_ref = tag_ptr(retry_var.inner, false);
3220                         return (*env)->NewObject(env, LDKEvent_PaymentPathFailed_class, LDKEvent_PaymentPathFailed_meth, payment_id_arr, payment_hash_arr, payment_failed_permanently_conv, network_update_ref, all_paths_failed_conv, path_arr, short_channel_id_ref, retry_ref);
3221                 }
3222                 case LDKEvent_ProbeSuccessful: {
3223                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3224                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->probe_successful.payment_id.data);
3225                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3226                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->probe_successful.payment_hash.data);
3227                         LDKCVec_RouteHopZ path_var = obj->probe_successful.path;
3228                         int64_tArray path_arr = NULL;
3229                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
3230                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
3231                         for (size_t k = 0; k < path_var.datalen; k++) {
3232                                 LDKRouteHop path_conv_10_var = path_var.data[k];
3233                                 int64_t path_conv_10_ref = 0;
3234                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
3235                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
3236                                 path_arr_ptr[k] = path_conv_10_ref;
3237                         }
3238                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
3239                         return (*env)->NewObject(env, LDKEvent_ProbeSuccessful_class, LDKEvent_ProbeSuccessful_meth, payment_id_arr, payment_hash_arr, path_arr);
3240                 }
3241                 case LDKEvent_ProbeFailed: {
3242                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3243                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->probe_failed.payment_id.data);
3244                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3245                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->probe_failed.payment_hash.data);
3246                         LDKCVec_RouteHopZ path_var = obj->probe_failed.path;
3247                         int64_tArray path_arr = NULL;
3248                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
3249                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
3250                         for (size_t k = 0; k < path_var.datalen; k++) {
3251                                 LDKRouteHop path_conv_10_var = path_var.data[k];
3252                                 int64_t path_conv_10_ref = 0;
3253                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
3254                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
3255                                 path_arr_ptr[k] = path_conv_10_ref;
3256                         }
3257                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
3258                         int64_t short_channel_id_ref = tag_ptr(&obj->probe_failed.short_channel_id, false);
3259                         return (*env)->NewObject(env, LDKEvent_ProbeFailed_class, LDKEvent_ProbeFailed_meth, payment_id_arr, payment_hash_arr, path_arr, short_channel_id_ref);
3260                 }
3261                 case LDKEvent_PendingHTLCsForwardable: {
3262                         int64_t time_forwardable_conv = obj->pending_htl_cs_forwardable.time_forwardable;
3263                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, time_forwardable_conv);
3264                 }
3265                 case LDKEvent_SpendableOutputs: {
3266                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
3267                         int64_tArray outputs_arr = NULL;
3268                         outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
3269                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
3270                         for (size_t b = 0; b < outputs_var.datalen; b++) {
3271                                 int64_t outputs_conv_27_ref = tag_ptr(&outputs_var.data[b], false);
3272                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
3273                         }
3274                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
3275                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
3276                 }
3277                 case LDKEvent_PaymentForwarded: {
3278                         int8_tArray prev_channel_id_arr = (*env)->NewByteArray(env, 32);
3279                         (*env)->SetByteArrayRegion(env, prev_channel_id_arr, 0, 32, obj->payment_forwarded.prev_channel_id.data);
3280                         int8_tArray next_channel_id_arr = (*env)->NewByteArray(env, 32);
3281                         (*env)->SetByteArrayRegion(env, next_channel_id_arr, 0, 32, obj->payment_forwarded.next_channel_id.data);
3282                         int64_t fee_earned_msat_ref = tag_ptr(&obj->payment_forwarded.fee_earned_msat, false);
3283                         jboolean claim_from_onchain_tx_conv = obj->payment_forwarded.claim_from_onchain_tx;
3284                         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);
3285                 }
3286                 case LDKEvent_ChannelClosed: {
3287                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
3288                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_closed.channel_id.data);
3289                         int64_t user_channel_id_conv = obj->channel_closed.user_channel_id;
3290                         int64_t reason_ref = tag_ptr(&obj->channel_closed.reason, false);
3291                         return (*env)->NewObject(env, LDKEvent_ChannelClosed_class, LDKEvent_ChannelClosed_meth, channel_id_arr, user_channel_id_conv, reason_ref);
3292                 }
3293                 case LDKEvent_DiscardFunding: {
3294                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
3295                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->discard_funding.channel_id.data);
3296                         LDKTransaction transaction_var = obj->discard_funding.transaction;
3297                         int8_tArray transaction_arr = (*env)->NewByteArray(env, transaction_var.datalen);
3298                         (*env)->SetByteArrayRegion(env, transaction_arr, 0, transaction_var.datalen, transaction_var.data);
3299                         return (*env)->NewObject(env, LDKEvent_DiscardFunding_class, LDKEvent_DiscardFunding_meth, channel_id_arr, transaction_arr);
3300                 }
3301                 case LDKEvent_OpenChannelRequest: {
3302                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
3303                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->open_channel_request.temporary_channel_id.data);
3304                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
3305                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->open_channel_request.counterparty_node_id.compressed_form);
3306                         int64_t funding_satoshis_conv = obj->open_channel_request.funding_satoshis;
3307                         int64_t push_msat_conv = obj->open_channel_request.push_msat;
3308                         LDKChannelTypeFeatures channel_type_var = obj->open_channel_request.channel_type;
3309                         int64_t channel_type_ref = 0;
3310                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
3311                         channel_type_ref = tag_ptr(channel_type_var.inner, false);
3312                         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);
3313                 }
3314                 case LDKEvent_HTLCHandlingFailed: {
3315                         int8_tArray prev_channel_id_arr = (*env)->NewByteArray(env, 32);
3316                         (*env)->SetByteArrayRegion(env, prev_channel_id_arr, 0, 32, obj->htlc_handling_failed.prev_channel_id.data);
3317                         int64_t failed_next_destination_ref = tag_ptr(&obj->htlc_handling_failed.failed_next_destination, false);
3318                         return (*env)->NewObject(env, LDKEvent_HTLCHandlingFailed_class, LDKEvent_HTLCHandlingFailed_meth, prev_channel_id_arr, failed_next_destination_ref);
3319                 }
3320                 default: abort();
3321         }
3322 }
3323 static jclass LDKCOption_EventZ_Some_class = NULL;
3324 static jmethodID LDKCOption_EventZ_Some_meth = NULL;
3325 static jclass LDKCOption_EventZ_None_class = NULL;
3326 static jmethodID LDKCOption_EventZ_None_meth = NULL;
3327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1EventZ_init (JNIEnv *env, jclass clz) {
3328         LDKCOption_EventZ_Some_class =
3329                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$Some"));
3330         CHECK(LDKCOption_EventZ_Some_class != NULL);
3331         LDKCOption_EventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_Some_class, "<init>", "(J)V");
3332         CHECK(LDKCOption_EventZ_Some_meth != NULL);
3333         LDKCOption_EventZ_None_class =
3334                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$None"));
3335         CHECK(LDKCOption_EventZ_None_class != NULL);
3336         LDKCOption_EventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_None_class, "<init>", "()V");
3337         CHECK(LDKCOption_EventZ_None_meth != NULL);
3338 }
3339 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1EventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3340         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)untag_ptr(ptr);
3341         switch(obj->tag) {
3342                 case LDKCOption_EventZ_Some: {
3343                         int64_t some_ref = tag_ptr(&obj->some, false);
3344                         return (*env)->NewObject(env, LDKCOption_EventZ_Some_class, LDKCOption_EventZ_Some_meth, some_ref);
3345                 }
3346                 case LDKCOption_EventZ_None: {
3347                         return (*env)->NewObject(env, LDKCOption_EventZ_None_class, LDKCOption_EventZ_None_meth);
3348                 }
3349                 default: abort();
3350         }
3351 }
3352 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
3353 CHECK(owner->result_ok);
3354         return COption_EventZ_clone(&*owner->contents.result);
3355 }
3356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3357         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(owner);
3358         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
3359         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
3360         int64_t ret_ref = tag_ptr(ret_copy, true);
3361         return ret_ref;
3362 }
3363
3364 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
3365 CHECK(!owner->result_ok);
3366         return DecodeError_clone(&*owner->contents.err);
3367 }
3368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3369         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(owner);
3370         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3371         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
3372         int64_t ret_ref = tag_ptr(ret_copy, true);
3373         return ret_ref;
3374 }
3375
3376 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
3377 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
3378 static jclass LDKErrorAction_IgnoreError_class = NULL;
3379 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
3380 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
3381 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
3382 static jclass LDKErrorAction_IgnoreDuplicateGossip_class = NULL;
3383 static jmethodID LDKErrorAction_IgnoreDuplicateGossip_meth = NULL;
3384 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
3385 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
3386 static jclass LDKErrorAction_SendWarningMessage_class = NULL;
3387 static jmethodID LDKErrorAction_SendWarningMessage_meth = NULL;
3388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
3389         LDKErrorAction_DisconnectPeer_class =
3390                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$DisconnectPeer"));
3391         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
3392         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
3393         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
3394         LDKErrorAction_IgnoreError_class =
3395                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreError"));
3396         CHECK(LDKErrorAction_IgnoreError_class != NULL);
3397         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
3398         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
3399         LDKErrorAction_IgnoreAndLog_class =
3400                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog"));
3401         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
3402         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
3403         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
3404         LDKErrorAction_IgnoreDuplicateGossip_class =
3405                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreDuplicateGossip"));
3406         CHECK(LDKErrorAction_IgnoreDuplicateGossip_class != NULL);
3407         LDKErrorAction_IgnoreDuplicateGossip_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreDuplicateGossip_class, "<init>", "()V");
3408         CHECK(LDKErrorAction_IgnoreDuplicateGossip_meth != NULL);
3409         LDKErrorAction_SendErrorMessage_class =
3410                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendErrorMessage"));
3411         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
3412         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
3413         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
3414         LDKErrorAction_SendWarningMessage_class =
3415                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendWarningMessage"));
3416         CHECK(LDKErrorAction_SendWarningMessage_class != NULL);
3417         LDKErrorAction_SendWarningMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendWarningMessage_class, "<init>", "(JLorg/ldk/enums/Level;)V");
3418         CHECK(LDKErrorAction_SendWarningMessage_meth != NULL);
3419 }
3420 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3421         LDKErrorAction *obj = (LDKErrorAction*)untag_ptr(ptr);
3422         switch(obj->tag) {
3423                 case LDKErrorAction_DisconnectPeer: {
3424                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
3425                         int64_t msg_ref = 0;
3426                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3427                         msg_ref = tag_ptr(msg_var.inner, false);
3428                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
3429                 }
3430                 case LDKErrorAction_IgnoreError: {
3431                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
3432                 }
3433                 case LDKErrorAction_IgnoreAndLog: {
3434                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
3435                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
3436                 }
3437                 case LDKErrorAction_IgnoreDuplicateGossip: {
3438                         return (*env)->NewObject(env, LDKErrorAction_IgnoreDuplicateGossip_class, LDKErrorAction_IgnoreDuplicateGossip_meth);
3439                 }
3440                 case LDKErrorAction_SendErrorMessage: {
3441                         LDKErrorMessage msg_var = obj->send_error_message.msg;
3442                         int64_t msg_ref = 0;
3443                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3444                         msg_ref = tag_ptr(msg_var.inner, false);
3445                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
3446                 }
3447                 case LDKErrorAction_SendWarningMessage: {
3448                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
3449                         int64_t msg_ref = 0;
3450                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3451                         msg_ref = tag_ptr(msg_var.inner, false);
3452                         jclass log_level_conv = LDKLevel_to_java(env, obj->send_warning_message.log_level);
3453                         return (*env)->NewObject(env, LDKErrorAction_SendWarningMessage_class, LDKErrorAction_SendWarningMessage_meth, msg_ref, log_level_conv);
3454                 }
3455                 default: abort();
3456         }
3457 }
3458 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
3459 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
3460 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
3461 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
3462 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
3463 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
3464 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
3465 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
3466 static jclass LDKMessageSendEvent_SendChannelReady_class = NULL;
3467 static jmethodID LDKMessageSendEvent_SendChannelReady_meth = NULL;
3468 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
3469 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
3470 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
3471 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
3472 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
3473 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
3474 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
3475 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
3476 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
3477 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
3478 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
3479 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
3480 static jclass LDKMessageSendEvent_SendChannelAnnouncement_class = NULL;
3481 static jmethodID LDKMessageSendEvent_SendChannelAnnouncement_meth = NULL;
3482 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
3483 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
3484 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
3485 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
3486 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
3487 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
3488 static jclass LDKMessageSendEvent_HandleError_class = NULL;
3489 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
3490 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
3491 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
3492 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
3493 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
3494 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
3495 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
3496 static jclass LDKMessageSendEvent_SendGossipTimestampFilter_class = NULL;
3497 static jmethodID LDKMessageSendEvent_SendGossipTimestampFilter_meth = NULL;
3498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
3499         LDKMessageSendEvent_SendAcceptChannel_class =
3500                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel"));
3501         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
3502         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
3503         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
3504         LDKMessageSendEvent_SendOpenChannel_class =
3505                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel"));
3506         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
3507         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
3508         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
3509         LDKMessageSendEvent_SendFundingCreated_class =
3510                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated"));
3511         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
3512         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
3513         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
3514         LDKMessageSendEvent_SendFundingSigned_class =
3515                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned"));
3516         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
3517         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
3518         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
3519         LDKMessageSendEvent_SendChannelReady_class =
3520                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReady"));
3521         CHECK(LDKMessageSendEvent_SendChannelReady_class != NULL);
3522         LDKMessageSendEvent_SendChannelReady_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReady_class, "<init>", "([BJ)V");
3523         CHECK(LDKMessageSendEvent_SendChannelReady_meth != NULL);
3524         LDKMessageSendEvent_SendAnnouncementSignatures_class =
3525                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures"));
3526         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
3527         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
3528         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
3529         LDKMessageSendEvent_UpdateHTLCs_class =
3530                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs"));
3531         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
3532         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
3533         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
3534         LDKMessageSendEvent_SendRevokeAndACK_class =
3535                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK"));
3536         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
3537         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
3538         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
3539         LDKMessageSendEvent_SendClosingSigned_class =
3540                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned"));
3541         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
3542         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
3543         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
3544         LDKMessageSendEvent_SendShutdown_class =
3545                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown"));
3546         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
3547         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
3548         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
3549         LDKMessageSendEvent_SendChannelReestablish_class =
3550                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish"));
3551         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
3552         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
3553         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
3554         LDKMessageSendEvent_SendChannelAnnouncement_class =
3555                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelAnnouncement"));
3556         CHECK(LDKMessageSendEvent_SendChannelAnnouncement_class != NULL);
3557         LDKMessageSendEvent_SendChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelAnnouncement_class, "<init>", "([BJJ)V");
3558         CHECK(LDKMessageSendEvent_SendChannelAnnouncement_meth != NULL);
3559         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
3560                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement"));
3561         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
3562         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
3563         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
3564         LDKMessageSendEvent_BroadcastChannelUpdate_class =
3565                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate"));
3566         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
3567         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
3568         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
3569         LDKMessageSendEvent_SendChannelUpdate_class =
3570                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate"));
3571         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
3572         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
3573         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
3574         LDKMessageSendEvent_HandleError_class =
3575                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$HandleError"));
3576         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
3577         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
3578         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
3579         LDKMessageSendEvent_SendChannelRangeQuery_class =
3580                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery"));
3581         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
3582         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
3583         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
3584         LDKMessageSendEvent_SendShortIdsQuery_class =
3585                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery"));
3586         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
3587         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
3588         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
3589         LDKMessageSendEvent_SendReplyChannelRange_class =
3590                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange"));
3591         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
3592         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
3593         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
3594         LDKMessageSendEvent_SendGossipTimestampFilter_class =
3595                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendGossipTimestampFilter"));
3596         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_class != NULL);
3597         LDKMessageSendEvent_SendGossipTimestampFilter_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, "<init>", "([BJ)V");
3598         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_meth != NULL);
3599 }
3600 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3601         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
3602         switch(obj->tag) {
3603                 case LDKMessageSendEvent_SendAcceptChannel: {
3604                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3605                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
3606                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
3607                         int64_t msg_ref = 0;
3608                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3609                         msg_ref = tag_ptr(msg_var.inner, false);
3610                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
3611                 }
3612                 case LDKMessageSendEvent_SendOpenChannel: {
3613                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3614                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
3615                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
3616                         int64_t msg_ref = 0;
3617                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3618                         msg_ref = tag_ptr(msg_var.inner, false);
3619                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
3620                 }
3621                 case LDKMessageSendEvent_SendFundingCreated: {
3622                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3623                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
3624                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
3625                         int64_t msg_ref = 0;
3626                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3627                         msg_ref = tag_ptr(msg_var.inner, false);
3628                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
3629                 }
3630                 case LDKMessageSendEvent_SendFundingSigned: {
3631                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3632                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
3633                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
3634                         int64_t msg_ref = 0;
3635                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3636                         msg_ref = tag_ptr(msg_var.inner, false);
3637                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
3638                 }
3639                 case LDKMessageSendEvent_SendChannelReady: {
3640                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3641                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_ready.node_id.compressed_form);
3642                         LDKChannelReady msg_var = obj->send_channel_ready.msg;
3643                         int64_t msg_ref = 0;
3644                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3645                         msg_ref = tag_ptr(msg_var.inner, false);
3646                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReady_class, LDKMessageSendEvent_SendChannelReady_meth, node_id_arr, msg_ref);
3647                 }
3648                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
3649                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3650                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
3651                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
3652                         int64_t msg_ref = 0;
3653                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3654                         msg_ref = tag_ptr(msg_var.inner, false);
3655                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
3656                 }
3657                 case LDKMessageSendEvent_UpdateHTLCs: {
3658                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3659                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
3660                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
3661                         int64_t updates_ref = 0;
3662                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
3663                         updates_ref = tag_ptr(updates_var.inner, false);
3664                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
3665                 }
3666                 case LDKMessageSendEvent_SendRevokeAndACK: {
3667                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3668                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
3669                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
3670                         int64_t msg_ref = 0;
3671                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3672                         msg_ref = tag_ptr(msg_var.inner, false);
3673                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
3674                 }
3675                 case LDKMessageSendEvent_SendClosingSigned: {
3676                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3677                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
3678                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
3679                         int64_t msg_ref = 0;
3680                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3681                         msg_ref = tag_ptr(msg_var.inner, false);
3682                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
3683                 }
3684                 case LDKMessageSendEvent_SendShutdown: {
3685                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3686                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
3687                         LDKShutdown msg_var = obj->send_shutdown.msg;
3688                         int64_t msg_ref = 0;
3689                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3690                         msg_ref = tag_ptr(msg_var.inner, false);
3691                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
3692                 }
3693                 case LDKMessageSendEvent_SendChannelReestablish: {
3694                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3695                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
3696                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
3697                         int64_t msg_ref = 0;
3698                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3699                         msg_ref = tag_ptr(msg_var.inner, false);
3700                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
3701                 }
3702                 case LDKMessageSendEvent_SendChannelAnnouncement: {
3703                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3704                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_announcement.node_id.compressed_form);
3705                         LDKChannelAnnouncement msg_var = obj->send_channel_announcement.msg;
3706                         int64_t msg_ref = 0;
3707                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3708                         msg_ref = tag_ptr(msg_var.inner, false);
3709                         LDKChannelUpdate update_msg_var = obj->send_channel_announcement.update_msg;
3710                         int64_t update_msg_ref = 0;
3711                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
3712                         update_msg_ref = tag_ptr(update_msg_var.inner, false);
3713                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelAnnouncement_class, LDKMessageSendEvent_SendChannelAnnouncement_meth, node_id_arr, msg_ref, update_msg_ref);
3714                 }
3715                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
3716                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
3717                         int64_t msg_ref = 0;
3718                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3719                         msg_ref = tag_ptr(msg_var.inner, false);
3720                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
3721                         int64_t update_msg_ref = 0;
3722                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
3723                         update_msg_ref = tag_ptr(update_msg_var.inner, false);
3724                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
3725                 }
3726                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
3727                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
3728                         int64_t msg_ref = 0;
3729                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3730                         msg_ref = tag_ptr(msg_var.inner, false);
3731                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
3732                 }
3733                 case LDKMessageSendEvent_SendChannelUpdate: {
3734                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3735                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
3736                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
3737                         int64_t msg_ref = 0;
3738                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3739                         msg_ref = tag_ptr(msg_var.inner, false);
3740                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
3741                 }
3742                 case LDKMessageSendEvent_HandleError: {
3743                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3744                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
3745                         int64_t action_ref = tag_ptr(&obj->handle_error.action, false);
3746                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
3747                 }
3748                 case LDKMessageSendEvent_SendChannelRangeQuery: {
3749                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3750                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
3751                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
3752                         int64_t msg_ref = 0;
3753                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3754                         msg_ref = tag_ptr(msg_var.inner, false);
3755                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
3756                 }
3757                 case LDKMessageSendEvent_SendShortIdsQuery: {
3758                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3759                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
3760                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
3761                         int64_t msg_ref = 0;
3762                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3763                         msg_ref = tag_ptr(msg_var.inner, false);
3764                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
3765                 }
3766                 case LDKMessageSendEvent_SendReplyChannelRange: {
3767                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3768                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
3769                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
3770                         int64_t msg_ref = 0;
3771                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3772                         msg_ref = tag_ptr(msg_var.inner, false);
3773                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
3774                 }
3775                 case LDKMessageSendEvent_SendGossipTimestampFilter: {
3776                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3777                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_gossip_timestamp_filter.node_id.compressed_form);
3778                         LDKGossipTimestampFilter msg_var = obj->send_gossip_timestamp_filter.msg;
3779                         int64_t msg_ref = 0;
3780                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3781                         msg_ref = tag_ptr(msg_var.inner, false);
3782                         return (*env)->NewObject(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, LDKMessageSendEvent_SendGossipTimestampFilter_meth, node_id_arr, msg_ref);
3783                 }
3784                 default: abort();
3785         }
3786 }
3787 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
3788         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
3789         for (size_t i = 0; i < ret.datalen; i++) {
3790                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
3791         }
3792         return ret;
3793 }
3794 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
3795 CHECK(owner->result_ok);
3796         return TxOut_clone(&*owner->contents.result);
3797 }
3798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3799         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(owner);
3800         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
3801         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
3802         return tag_ptr(ret_ref, true);
3803 }
3804
3805 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
3806 CHECK(!owner->result_ok);
3807         return AccessError_clone(&*owner->contents.err);
3808 }
3809 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3810         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(owner);
3811         jclass ret_conv = LDKAccessError_to_java(env, CResult_TxOutAccessErrorZ_get_err(owner_conv));
3812         return ret_conv;
3813 }
3814
3815 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
3816         return owner->a;
3817 }
3818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3819         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(owner);
3820         int64_t ret_conv = C2Tuple_usizeTransactionZ_get_a(owner_conv);
3821         return ret_conv;
3822 }
3823
3824 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
3825         return owner->b;
3826 }
3827 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3828         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(owner);
3829         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
3830         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
3831         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
3832         return ret_arr;
3833 }
3834
3835 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
3836         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
3837         for (size_t i = 0; i < ret.datalen; i++) {
3838                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
3839         }
3840         return ret;
3841 }
3842 static inline LDKCVec_TxidZ CVec_TxidZ_clone(const LDKCVec_TxidZ *orig) {
3843         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
3844         for (size_t i = 0; i < ret.datalen; i++) {
3845                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
3846         }
3847         return ret;
3848 }
3849 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
3850 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
3851 static jclass LDKMonitorEvent_CommitmentTxConfirmed_class = NULL;
3852 static jmethodID LDKMonitorEvent_CommitmentTxConfirmed_meth = NULL;
3853 static jclass LDKMonitorEvent_Completed_class = NULL;
3854 static jmethodID LDKMonitorEvent_Completed_meth = NULL;
3855 static jclass LDKMonitorEvent_UpdateFailed_class = NULL;
3856 static jmethodID LDKMonitorEvent_UpdateFailed_meth = NULL;
3857 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
3858         LDKMonitorEvent_HTLCEvent_class =
3859                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent"));
3860         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
3861         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
3862         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
3863         LDKMonitorEvent_CommitmentTxConfirmed_class =
3864                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxConfirmed"));
3865         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_class != NULL);
3866         LDKMonitorEvent_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxConfirmed_class, "<init>", "(J)V");
3867         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_meth != NULL);
3868         LDKMonitorEvent_Completed_class =
3869                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$Completed"));
3870         CHECK(LDKMonitorEvent_Completed_class != NULL);
3871         LDKMonitorEvent_Completed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_Completed_class, "<init>", "(JJ)V");
3872         CHECK(LDKMonitorEvent_Completed_meth != NULL);
3873         LDKMonitorEvent_UpdateFailed_class =
3874                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateFailed"));
3875         CHECK(LDKMonitorEvent_UpdateFailed_class != NULL);
3876         LDKMonitorEvent_UpdateFailed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateFailed_class, "<init>", "(J)V");
3877         CHECK(LDKMonitorEvent_UpdateFailed_meth != NULL);
3878 }
3879 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3880         LDKMonitorEvent *obj = (LDKMonitorEvent*)untag_ptr(ptr);
3881         switch(obj->tag) {
3882                 case LDKMonitorEvent_HTLCEvent: {
3883                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
3884                         int64_t htlc_event_ref = 0;
3885                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
3886                         htlc_event_ref = tag_ptr(htlc_event_var.inner, false);
3887                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
3888                 }
3889                 case LDKMonitorEvent_CommitmentTxConfirmed: {
3890                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
3891                         int64_t commitment_tx_confirmed_ref = 0;
3892                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
3893                         commitment_tx_confirmed_ref = tag_ptr(commitment_tx_confirmed_var.inner, false);
3894                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxConfirmed_class, LDKMonitorEvent_CommitmentTxConfirmed_meth, commitment_tx_confirmed_ref);
3895                 }
3896                 case LDKMonitorEvent_Completed: {
3897                         LDKOutPoint funding_txo_var = obj->completed.funding_txo;
3898                         int64_t funding_txo_ref = 0;
3899                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
3900                         funding_txo_ref = tag_ptr(funding_txo_var.inner, false);
3901                         int64_t monitor_update_id_conv = obj->completed.monitor_update_id;
3902                         return (*env)->NewObject(env, LDKMonitorEvent_Completed_class, LDKMonitorEvent_Completed_meth, funding_txo_ref, monitor_update_id_conv);
3903                 }
3904                 case LDKMonitorEvent_UpdateFailed: {
3905                         LDKOutPoint update_failed_var = obj->update_failed;
3906                         int64_t update_failed_ref = 0;
3907                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
3908                         update_failed_ref = tag_ptr(update_failed_var.inner, false);
3909                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateFailed_class, LDKMonitorEvent_UpdateFailed_meth, update_failed_ref);
3910                 }
3911                 default: abort();
3912         }
3913 }
3914 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
3915         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
3916         for (size_t i = 0; i < ret.datalen; i++) {
3917                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
3918         }
3919         return ret;
3920 }
3921 static inline struct LDKOutPoint C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
3922         LDKOutPoint ret = owner->a;
3923         ret.is_owned = false;
3924         return ret;
3925 }
3926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3927         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
3928         LDKOutPoint ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(owner_conv);
3929         int64_t ret_ref = 0;
3930         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3931         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3932         return ret_ref;
3933 }
3934
3935 static inline struct LDKCVec_MonitorEventZ C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
3936         return CVec_MonitorEventZ_clone(&owner->b);
3937 }
3938 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3939         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
3940         LDKCVec_MonitorEventZ ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(owner_conv);
3941         int64_tArray ret_arr = NULL;
3942         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
3943         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
3944         for (size_t o = 0; o < ret_var.datalen; o++) {
3945                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3946                 *ret_conv_14_copy = ret_var.data[o];
3947                 int64_t ret_conv_14_ref = tag_ptr(ret_conv_14_copy, true);
3948                 ret_arr_ptr[o] = ret_conv_14_ref;
3949         }
3950         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
3951         FREE(ret_var.data);
3952         return ret_arr;
3953 }
3954
3955 static inline struct LDKPublicKey C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
3956         return owner->c;
3957 }
3958 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
3959         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
3960         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
3961         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(owner_conv).compressed_form);
3962         return ret_arr;
3963 }
3964
3965 static inline LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_clone(const LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ *orig) {
3966         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) * orig->datalen, "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ clone bytes"), .datalen = orig->datalen };
3967         for (size_t i = 0; i < ret.datalen; i++) {
3968                 ret.data[i] = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(&orig->data[i]);
3969         }
3970         return ret;
3971 }
3972 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3973         LDKFixedPenaltyScorer ret = *owner->contents.result;
3974         ret.is_owned = false;
3975         return ret;
3976 }
3977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3978         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(owner);
3979         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
3980         int64_t ret_ref = 0;
3981         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3982         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3983         return ret_ref;
3984 }
3985
3986 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3987 CHECK(!owner->result_ok);
3988         return DecodeError_clone(&*owner->contents.err);
3989 }
3990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3991         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(owner);
3992         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3993         *ret_copy = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
3994         int64_t ret_ref = tag_ptr(ret_copy, true);
3995         return ret_ref;
3996 }
3997
3998 static inline uint64_t C2Tuple_u64u64Z_get_a(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
3999         return owner->a;
4000 }
4001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4002         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(owner);
4003         int64_t ret_conv = C2Tuple_u64u64Z_get_a(owner_conv);
4004         return ret_conv;
4005 }
4006
4007 static inline uint64_t C2Tuple_u64u64Z_get_b(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
4008         return owner->b;
4009 }
4010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4011         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(owner);
4012         int64_t ret_conv = C2Tuple_u64u64Z_get_b(owner_conv);
4013         return ret_conv;
4014 }
4015
4016 static jclass LDKCOption_C2Tuple_u64u64ZZ_Some_class = NULL;
4017 static jmethodID LDKCOption_C2Tuple_u64u64ZZ_Some_meth = NULL;
4018 static jclass LDKCOption_C2Tuple_u64u64ZZ_None_class = NULL;
4019 static jmethodID LDKCOption_C2Tuple_u64u64ZZ_None_meth = NULL;
4020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1u64u64ZZ_init (JNIEnv *env, jclass clz) {
4021         LDKCOption_C2Tuple_u64u64ZZ_Some_class =
4022                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_u64u64ZZ$Some"));
4023         CHECK(LDKCOption_C2Tuple_u64u64ZZ_Some_class != NULL);
4024         LDKCOption_C2Tuple_u64u64ZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_u64u64ZZ_Some_class, "<init>", "(J)V");
4025         CHECK(LDKCOption_C2Tuple_u64u64ZZ_Some_meth != NULL);
4026         LDKCOption_C2Tuple_u64u64ZZ_None_class =
4027                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_u64u64ZZ$None"));
4028         CHECK(LDKCOption_C2Tuple_u64u64ZZ_None_class != NULL);
4029         LDKCOption_C2Tuple_u64u64ZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_u64u64ZZ_None_class, "<init>", "()V");
4030         CHECK(LDKCOption_C2Tuple_u64u64ZZ_None_meth != NULL);
4031 }
4032 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1u64u64ZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4033         LDKCOption_C2Tuple_u64u64ZZ *obj = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(ptr);
4034         switch(obj->tag) {
4035                 case LDKCOption_C2Tuple_u64u64ZZ_Some: {
4036                         LDKC2Tuple_u64u64Z* some_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
4037                         *some_conv = obj->some;
4038                         *some_conv = C2Tuple_u64u64Z_clone(some_conv);
4039                         return (*env)->NewObject(env, LDKCOption_C2Tuple_u64u64ZZ_Some_class, LDKCOption_C2Tuple_u64u64ZZ_Some_meth, tag_ptr(some_conv, true));
4040                 }
4041                 case LDKCOption_C2Tuple_u64u64ZZ_None: {
4042                         return (*env)->NewObject(env, LDKCOption_C2Tuple_u64u64ZZ_None_class, LDKCOption_C2Tuple_u64u64ZZ_None_meth);
4043                 }
4044                 default: abort();
4045         }
4046 }
4047 static inline LDKCVec_NodeIdZ CVec_NodeIdZ_clone(const LDKCVec_NodeIdZ *orig) {
4048         LDKCVec_NodeIdZ ret = { .data = MALLOC(sizeof(LDKNodeId) * orig->datalen, "LDKCVec_NodeIdZ clone bytes"), .datalen = orig->datalen };
4049         for (size_t i = 0; i < ret.datalen; i++) {
4050                 ret.data[i] = NodeId_clone(&orig->data[i]);
4051         }
4052         return ret;
4053 }
4054 typedef struct LDKLogger_JCalls {
4055         atomic_size_t refcnt;
4056         JavaVM *vm;
4057         jweak o;
4058         jmethodID log_meth;
4059 } LDKLogger_JCalls;
4060 static void LDKLogger_JCalls_free(void* this_arg) {
4061         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4062         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4063                 JNIEnv *env;
4064                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4065                 if (get_jenv_res == JNI_EDETACHED) {
4066                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4067                 } else {
4068                         DO_ASSERT(get_jenv_res == JNI_OK);
4069                 }
4070                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4071                 if (get_jenv_res == JNI_EDETACHED) {
4072                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4073                 }
4074                 FREE(j_calls);
4075         }
4076 }
4077 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
4078         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4079         JNIEnv *env;
4080         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4081         if (get_jenv_res == JNI_EDETACHED) {
4082                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4083         } else {
4084                 DO_ASSERT(get_jenv_res == JNI_OK);
4085         }
4086         LDKRecord record_var = *record;
4087         int64_t record_ref = 0;
4088         record_var = Record_clone(&record_var);
4089         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
4090         record_ref = tag_ptr(record_var.inner, record_var.is_owned);
4091         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4092         CHECK(obj != NULL);
4093         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_ref);
4094         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4095                 (*env)->ExceptionDescribe(env);
4096                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
4097         }
4098         if (get_jenv_res == JNI_EDETACHED) {
4099                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4100         }
4101 }
4102 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
4103         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
4104         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4105 }
4106 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
4107         jclass c = (*env)->GetObjectClass(env, o);
4108         CHECK(c != NULL);
4109         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
4110         atomic_init(&calls->refcnt, 1);
4111         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4112         calls->o = (*env)->NewWeakGlobalRef(env, o);
4113         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(J)V");
4114         CHECK(calls->log_meth != NULL);
4115
4116         LDKLogger ret = {
4117                 .this_arg = (void*) calls,
4118                 .log = log_LDKLogger_jcall,
4119                 .free = LDKLogger_JCalls_free,
4120         };
4121         return ret;
4122 }
4123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
4124         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
4125         *res_ptr = LDKLogger_init(env, clz, o);
4126         return tag_ptr(res_ptr, true);
4127 }
4128 static inline struct LDKProbabilisticScorer CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
4129         LDKProbabilisticScorer ret = *owner->contents.result;
4130         ret.is_owned = false;
4131         return ret;
4132 }
4133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4134         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(owner);
4135         LDKProbabilisticScorer ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
4136         int64_t ret_ref = 0;
4137         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4138         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4139         return ret_ref;
4140 }
4141
4142 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
4143 CHECK(!owner->result_ok);
4144         return DecodeError_clone(&*owner->contents.err);
4145 }
4146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4147         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(owner);
4148         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4149         *ret_copy = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
4150         int64_t ret_ref = tag_ptr(ret_copy, true);
4151         return ret_ref;
4152 }
4153
4154 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
4155         LDKInitFeatures ret = *owner->contents.result;
4156         ret.is_owned = false;
4157         return ret;
4158 }
4159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4160         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(owner);
4161         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
4162         int64_t ret_ref = 0;
4163         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4164         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4165         return ret_ref;
4166 }
4167
4168 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
4169 CHECK(!owner->result_ok);
4170         return DecodeError_clone(&*owner->contents.err);
4171 }
4172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4173         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(owner);
4174         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4175         *ret_copy = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
4176         int64_t ret_ref = tag_ptr(ret_copy, true);
4177         return ret_ref;
4178 }
4179
4180 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
4181         LDKChannelFeatures ret = *owner->contents.result;
4182         ret.is_owned = false;
4183         return ret;
4184 }
4185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4186         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(owner);
4187         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
4188         int64_t ret_ref = 0;
4189         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4190         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4191         return ret_ref;
4192 }
4193
4194 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
4195 CHECK(!owner->result_ok);
4196         return DecodeError_clone(&*owner->contents.err);
4197 }
4198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4199         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(owner);
4200         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4201         *ret_copy = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
4202         int64_t ret_ref = tag_ptr(ret_copy, true);
4203         return ret_ref;
4204 }
4205
4206 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4207         LDKNodeFeatures ret = *owner->contents.result;
4208         ret.is_owned = false;
4209         return ret;
4210 }
4211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4212         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(owner);
4213         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
4214         int64_t ret_ref = 0;
4215         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4216         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4217         return ret_ref;
4218 }
4219
4220 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4221 CHECK(!owner->result_ok);
4222         return DecodeError_clone(&*owner->contents.err);
4223 }
4224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4225         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(owner);
4226         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4227         *ret_copy = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
4228         int64_t ret_ref = tag_ptr(ret_copy, true);
4229         return ret_ref;
4230 }
4231
4232 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
4233         LDKInvoiceFeatures ret = *owner->contents.result;
4234         ret.is_owned = false;
4235         return ret;
4236 }
4237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4238         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(owner);
4239         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
4240         int64_t ret_ref = 0;
4241         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4242         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4243         return ret_ref;
4244 }
4245
4246 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
4247 CHECK(!owner->result_ok);
4248         return DecodeError_clone(&*owner->contents.err);
4249 }
4250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4251         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(owner);
4252         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4253         *ret_copy = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
4254         int64_t ret_ref = tag_ptr(ret_copy, true);
4255         return ret_ref;
4256 }
4257
4258 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4259         LDKChannelTypeFeatures ret = *owner->contents.result;
4260         ret.is_owned = false;
4261         return ret;
4262 }
4263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4264         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(owner);
4265         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
4266         int64_t ret_ref = 0;
4267         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4268         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4269         return ret_ref;
4270 }
4271
4272 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4273 CHECK(!owner->result_ok);
4274         return DecodeError_clone(&*owner->contents.err);
4275 }
4276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4277         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(owner);
4278         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4279         *ret_copy = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
4280         int64_t ret_ref = tag_ptr(ret_copy, true);
4281         return ret_ref;
4282 }
4283
4284 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
4285         LDKNodeId ret = *owner->contents.result;
4286         ret.is_owned = false;
4287         return ret;
4288 }
4289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4290         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(owner);
4291         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
4292         int64_t ret_ref = 0;
4293         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4294         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4295         return ret_ref;
4296 }
4297
4298 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
4299 CHECK(!owner->result_ok);
4300         return DecodeError_clone(&*owner->contents.err);
4301 }
4302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4303         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(owner);
4304         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4305         *ret_copy = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
4306         int64_t ret_ref = tag_ptr(ret_copy, true);
4307         return ret_ref;
4308 }
4309
4310 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
4311 CHECK(owner->result_ok);
4312         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
4313 }
4314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4315         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(owner);
4316         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
4317         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
4318         int64_t ret_ref = tag_ptr(ret_copy, true);
4319         return ret_ref;
4320 }
4321
4322 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
4323 CHECK(!owner->result_ok);
4324         return DecodeError_clone(&*owner->contents.err);
4325 }
4326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4327         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(owner);
4328         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4329         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
4330         int64_t ret_ref = tag_ptr(ret_copy, true);
4331         return ret_ref;
4332 }
4333
4334 typedef struct LDKAccess_JCalls {
4335         atomic_size_t refcnt;
4336         JavaVM *vm;
4337         jweak o;
4338         jmethodID get_utxo_meth;
4339 } LDKAccess_JCalls;
4340 static void LDKAccess_JCalls_free(void* this_arg) {
4341         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4342         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4343                 JNIEnv *env;
4344                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4345                 if (get_jenv_res == JNI_EDETACHED) {
4346                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4347                 } else {
4348                         DO_ASSERT(get_jenv_res == JNI_OK);
4349                 }
4350                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4351                 if (get_jenv_res == JNI_EDETACHED) {
4352                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4353                 }
4354                 FREE(j_calls);
4355         }
4356 }
4357 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
4358         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4359         JNIEnv *env;
4360         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4361         if (get_jenv_res == JNI_EDETACHED) {
4362                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4363         } else {
4364                 DO_ASSERT(get_jenv_res == JNI_OK);
4365         }
4366         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
4367         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
4368         int64_t short_channel_id_conv = short_channel_id;
4369         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4370         CHECK(obj != NULL);
4371         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id_conv);
4372         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4373                 (*env)->ExceptionDescribe(env);
4374                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
4375         }
4376         void* ret_ptr = untag_ptr(ret);
4377         CHECK_ACCESS(ret_ptr);
4378         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
4379         FREE(untag_ptr(ret));
4380         if (get_jenv_res == JNI_EDETACHED) {
4381                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4382         }
4383         return ret_conv;
4384 }
4385 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
4386         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
4387         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4388 }
4389 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
4390         jclass c = (*env)->GetObjectClass(env, o);
4391         CHECK(c != NULL);
4392         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
4393         atomic_init(&calls->refcnt, 1);
4394         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4395         calls->o = (*env)->NewWeakGlobalRef(env, o);
4396         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
4397         CHECK(calls->get_utxo_meth != NULL);
4398
4399         LDKAccess ret = {
4400                 .this_arg = (void*) calls,
4401                 .get_utxo = get_utxo_LDKAccess_jcall,
4402                 .free = LDKAccess_JCalls_free,
4403         };
4404         return ret;
4405 }
4406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
4407         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
4408         *res_ptr = LDKAccess_init(env, clz, o);
4409         return tag_ptr(res_ptr, true);
4410 }
4411 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) {
4412         void* this_arg_ptr = untag_ptr(this_arg);
4413         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4414         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
4415         unsigned char genesis_hash_arr[32];
4416         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
4417         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
4418         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
4419         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4420         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
4421         return tag_ptr(ret_conv, true);
4422 }
4423
4424 static jclass LDKCOption_AccessZ_Some_class = NULL;
4425 static jmethodID LDKCOption_AccessZ_Some_meth = NULL;
4426 static jclass LDKCOption_AccessZ_None_class = NULL;
4427 static jmethodID LDKCOption_AccessZ_None_meth = NULL;
4428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1AccessZ_init (JNIEnv *env, jclass clz) {
4429         LDKCOption_AccessZ_Some_class =
4430                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$Some"));
4431         CHECK(LDKCOption_AccessZ_Some_class != NULL);
4432         LDKCOption_AccessZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_Some_class, "<init>", "(J)V");
4433         CHECK(LDKCOption_AccessZ_Some_meth != NULL);
4434         LDKCOption_AccessZ_None_class =
4435                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$None"));
4436         CHECK(LDKCOption_AccessZ_None_class != NULL);
4437         LDKCOption_AccessZ_None_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_None_class, "<init>", "()V");
4438         CHECK(LDKCOption_AccessZ_None_meth != NULL);
4439 }
4440 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1AccessZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4441         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)untag_ptr(ptr);
4442         switch(obj->tag) {
4443                 case LDKCOption_AccessZ_Some: {
4444                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
4445                         *some_ret = obj->some;
4446                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
4447                         if ((*some_ret).free == LDKAccess_JCalls_free) {
4448                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
4449                                 LDKAccess_JCalls_cloned(&(*some_ret));
4450                         }
4451                         return (*env)->NewObject(env, LDKCOption_AccessZ_Some_class, LDKCOption_AccessZ_Some_meth, tag_ptr(some_ret, true));
4452                 }
4453                 case LDKCOption_AccessZ_None: {
4454                         return (*env)->NewObject(env, LDKCOption_AccessZ_None_class, LDKCOption_AccessZ_None_meth);
4455                 }
4456                 default: abort();
4457         }
4458 }
4459 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
4460 CHECK(owner->result_ok);
4461         return *owner->contents.result;
4462 }
4463 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4464         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(owner);
4465         jboolean ret_conv = CResult_boolLightningErrorZ_get_ok(owner_conv);
4466         return ret_conv;
4467 }
4468
4469 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
4470         LDKLightningError ret = *owner->contents.err;
4471         ret.is_owned = false;
4472         return ret;
4473 }
4474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4475         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(owner);
4476         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
4477         int64_t ret_ref = 0;
4478         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4479         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4480         return ret_ref;
4481 }
4482
4483 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
4484         LDKChannelAnnouncement ret = owner->a;
4485         ret.is_owned = false;
4486         return ret;
4487 }
4488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4489         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
4490         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
4491         int64_t ret_ref = 0;
4492         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4493         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4494         return ret_ref;
4495 }
4496
4497 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
4498         LDKChannelUpdate ret = owner->b;
4499         ret.is_owned = false;
4500         return ret;
4501 }
4502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4503         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
4504         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
4505         int64_t ret_ref = 0;
4506         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4507         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4508         return ret_ref;
4509 }
4510
4511 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
4512         LDKChannelUpdate ret = owner->c;
4513         ret.is_owned = false;
4514         return ret;
4515 }
4516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
4517         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
4518         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
4519         int64_t ret_ref = 0;
4520         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4521         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4522         return ret_ref;
4523 }
4524
4525 static jclass LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class = NULL;
4526 static jmethodID LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth = NULL;
4527 static jclass LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class = NULL;
4528 static jmethodID LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth = NULL;
4529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_init (JNIEnv *env, jclass clz) {
4530         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class =
4531                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ$Some"));
4532         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class != NULL);
4533         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class, "<init>", "(J)V");
4534         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth != NULL);
4535         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class =
4536                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ$None"));
4537         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class != NULL);
4538         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class, "<init>", "()V");
4539         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth != NULL);
4540 }
4541 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4542         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *obj = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(ptr);
4543         switch(obj->tag) {
4544                 case LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some: {
4545                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* some_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
4546                         *some_conv = obj->some;
4547                         *some_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(some_conv);
4548                         return (*env)->NewObject(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth, tag_ptr(some_conv, true));
4549                 }
4550                 case LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None: {
4551                         return (*env)->NewObject(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth);
4552                 }
4553                 default: abort();
4554         }
4555 }
4556 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
4557 CHECK(owner->result_ok);
4558         return *owner->contents.result;
4559 }
4560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4561         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(owner);
4562         CResult_NoneLightningErrorZ_get_ok(owner_conv);
4563 }
4564
4565 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
4566         LDKLightningError ret = *owner->contents.err;
4567         ret.is_owned = false;
4568         return ret;
4569 }
4570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4571         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(owner);
4572         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
4573         int64_t ret_ref = 0;
4574         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4575         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4576         return ret_ref;
4577 }
4578
4579 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
4580         LDKChannelUpdateInfo ret = *owner->contents.result;
4581         ret.is_owned = false;
4582         return ret;
4583 }
4584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4585         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(owner);
4586         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
4587         int64_t ret_ref = 0;
4588         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4589         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4590         return ret_ref;
4591 }
4592
4593 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
4594 CHECK(!owner->result_ok);
4595         return DecodeError_clone(&*owner->contents.err);
4596 }
4597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4598         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(owner);
4599         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4600         *ret_copy = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
4601         int64_t ret_ref = tag_ptr(ret_copy, true);
4602         return ret_ref;
4603 }
4604
4605 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
4606         LDKChannelInfo ret = *owner->contents.result;
4607         ret.is_owned = false;
4608         return ret;
4609 }
4610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4611         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(owner);
4612         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
4613         int64_t ret_ref = 0;
4614         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4615         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4616         return ret_ref;
4617 }
4618
4619 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
4620 CHECK(!owner->result_ok);
4621         return DecodeError_clone(&*owner->contents.err);
4622 }
4623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4624         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(owner);
4625         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4626         *ret_copy = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
4627         int64_t ret_ref = tag_ptr(ret_copy, true);
4628         return ret_ref;
4629 }
4630
4631 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
4632         LDKRoutingFees ret = *owner->contents.result;
4633         ret.is_owned = false;
4634         return ret;
4635 }
4636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4637         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(owner);
4638         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
4639         int64_t ret_ref = 0;
4640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4641         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4642         return ret_ref;
4643 }
4644
4645 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
4646 CHECK(!owner->result_ok);
4647         return DecodeError_clone(&*owner->contents.err);
4648 }
4649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4650         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(owner);
4651         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4652         *ret_copy = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
4653         int64_t ret_ref = tag_ptr(ret_copy, true);
4654         return ret_ref;
4655 }
4656
4657 static jclass LDKNetAddress_IPv4_class = NULL;
4658 static jmethodID LDKNetAddress_IPv4_meth = NULL;
4659 static jclass LDKNetAddress_IPv6_class = NULL;
4660 static jmethodID LDKNetAddress_IPv6_meth = NULL;
4661 static jclass LDKNetAddress_OnionV2_class = NULL;
4662 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
4663 static jclass LDKNetAddress_OnionV3_class = NULL;
4664 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
4665 static jclass LDKNetAddress_Hostname_class = NULL;
4666 static jmethodID LDKNetAddress_Hostname_meth = NULL;
4667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
4668         LDKNetAddress_IPv4_class =
4669                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv4"));
4670         CHECK(LDKNetAddress_IPv4_class != NULL);
4671         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
4672         CHECK(LDKNetAddress_IPv4_meth != NULL);
4673         LDKNetAddress_IPv6_class =
4674                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv6"));
4675         CHECK(LDKNetAddress_IPv6_class != NULL);
4676         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
4677         CHECK(LDKNetAddress_IPv6_meth != NULL);
4678         LDKNetAddress_OnionV2_class =
4679                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV2"));
4680         CHECK(LDKNetAddress_OnionV2_class != NULL);
4681         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([B)V");
4682         CHECK(LDKNetAddress_OnionV2_meth != NULL);
4683         LDKNetAddress_OnionV3_class =
4684                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV3"));
4685         CHECK(LDKNetAddress_OnionV3_class != NULL);
4686         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
4687         CHECK(LDKNetAddress_OnionV3_meth != NULL);
4688         LDKNetAddress_Hostname_class =
4689                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$Hostname"));
4690         CHECK(LDKNetAddress_Hostname_class != NULL);
4691         LDKNetAddress_Hostname_meth = (*env)->GetMethodID(env, LDKNetAddress_Hostname_class, "<init>", "(JS)V");
4692         CHECK(LDKNetAddress_Hostname_meth != NULL);
4693 }
4694 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4695         LDKNetAddress *obj = (LDKNetAddress*)untag_ptr(ptr);
4696         switch(obj->tag) {
4697                 case LDKNetAddress_IPv4: {
4698                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
4699                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
4700                         int16_t port_conv = obj->i_pv4.port;
4701                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, port_conv);
4702                 }
4703                 case LDKNetAddress_IPv6: {
4704                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
4705                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
4706                         int16_t port_conv = obj->i_pv6.port;
4707                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, port_conv);
4708                 }
4709                 case LDKNetAddress_OnionV2: {
4710                         int8_tArray onion_v2_arr = (*env)->NewByteArray(env, 12);
4711                         (*env)->SetByteArrayRegion(env, onion_v2_arr, 0, 12, obj->onion_v2.data);
4712                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, onion_v2_arr);
4713                 }
4714                 case LDKNetAddress_OnionV3: {
4715                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
4716                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
4717                         int16_t checksum_conv = obj->onion_v3.checksum;
4718                         int8_t version_conv = obj->onion_v3.version;
4719                         int16_t port_conv = obj->onion_v3.port;
4720                         return (*env)->NewObject(env, LDKNetAddress_OnionV3_class, LDKNetAddress_OnionV3_meth, ed25519_pubkey_arr, checksum_conv, version_conv, port_conv);
4721                 }
4722                 case LDKNetAddress_Hostname: {
4723                         LDKHostname hostname_var = obj->hostname.hostname;
4724                         int64_t hostname_ref = 0;
4725                         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_var);
4726                         hostname_ref = tag_ptr(hostname_var.inner, false);
4727                         int16_t port_conv = obj->hostname.port;
4728                         return (*env)->NewObject(env, LDKNetAddress_Hostname_class, LDKNetAddress_Hostname_meth, hostname_ref, port_conv);
4729                 }
4730                 default: abort();
4731         }
4732 }
4733 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
4734         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
4735         for (size_t i = 0; i < ret.datalen; i++) {
4736                 ret.data[i] = NetAddress_clone(&orig->data[i]);
4737         }
4738         return ret;
4739 }
4740 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
4741         LDKNodeAnnouncementInfo ret = *owner->contents.result;
4742         ret.is_owned = false;
4743         return ret;
4744 }
4745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4746         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(owner);
4747         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
4748         int64_t ret_ref = 0;
4749         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4750         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4751         return ret_ref;
4752 }
4753
4754 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
4755 CHECK(!owner->result_ok);
4756         return DecodeError_clone(&*owner->contents.err);
4757 }
4758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4759         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(owner);
4760         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4761         *ret_copy = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
4762         int64_t ret_ref = tag_ptr(ret_copy, true);
4763         return ret_ref;
4764 }
4765
4766 static inline struct LDKNodeAlias CResult_NodeAliasDecodeErrorZ_get_ok(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
4767         LDKNodeAlias ret = *owner->contents.result;
4768         ret.is_owned = false;
4769         return ret;
4770 }
4771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4772         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(owner);
4773         LDKNodeAlias ret_var = CResult_NodeAliasDecodeErrorZ_get_ok(owner_conv);
4774         int64_t ret_ref = 0;
4775         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4776         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4777         return ret_ref;
4778 }
4779
4780 static inline struct LDKDecodeError CResult_NodeAliasDecodeErrorZ_get_err(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
4781 CHECK(!owner->result_ok);
4782         return DecodeError_clone(&*owner->contents.err);
4783 }
4784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4785         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(owner);
4786         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4787         *ret_copy = CResult_NodeAliasDecodeErrorZ_get_err(owner_conv);
4788         int64_t ret_ref = tag_ptr(ret_copy, true);
4789         return ret_ref;
4790 }
4791
4792 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
4793         LDKNodeInfo ret = *owner->contents.result;
4794         ret.is_owned = false;
4795         return ret;
4796 }
4797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4798         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(owner);
4799         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
4800         int64_t ret_ref = 0;
4801         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4802         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4803         return ret_ref;
4804 }
4805
4806 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
4807 CHECK(!owner->result_ok);
4808         return DecodeError_clone(&*owner->contents.err);
4809 }
4810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4811         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(owner);
4812         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4813         *ret_copy = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
4814         int64_t ret_ref = tag_ptr(ret_copy, true);
4815         return ret_ref;
4816 }
4817
4818 static inline struct LDKNetworkGraph CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
4819         LDKNetworkGraph ret = *owner->contents.result;
4820         ret.is_owned = false;
4821         return ret;
4822 }
4823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4824         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(owner);
4825         LDKNetworkGraph ret_var = CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
4826         int64_t ret_ref = 0;
4827         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4828         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4829         return ret_ref;
4830 }
4831
4832 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
4833 CHECK(!owner->result_ok);
4834         return DecodeError_clone(&*owner->contents.err);
4835 }
4836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4837         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(owner);
4838         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4839         *ret_copy = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
4840         int64_t ret_ref = tag_ptr(ret_copy, true);
4841         return ret_ref;
4842 }
4843
4844 static jclass LDKCOption_CVec_NetAddressZZ_Some_class = NULL;
4845 static jmethodID LDKCOption_CVec_NetAddressZZ_Some_meth = NULL;
4846 static jclass LDKCOption_CVec_NetAddressZZ_None_class = NULL;
4847 static jmethodID LDKCOption_CVec_NetAddressZZ_None_meth = NULL;
4848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CVec_1NetAddressZZ_init (JNIEnv *env, jclass clz) {
4849         LDKCOption_CVec_NetAddressZZ_Some_class =
4850                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$Some"));
4851         CHECK(LDKCOption_CVec_NetAddressZZ_Some_class != NULL);
4852         LDKCOption_CVec_NetAddressZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_Some_class, "<init>", "([J)V");
4853         CHECK(LDKCOption_CVec_NetAddressZZ_Some_meth != NULL);
4854         LDKCOption_CVec_NetAddressZZ_None_class =
4855                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$None"));
4856         CHECK(LDKCOption_CVec_NetAddressZZ_None_class != NULL);
4857         LDKCOption_CVec_NetAddressZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_None_class, "<init>", "()V");
4858         CHECK(LDKCOption_CVec_NetAddressZZ_None_meth != NULL);
4859 }
4860 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddressZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4861         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)untag_ptr(ptr);
4862         switch(obj->tag) {
4863                 case LDKCOption_CVec_NetAddressZZ_Some: {
4864                         LDKCVec_NetAddressZ some_var = obj->some;
4865                         int64_tArray some_arr = NULL;
4866                         some_arr = (*env)->NewLongArray(env, some_var.datalen);
4867                         int64_t *some_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, some_arr, NULL);
4868                         for (size_t m = 0; m < some_var.datalen; m++) {
4869                                 int64_t some_conv_12_ref = tag_ptr(&some_var.data[m], false);
4870                                 some_arr_ptr[m] = some_conv_12_ref;
4871                         }
4872                         (*env)->ReleasePrimitiveArrayCritical(env, some_arr, some_arr_ptr, 0);
4873                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_Some_class, LDKCOption_CVec_NetAddressZZ_Some_meth, some_arr);
4874                 }
4875                 case LDKCOption_CVec_NetAddressZZ_None: {
4876                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_None_class, LDKCOption_CVec_NetAddressZZ_None_meth);
4877                 }
4878                 default: abort();
4879         }
4880 }
4881 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4882         LDKDelayedPaymentOutputDescriptor ret = *owner->contents.result;
4883         ret.is_owned = false;
4884         return ret;
4885 }
4886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4887         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
4888         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
4889         int64_t ret_ref = 0;
4890         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4891         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4892         return ret_ref;
4893 }
4894
4895 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4896 CHECK(!owner->result_ok);
4897         return DecodeError_clone(&*owner->contents.err);
4898 }
4899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4900         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
4901         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4902         *ret_copy = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
4903         int64_t ret_ref = tag_ptr(ret_copy, true);
4904         return ret_ref;
4905 }
4906
4907 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4908         LDKStaticPaymentOutputDescriptor ret = *owner->contents.result;
4909         ret.is_owned = false;
4910         return ret;
4911 }
4912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4913         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
4914         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
4915         int64_t ret_ref = 0;
4916         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4917         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4918         return ret_ref;
4919 }
4920
4921 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4922 CHECK(!owner->result_ok);
4923         return DecodeError_clone(&*owner->contents.err);
4924 }
4925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4926         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
4927         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4928         *ret_copy = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
4929         int64_t ret_ref = tag_ptr(ret_copy, true);
4930         return ret_ref;
4931 }
4932
4933 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4934 CHECK(owner->result_ok);
4935         return SpendableOutputDescriptor_clone(&*owner->contents.result);
4936 }
4937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4938         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
4939         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
4940         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
4941         int64_t ret_ref = tag_ptr(ret_copy, true);
4942         return ret_ref;
4943 }
4944
4945 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4946 CHECK(!owner->result_ok);
4947         return DecodeError_clone(&*owner->contents.err);
4948 }
4949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4950         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
4951         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4952         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
4953         int64_t ret_ref = tag_ptr(ret_copy, true);
4954         return ret_ref;
4955 }
4956
4957 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
4958         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
4959         for (size_t i = 0; i < ret.datalen; i++) {
4960                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
4961         }
4962         return ret;
4963 }
4964 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
4965         return owner->a;
4966 }
4967 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4968         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(owner);
4969         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
4970         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form);
4971         return ret_arr;
4972 }
4973
4974 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
4975         return owner->b;
4976 }
4977 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4978         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(owner);
4979         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
4980         jobjectArray ret_arr = NULL;
4981         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
4982         ;
4983         for (size_t i = 0; i < ret_var.datalen; i++) {
4984                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
4985                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
4986                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
4987         }
4988         
4989         return ret_arr;
4990 }
4991
4992 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
4993 CHECK(owner->result_ok);
4994         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
4995 }
4996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4997         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(owner);
4998         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
4999         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
5000         return tag_ptr(ret_conv, true);
5001 }
5002
5003 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
5004 CHECK(!owner->result_ok);
5005         return *owner->contents.err;
5006 }
5007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5008         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(owner);
5009         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
5010 }
5011
5012 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
5013 CHECK(owner->result_ok);
5014         return *owner->contents.result;
5015 }
5016 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5017         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(owner);
5018         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
5019         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form);
5020         return ret_arr;
5021 }
5022
5023 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
5024 CHECK(!owner->result_ok);
5025         return *owner->contents.err;
5026 }
5027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5028         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(owner);
5029         CResult_SignatureNoneZ_get_err(owner_conv);
5030 }
5031
5032 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
5033         return owner->a;
5034 }
5035 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5036         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)untag_ptr(owner);
5037         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
5038         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form);
5039         return ret_arr;
5040 }
5041
5042 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
5043         return owner->b;
5044 }
5045 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5046         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)untag_ptr(owner);
5047         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
5048         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form);
5049         return ret_arr;
5050 }
5051
5052 static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
5053 CHECK(owner->result_ok);
5054         return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
5055 }
5056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5057         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(owner);
5058         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
5059         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
5060         return tag_ptr(ret_conv, true);
5061 }
5062
5063 static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
5064 CHECK(!owner->result_ok);
5065         return *owner->contents.err;
5066 }
5067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5068         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(owner);
5069         CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
5070 }
5071
5072 static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
5073 CHECK(owner->result_ok);
5074         return *owner->contents.result;
5075 }
5076 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5077         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(owner);
5078         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5079         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes);
5080         return ret_arr;
5081 }
5082
5083 static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
5084 CHECK(!owner->result_ok);
5085         return *owner->contents.err;
5086 }
5087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5088         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(owner);
5089         CResult_SecretKeyNoneZ_get_err(owner_conv);
5090 }
5091
5092 static inline struct LDKPublicKey CResult_PublicKeyNoneZ_get_ok(LDKCResult_PublicKeyNoneZ *NONNULL_PTR owner){
5093 CHECK(owner->result_ok);
5094         return *owner->contents.result;
5095 }
5096 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5097         LDKCResult_PublicKeyNoneZ* owner_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(owner);
5098         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
5099         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, CResult_PublicKeyNoneZ_get_ok(owner_conv).compressed_form);
5100         return ret_arr;
5101 }
5102
5103 static inline void CResult_PublicKeyNoneZ_get_err(LDKCResult_PublicKeyNoneZ *NONNULL_PTR owner){
5104 CHECK(!owner->result_ok);
5105         return *owner->contents.err;
5106 }
5107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5108         LDKCResult_PublicKeyNoneZ* owner_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(owner);
5109         CResult_PublicKeyNoneZ_get_err(owner_conv);
5110 }
5111
5112 static jclass LDKCOption_ScalarZ_Some_class = NULL;
5113 static jmethodID LDKCOption_ScalarZ_Some_meth = NULL;
5114 static jclass LDKCOption_ScalarZ_None_class = NULL;
5115 static jmethodID LDKCOption_ScalarZ_None_meth = NULL;
5116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ScalarZ_init (JNIEnv *env, jclass clz) {
5117         LDKCOption_ScalarZ_Some_class =
5118                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ScalarZ$Some"));
5119         CHECK(LDKCOption_ScalarZ_Some_class != NULL);
5120         LDKCOption_ScalarZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ScalarZ_Some_class, "<init>", "(J)V");
5121         CHECK(LDKCOption_ScalarZ_Some_meth != NULL);
5122         LDKCOption_ScalarZ_None_class =
5123                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ScalarZ$None"));
5124         CHECK(LDKCOption_ScalarZ_None_class != NULL);
5125         LDKCOption_ScalarZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ScalarZ_None_class, "<init>", "()V");
5126         CHECK(LDKCOption_ScalarZ_None_meth != NULL);
5127 }
5128 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ScalarZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5129         LDKCOption_ScalarZ *obj = (LDKCOption_ScalarZ*)untag_ptr(ptr);
5130         switch(obj->tag) {
5131                 case LDKCOption_ScalarZ_Some: {
5132                         LDKBigEndianScalar* some_ref = &obj->some;
5133                         return (*env)->NewObject(env, LDKCOption_ScalarZ_Some_class, LDKCOption_ScalarZ_Some_meth, tag_ptr(some_ref, false));
5134                 }
5135                 case LDKCOption_ScalarZ_None: {
5136                         return (*env)->NewObject(env, LDKCOption_ScalarZ_None_class, LDKCOption_ScalarZ_None_meth);
5137                 }
5138                 default: abort();
5139         }
5140 }
5141 static inline struct LDKThirtyTwoBytes CResult_SharedSecretNoneZ_get_ok(LDKCResult_SharedSecretNoneZ *NONNULL_PTR owner){
5142 CHECK(owner->result_ok);
5143         return ThirtyTwoBytes_clone(&*owner->contents.result);
5144 }
5145 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5146         LDKCResult_SharedSecretNoneZ* owner_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(owner);
5147         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5148         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SharedSecretNoneZ_get_ok(owner_conv).data);
5149         return ret_arr;
5150 }
5151
5152 static inline void CResult_SharedSecretNoneZ_get_err(LDKCResult_SharedSecretNoneZ *NONNULL_PTR owner){
5153 CHECK(!owner->result_ok);
5154         return *owner->contents.err;
5155 }
5156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5157         LDKCResult_SharedSecretNoneZ* owner_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(owner);
5158         CResult_SharedSecretNoneZ_get_err(owner_conv);
5159 }
5160
5161 typedef struct LDKBaseSign_JCalls {
5162         atomic_size_t refcnt;
5163         JavaVM *vm;
5164         jweak o;
5165         jmethodID get_per_commitment_point_meth;
5166         jmethodID release_commitment_secret_meth;
5167         jmethodID validate_holder_commitment_meth;
5168         jmethodID channel_keys_id_meth;
5169         jmethodID sign_counterparty_commitment_meth;
5170         jmethodID validate_counterparty_revocation_meth;
5171         jmethodID sign_holder_commitment_and_htlcs_meth;
5172         jmethodID sign_justice_revoked_output_meth;
5173         jmethodID sign_justice_revoked_htlc_meth;
5174         jmethodID sign_counterparty_htlc_transaction_meth;
5175         jmethodID sign_closing_transaction_meth;
5176         jmethodID sign_holder_anchor_input_meth;
5177         jmethodID sign_channel_announcement_meth;
5178         jmethodID ready_channel_meth;
5179 } LDKBaseSign_JCalls;
5180 static void LDKBaseSign_JCalls_free(void* this_arg) {
5181         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5182         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5183                 JNIEnv *env;
5184                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5185                 if (get_jenv_res == JNI_EDETACHED) {
5186                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5187                 } else {
5188                         DO_ASSERT(get_jenv_res == JNI_OK);
5189                 }
5190                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5191                 if (get_jenv_res == JNI_EDETACHED) {
5192                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5193                 }
5194                 FREE(j_calls);
5195         }
5196 }
5197 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
5198         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5199         JNIEnv *env;
5200         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5201         if (get_jenv_res == JNI_EDETACHED) {
5202                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5203         } else {
5204                 DO_ASSERT(get_jenv_res == JNI_OK);
5205         }
5206         int64_t idx_conv = idx;
5207         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5208         CHECK(obj != NULL);
5209         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx_conv);
5210         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5211                 (*env)->ExceptionDescribe(env);
5212                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
5213         }
5214         LDKPublicKey ret_ref;
5215         CHECK((*env)->GetArrayLength(env, ret) == 33);
5216         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
5217         if (get_jenv_res == JNI_EDETACHED) {
5218                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5219         }
5220         return ret_ref;
5221 }
5222 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
5223         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5224         JNIEnv *env;
5225         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5226         if (get_jenv_res == JNI_EDETACHED) {
5227                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5228         } else {
5229                 DO_ASSERT(get_jenv_res == JNI_OK);
5230         }
5231         int64_t idx_conv = idx;
5232         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5233         CHECK(obj != NULL);
5234         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx_conv);
5235         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5236                 (*env)->ExceptionDescribe(env);
5237                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
5238         }
5239         LDKThirtyTwoBytes ret_ref;
5240         CHECK((*env)->GetArrayLength(env, ret) == 32);
5241         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
5242         if (get_jenv_res == JNI_EDETACHED) {
5243                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5244         }
5245         return ret_ref;
5246 }
5247 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
5248         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5249         JNIEnv *env;
5250         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5251         if (get_jenv_res == JNI_EDETACHED) {
5252                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5253         } else {
5254                 DO_ASSERT(get_jenv_res == JNI_OK);
5255         }
5256         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
5257         int64_t holder_tx_ref = 0;
5258         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
5259         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
5260         holder_tx_ref = tag_ptr(holder_tx_var.inner, holder_tx_var.is_owned);
5261         LDKCVec_PaymentPreimageZ preimages_var = preimages;
5262         jobjectArray preimages_arr = NULL;
5263         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
5264         ;
5265         for (size_t i = 0; i < preimages_var.datalen; i++) {
5266                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
5267                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
5268                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
5269         }
5270         
5271         FREE(preimages_var.data);
5272         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5273         CHECK(obj != NULL);
5274         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_holder_commitment_meth, holder_tx_ref, preimages_arr);
5275         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5276                 (*env)->ExceptionDescribe(env);
5277                 (*env)->FatalError(env, "A call to validate_holder_commitment in LDKBaseSign from rust threw an exception.");
5278         }
5279         void* ret_ptr = untag_ptr(ret);
5280         CHECK_ACCESS(ret_ptr);
5281         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
5282         FREE(untag_ptr(ret));
5283         if (get_jenv_res == JNI_EDETACHED) {
5284                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5285         }
5286         return ret_conv;
5287 }
5288 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
5289         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5290         JNIEnv *env;
5291         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5292         if (get_jenv_res == JNI_EDETACHED) {
5293                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5294         } else {
5295                 DO_ASSERT(get_jenv_res == JNI_OK);
5296         }
5297         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5298         CHECK(obj != NULL);
5299         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
5300         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5301                 (*env)->ExceptionDescribe(env);
5302                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
5303         }
5304         LDKThirtyTwoBytes ret_ref;
5305         CHECK((*env)->GetArrayLength(env, ret) == 32);
5306         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
5307         if (get_jenv_res == JNI_EDETACHED) {
5308                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5309         }
5310         return ret_ref;
5311 }
5312 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
5313         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5314         JNIEnv *env;
5315         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5316         if (get_jenv_res == JNI_EDETACHED) {
5317                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5318         } else {
5319                 DO_ASSERT(get_jenv_res == JNI_OK);
5320         }
5321         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
5322         int64_t commitment_tx_ref = 0;
5323         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
5324         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
5325         commitment_tx_ref = tag_ptr(commitment_tx_var.inner, commitment_tx_var.is_owned);
5326         LDKCVec_PaymentPreimageZ preimages_var = preimages;
5327         jobjectArray preimages_arr = NULL;
5328         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
5329         ;
5330         for (size_t i = 0; i < preimages_var.datalen; i++) {
5331                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
5332                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
5333                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
5334         }
5335         
5336         FREE(preimages_var.data);
5337         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5338         CHECK(obj != NULL);
5339         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref, preimages_arr);
5340         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5341                 (*env)->ExceptionDescribe(env);
5342                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
5343         }
5344         void* ret_ptr = untag_ptr(ret);
5345         CHECK_ACCESS(ret_ptr);
5346         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
5347         FREE(untag_ptr(ret));
5348         if (get_jenv_res == JNI_EDETACHED) {
5349                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5350         }
5351         return ret_conv;
5352 }
5353 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
5354         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5355         JNIEnv *env;
5356         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5357         if (get_jenv_res == JNI_EDETACHED) {
5358                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5359         } else {
5360                 DO_ASSERT(get_jenv_res == JNI_OK);
5361         }
5362         int64_t idx_conv = idx;
5363         int8_tArray secret_arr = (*env)->NewByteArray(env, 32);
5364         (*env)->SetByteArrayRegion(env, secret_arr, 0, 32, *secret);
5365         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5366         CHECK(obj != NULL);
5367         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_counterparty_revocation_meth, idx_conv, secret_arr);
5368         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5369                 (*env)->ExceptionDescribe(env);
5370                 (*env)->FatalError(env, "A call to validate_counterparty_revocation in LDKBaseSign from rust threw an exception.");
5371         }
5372         void* ret_ptr = untag_ptr(ret);
5373         CHECK_ACCESS(ret_ptr);
5374         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
5375         FREE(untag_ptr(ret));
5376         if (get_jenv_res == JNI_EDETACHED) {
5377                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5378         }
5379         return ret_conv;
5380 }
5381 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
5382         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5383         JNIEnv *env;
5384         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5385         if (get_jenv_res == JNI_EDETACHED) {
5386                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5387         } else {
5388                 DO_ASSERT(get_jenv_res == JNI_OK);
5389         }
5390         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
5391         int64_t commitment_tx_ref = 0;
5392         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
5393         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
5394         commitment_tx_ref = tag_ptr(commitment_tx_var.inner, commitment_tx_var.is_owned);
5395         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5396         CHECK(obj != NULL);
5397         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
5398         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5399                 (*env)->ExceptionDescribe(env);
5400                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
5401         }
5402         void* ret_ptr = untag_ptr(ret);
5403         CHECK_ACCESS(ret_ptr);
5404         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
5405         FREE(untag_ptr(ret));
5406         if (get_jenv_res == JNI_EDETACHED) {
5407                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5408         }
5409         return ret_conv;
5410 }
5411 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]) {
5412         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5413         JNIEnv *env;
5414         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5415         if (get_jenv_res == JNI_EDETACHED) {
5416                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5417         } else {
5418                 DO_ASSERT(get_jenv_res == JNI_OK);
5419         }
5420         LDKTransaction justice_tx_var = justice_tx;
5421         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
5422         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
5423         Transaction_free(justice_tx_var);
5424         int64_t input_conv = input;
5425         int64_t amount_conv = amount;
5426         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
5427         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
5428         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5429         CHECK(obj != NULL);
5430         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);
5431         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5432                 (*env)->ExceptionDescribe(env);
5433                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
5434         }
5435         void* ret_ptr = untag_ptr(ret);
5436         CHECK_ACCESS(ret_ptr);
5437         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5438         FREE(untag_ptr(ret));
5439         if (get_jenv_res == JNI_EDETACHED) {
5440                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5441         }
5442         return ret_conv;
5443 }
5444 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) {
5445         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5446         JNIEnv *env;
5447         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5448         if (get_jenv_res == JNI_EDETACHED) {
5449                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5450         } else {
5451                 DO_ASSERT(get_jenv_res == JNI_OK);
5452         }
5453         LDKTransaction justice_tx_var = justice_tx;
5454         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
5455         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
5456         Transaction_free(justice_tx_var);
5457         int64_t input_conv = input;
5458         int64_t amount_conv = amount;
5459         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
5460         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
5461         LDKHTLCOutputInCommitment htlc_var = *htlc;
5462         int64_t htlc_ref = 0;
5463         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
5464         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
5465         htlc_ref = tag_ptr(htlc_var.inner, htlc_var.is_owned);
5466         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5467         CHECK(obj != NULL);
5468         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);
5469         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5470                 (*env)->ExceptionDescribe(env);
5471                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
5472         }
5473         void* ret_ptr = untag_ptr(ret);
5474         CHECK_ACCESS(ret_ptr);
5475         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5476         FREE(untag_ptr(ret));
5477         if (get_jenv_res == JNI_EDETACHED) {
5478                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5479         }
5480         return ret_conv;
5481 }
5482 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) {
5483         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5484         JNIEnv *env;
5485         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5486         if (get_jenv_res == JNI_EDETACHED) {
5487                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5488         } else {
5489                 DO_ASSERT(get_jenv_res == JNI_OK);
5490         }
5491         LDKTransaction htlc_tx_var = htlc_tx;
5492         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
5493         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
5494         Transaction_free(htlc_tx_var);
5495         int64_t input_conv = input;
5496         int64_t amount_conv = amount;
5497         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
5498         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
5499         LDKHTLCOutputInCommitment htlc_var = *htlc;
5500         int64_t htlc_ref = 0;
5501         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
5502         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
5503         htlc_ref = tag_ptr(htlc_var.inner, htlc_var.is_owned);
5504         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5505         CHECK(obj != NULL);
5506         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);
5507         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5508                 (*env)->ExceptionDescribe(env);
5509                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
5510         }
5511         void* ret_ptr = untag_ptr(ret);
5512         CHECK_ACCESS(ret_ptr);
5513         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5514         FREE(untag_ptr(ret));
5515         if (get_jenv_res == JNI_EDETACHED) {
5516                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5517         }
5518         return ret_conv;
5519 }
5520 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
5521         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5522         JNIEnv *env;
5523         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5524         if (get_jenv_res == JNI_EDETACHED) {
5525                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5526         } else {
5527                 DO_ASSERT(get_jenv_res == JNI_OK);
5528         }
5529         LDKClosingTransaction closing_tx_var = *closing_tx;
5530         int64_t closing_tx_ref = 0;
5531         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
5532         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
5533         closing_tx_ref = tag_ptr(closing_tx_var.inner, closing_tx_var.is_owned);
5534         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5535         CHECK(obj != NULL);
5536         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
5537         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5538                 (*env)->ExceptionDescribe(env);
5539                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
5540         }
5541         void* ret_ptr = untag_ptr(ret);
5542         CHECK_ACCESS(ret_ptr);
5543         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5544         FREE(untag_ptr(ret));
5545         if (get_jenv_res == JNI_EDETACHED) {
5546                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5547         }
5548         return ret_conv;
5549 }
5550 LDKCResult_SignatureNoneZ sign_holder_anchor_input_LDKBaseSign_jcall(const void* this_arg, LDKTransaction anchor_tx, uintptr_t input) {
5551         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5552         JNIEnv *env;
5553         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5554         if (get_jenv_res == JNI_EDETACHED) {
5555                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5556         } else {
5557                 DO_ASSERT(get_jenv_res == JNI_OK);
5558         }
5559         LDKTransaction anchor_tx_var = anchor_tx;
5560         int8_tArray anchor_tx_arr = (*env)->NewByteArray(env, anchor_tx_var.datalen);
5561         (*env)->SetByteArrayRegion(env, anchor_tx_arr, 0, anchor_tx_var.datalen, anchor_tx_var.data);
5562         Transaction_free(anchor_tx_var);
5563         int64_t input_conv = input;
5564         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5565         CHECK(obj != NULL);
5566         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_anchor_input_meth, anchor_tx_arr, input_conv);
5567         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5568                 (*env)->ExceptionDescribe(env);
5569                 (*env)->FatalError(env, "A call to sign_holder_anchor_input in LDKBaseSign from rust threw an exception.");
5570         }
5571         void* ret_ptr = untag_ptr(ret);
5572         CHECK_ACCESS(ret_ptr);
5573         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5574         FREE(untag_ptr(ret));
5575         if (get_jenv_res == JNI_EDETACHED) {
5576                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5577         }
5578         return ret_conv;
5579 }
5580 LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
5581         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5582         JNIEnv *env;
5583         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5584         if (get_jenv_res == JNI_EDETACHED) {
5585                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5586         } else {
5587                 DO_ASSERT(get_jenv_res == JNI_OK);
5588         }
5589         LDKUnsignedChannelAnnouncement msg_var = *msg;
5590         int64_t msg_ref = 0;
5591         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
5592         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
5593         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
5594         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5595         CHECK(obj != NULL);
5596         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
5597         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5598                 (*env)->ExceptionDescribe(env);
5599                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
5600         }
5601         void* ret_ptr = untag_ptr(ret);
5602         CHECK_ACCESS(ret_ptr);
5603         LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
5604         FREE(untag_ptr(ret));
5605         if (get_jenv_res == JNI_EDETACHED) {
5606                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5607         }
5608         return ret_conv;
5609 }
5610 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
5611         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5612         JNIEnv *env;
5613         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5614         if (get_jenv_res == JNI_EDETACHED) {
5615                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5616         } else {
5617                 DO_ASSERT(get_jenv_res == JNI_OK);
5618         }
5619         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
5620         int64_t channel_parameters_ref = 0;
5621         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
5622         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
5623         channel_parameters_ref = tag_ptr(channel_parameters_var.inner, channel_parameters_var.is_owned);
5624         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5625         CHECK(obj != NULL);
5626         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
5627         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5628                 (*env)->ExceptionDescribe(env);
5629                 (*env)->FatalError(env, "A call to ready_channel in LDKBaseSign from rust threw an exception.");
5630         }
5631         if (get_jenv_res == JNI_EDETACHED) {
5632                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5633         }
5634 }
5635 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
5636         jclass c = (*env)->GetObjectClass(env, o);
5637         CHECK(c != NULL);
5638         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
5639         atomic_init(&calls->refcnt, 1);
5640         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5641         calls->o = (*env)->NewWeakGlobalRef(env, o);
5642         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
5643         CHECK(calls->get_per_commitment_point_meth != NULL);
5644         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
5645         CHECK(calls->release_commitment_secret_meth != NULL);
5646         calls->validate_holder_commitment_meth = (*env)->GetMethodID(env, c, "validate_holder_commitment", "(J[[B)J");
5647         CHECK(calls->validate_holder_commitment_meth != NULL);
5648         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
5649         CHECK(calls->channel_keys_id_meth != NULL);
5650         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J[[B)J");
5651         CHECK(calls->sign_counterparty_commitment_meth != NULL);
5652         calls->validate_counterparty_revocation_meth = (*env)->GetMethodID(env, c, "validate_counterparty_revocation", "(J[B)J");
5653         CHECK(calls->validate_counterparty_revocation_meth != NULL);
5654         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
5655         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
5656         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
5657         CHECK(calls->sign_justice_revoked_output_meth != NULL);
5658         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
5659         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
5660         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
5661         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
5662         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
5663         CHECK(calls->sign_closing_transaction_meth != NULL);
5664         calls->sign_holder_anchor_input_meth = (*env)->GetMethodID(env, c, "sign_holder_anchor_input", "([BJ)J");
5665         CHECK(calls->sign_holder_anchor_input_meth != NULL);
5666         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
5667         CHECK(calls->sign_channel_announcement_meth != NULL);
5668         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
5669         CHECK(calls->ready_channel_meth != NULL);
5670
5671         LDKChannelPublicKeys pubkeys_conv;
5672         pubkeys_conv.inner = untag_ptr(pubkeys);
5673         pubkeys_conv.is_owned = ptr_is_owned(pubkeys);
5674         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
5675
5676         LDKBaseSign ret = {
5677                 .this_arg = (void*) calls,
5678                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
5679                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
5680                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
5681                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
5682                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
5683                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
5684                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
5685                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
5686                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
5687                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
5688                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
5689                 .sign_holder_anchor_input = sign_holder_anchor_input_LDKBaseSign_jcall,
5690                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
5691                 .ready_channel = ready_channel_LDKBaseSign_jcall,
5692                 .free = LDKBaseSign_JCalls_free,
5693                 .pubkeys = pubkeys_conv,
5694                 .set_pubkeys = NULL,
5695         };
5696         return ret;
5697 }
5698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
5699         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
5700         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
5701         return tag_ptr(res_ptr, true);
5702 }
5703 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) {
5704         void* this_arg_ptr = untag_ptr(this_arg);
5705         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5706         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5707         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
5708         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
5709         return ret_arr;
5710 }
5711
5712 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
5713         void* this_arg_ptr = untag_ptr(this_arg);
5714         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5715         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5716         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5717         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
5718         return ret_arr;
5719 }
5720
5721 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) {
5722         void* this_arg_ptr = untag_ptr(this_arg);
5723         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5724         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5725         LDKHolderCommitmentTransaction holder_tx_conv;
5726         holder_tx_conv.inner = untag_ptr(holder_tx);
5727         holder_tx_conv.is_owned = ptr_is_owned(holder_tx);
5728         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
5729         holder_tx_conv.is_owned = false;
5730         LDKCVec_PaymentPreimageZ preimages_constr;
5731         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
5732         if (preimages_constr.datalen > 0)
5733                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
5734         else
5735                 preimages_constr.data = NULL;
5736         for (size_t i = 0; i < preimages_constr.datalen; i++) {
5737                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
5738                 LDKThirtyTwoBytes preimages_conv_8_ref;
5739                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
5740                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
5741                 preimages_constr.data[i] = preimages_conv_8_ref;
5742         }
5743         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
5744         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
5745         return tag_ptr(ret_conv, true);
5746 }
5747
5748 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
5749         void* this_arg_ptr = untag_ptr(this_arg);
5750         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5751         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5752         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5753         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
5754         return ret_arr;
5755 }
5756
5757 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) {
5758         void* this_arg_ptr = untag_ptr(this_arg);
5759         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5760         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5761         LDKCommitmentTransaction commitment_tx_conv;
5762         commitment_tx_conv.inner = untag_ptr(commitment_tx);
5763         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
5764         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
5765         commitment_tx_conv.is_owned = false;
5766         LDKCVec_PaymentPreimageZ preimages_constr;
5767         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
5768         if (preimages_constr.datalen > 0)
5769                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
5770         else
5771                 preimages_constr.data = NULL;
5772         for (size_t i = 0; i < preimages_constr.datalen; i++) {
5773                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
5774                 LDKThirtyTwoBytes preimages_conv_8_ref;
5775                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
5776                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
5777                 preimages_constr.data[i] = preimages_conv_8_ref;
5778         }
5779         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
5780         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
5781         return tag_ptr(ret_conv, true);
5782 }
5783
5784 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) {
5785         void* this_arg_ptr = untag_ptr(this_arg);
5786         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5787         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5788         unsigned char secret_arr[32];
5789         CHECK((*env)->GetArrayLength(env, secret) == 32);
5790         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr);
5791         unsigned char (*secret_ref)[32] = &secret_arr;
5792         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
5793         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
5794         return tag_ptr(ret_conv, true);
5795 }
5796
5797 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) {
5798         void* this_arg_ptr = untag_ptr(this_arg);
5799         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5800         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5801         LDKHolderCommitmentTransaction commitment_tx_conv;
5802         commitment_tx_conv.inner = untag_ptr(commitment_tx);
5803         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
5804         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
5805         commitment_tx_conv.is_owned = false;
5806         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
5807         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
5808         return tag_ptr(ret_conv, true);
5809 }
5810
5811 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) {
5812         void* this_arg_ptr = untag_ptr(this_arg);
5813         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5814         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5815         LDKTransaction justice_tx_ref;
5816         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
5817         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
5818         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
5819         justice_tx_ref.data_is_owned = true;
5820         unsigned char per_commitment_key_arr[32];
5821         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
5822         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
5823         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
5824         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5825         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
5826         return tag_ptr(ret_conv, true);
5827 }
5828
5829 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) {
5830         void* this_arg_ptr = untag_ptr(this_arg);
5831         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5832         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5833         LDKTransaction justice_tx_ref;
5834         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
5835         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
5836         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
5837         justice_tx_ref.data_is_owned = true;
5838         unsigned char per_commitment_key_arr[32];
5839         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
5840         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
5841         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
5842         LDKHTLCOutputInCommitment htlc_conv;
5843         htlc_conv.inner = untag_ptr(htlc);
5844         htlc_conv.is_owned = ptr_is_owned(htlc);
5845         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
5846         htlc_conv.is_owned = false;
5847         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5848         *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);
5849         return tag_ptr(ret_conv, true);
5850 }
5851
5852 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) {
5853         void* this_arg_ptr = untag_ptr(this_arg);
5854         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5855         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5856         LDKTransaction htlc_tx_ref;
5857         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
5858         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
5859         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
5860         htlc_tx_ref.data_is_owned = true;
5861         LDKPublicKey per_commitment_point_ref;
5862         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
5863         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
5864         LDKHTLCOutputInCommitment htlc_conv;
5865         htlc_conv.inner = untag_ptr(htlc);
5866         htlc_conv.is_owned = ptr_is_owned(htlc);
5867         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
5868         htlc_conv.is_owned = false;
5869         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5870         *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);
5871         return tag_ptr(ret_conv, true);
5872 }
5873
5874 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) {
5875         void* this_arg_ptr = untag_ptr(this_arg);
5876         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5877         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5878         LDKClosingTransaction closing_tx_conv;
5879         closing_tx_conv.inner = untag_ptr(closing_tx);
5880         closing_tx_conv.is_owned = ptr_is_owned(closing_tx);
5881         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
5882         closing_tx_conv.is_owned = false;
5883         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5884         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
5885         return tag_ptr(ret_conv, true);
5886 }
5887
5888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1holder_1anchor_1input(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray anchor_tx, int64_t input) {
5889         void* this_arg_ptr = untag_ptr(this_arg);
5890         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5891         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5892         LDKTransaction anchor_tx_ref;
5893         anchor_tx_ref.datalen = (*env)->GetArrayLength(env, anchor_tx);
5894         anchor_tx_ref.data = MALLOC(anchor_tx_ref.datalen, "LDKTransaction Bytes");
5895         (*env)->GetByteArrayRegion(env, anchor_tx, 0, anchor_tx_ref.datalen, anchor_tx_ref.data);
5896         anchor_tx_ref.data_is_owned = true;
5897         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5898         *ret_conv = (this_arg_conv->sign_holder_anchor_input)(this_arg_conv->this_arg, anchor_tx_ref, input);
5899         return tag_ptr(ret_conv, true);
5900 }
5901
5902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
5903         void* this_arg_ptr = untag_ptr(this_arg);
5904         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5905         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5906         LDKUnsignedChannelAnnouncement msg_conv;
5907         msg_conv.inner = untag_ptr(msg);
5908         msg_conv.is_owned = ptr_is_owned(msg);
5909         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
5910         msg_conv.is_owned = false;
5911         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
5912         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
5913         return tag_ptr(ret_conv, true);
5914 }
5915
5916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
5917         void* this_arg_ptr = untag_ptr(this_arg);
5918         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5919         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5920         LDKChannelTransactionParameters channel_parameters_conv;
5921         channel_parameters_conv.inner = untag_ptr(channel_parameters);
5922         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
5923         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
5924         channel_parameters_conv.is_owned = false;
5925         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
5926 }
5927
5928 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
5929         if (this_arg->set_pubkeys != NULL)
5930                 this_arg->set_pubkeys(this_arg);
5931         return this_arg->pubkeys;
5932 }
5933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
5934         void* this_arg_ptr = untag_ptr(this_arg);
5935         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5936         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5937         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
5938         int64_t ret_ref = 0;
5939         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5940         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5941         return ret_ref;
5942 }
5943
5944 typedef struct LDKSign_JCalls {
5945         atomic_size_t refcnt;
5946         JavaVM *vm;
5947         jweak o;
5948         LDKBaseSign_JCalls* BaseSign;
5949         jmethodID write_meth;
5950 } LDKSign_JCalls;
5951 static void LDKSign_JCalls_free(void* this_arg) {
5952         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
5953         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5954                 JNIEnv *env;
5955                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5956                 if (get_jenv_res == JNI_EDETACHED) {
5957                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5958                 } else {
5959                         DO_ASSERT(get_jenv_res == JNI_OK);
5960                 }
5961                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5962                 if (get_jenv_res == JNI_EDETACHED) {
5963                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5964                 }
5965                 FREE(j_calls);
5966         }
5967 }
5968 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
5969         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
5970         JNIEnv *env;
5971         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5972         if (get_jenv_res == JNI_EDETACHED) {
5973                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5974         } else {
5975                 DO_ASSERT(get_jenv_res == JNI_OK);
5976         }
5977         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5978         CHECK(obj != NULL);
5979         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
5980         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5981                 (*env)->ExceptionDescribe(env);
5982                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
5983         }
5984         LDKCVec_u8Z ret_ref;
5985         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
5986         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5987         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
5988         if (get_jenv_res == JNI_EDETACHED) {
5989                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5990         }
5991         return ret_ref;
5992 }
5993 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
5994         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
5995         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5996         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
5997 }
5998 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
5999         jclass c = (*env)->GetObjectClass(env, o);
6000         CHECK(c != NULL);
6001         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
6002         atomic_init(&calls->refcnt, 1);
6003         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6004         calls->o = (*env)->NewWeakGlobalRef(env, o);
6005         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
6006         CHECK(calls->write_meth != NULL);
6007
6008         LDKChannelPublicKeys pubkeys_conv;
6009         pubkeys_conv.inner = untag_ptr(pubkeys);
6010         pubkeys_conv.is_owned = ptr_is_owned(pubkeys);
6011         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
6012
6013         LDKSign ret = {
6014                 .this_arg = (void*) calls,
6015                 .write = write_LDKSign_jcall,
6016                 .cloned = LDKSign_JCalls_cloned,
6017                 .free = LDKSign_JCalls_free,
6018                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
6019         };
6020         calls->BaseSign = ret.BaseSign.this_arg;
6021         return ret;
6022 }
6023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
6024         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
6025         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
6026         return tag_ptr(res_ptr, true);
6027 }
6028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIEnv *env, jclass clz, int64_t arg) {
6029         LDKSign *inp = (LDKSign *)untag_ptr(arg);
6030         return tag_ptr(&inp->BaseSign, false);
6031 }
6032 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
6033         void* this_arg_ptr = untag_ptr(this_arg);
6034         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6035         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
6036         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
6037         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6038         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6039         CVec_u8Z_free(ret_var);
6040         return ret_arr;
6041 }
6042
6043 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
6044 CHECK(owner->result_ok);
6045         return Sign_clone(&*owner->contents.result);
6046 }
6047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6048         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(owner);
6049         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
6050         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
6051         return tag_ptr(ret_ret, true);
6052 }
6053
6054 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
6055 CHECK(!owner->result_ok);
6056         return DecodeError_clone(&*owner->contents.err);
6057 }
6058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6059         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(owner);
6060         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6061         *ret_copy = CResult_SignDecodeErrorZ_get_err(owner_conv);
6062         int64_t ret_ref = tag_ptr(ret_copy, true);
6063         return ret_ref;
6064 }
6065
6066 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
6067 CHECK(owner->result_ok);
6068         return *owner->contents.result;
6069 }
6070 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6071         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(owner);
6072         int8_tArray ret_arr = (*env)->NewByteArray(env, 68);
6073         (*env)->SetByteArrayRegion(env, ret_arr, 0, 68, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form);
6074         return ret_arr;
6075 }
6076
6077 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
6078 CHECK(!owner->result_ok);
6079         return *owner->contents.err;
6080 }
6081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6082         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(owner);
6083         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
6084 }
6085
6086 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
6087         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
6088         for (size_t i = 0; i < ret.datalen; i++) {
6089                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
6090         }
6091         return ret;
6092 }
6093 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
6094 CHECK(owner->result_ok);
6095         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
6096 }
6097 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6098         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(owner);
6099         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
6100         jobjectArray ret_arr = NULL;
6101         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
6102         ;
6103         for (size_t i = 0; i < ret_var.datalen; i++) {
6104                 LDKCVec_u8Z ret_conv_8_var = ret_var.data[i];
6105                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
6106                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
6107                 CVec_u8Z_free(ret_conv_8_var);
6108                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
6109         }
6110         
6111         FREE(ret_var.data);
6112         return ret_arr;
6113 }
6114
6115 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
6116 CHECK(!owner->result_ok);
6117         return *owner->contents.err;
6118 }
6119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6120         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(owner);
6121         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
6122 }
6123
6124 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
6125         LDKInMemorySigner ret = *owner->contents.result;
6126         ret.is_owned = false;
6127         return ret;
6128 }
6129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6130         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(owner);
6131         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
6132         int64_t ret_ref = 0;
6133         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6134         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6135         return ret_ref;
6136 }
6137
6138 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
6139 CHECK(!owner->result_ok);
6140         return DecodeError_clone(&*owner->contents.err);
6141 }
6142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6143         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(owner);
6144         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6145         *ret_copy = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
6146         int64_t ret_ref = tag_ptr(ret_copy, true);
6147         return ret_ref;
6148 }
6149
6150 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
6151         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
6152         for (size_t i = 0; i < ret.datalen; i++) {
6153                 ret.data[i] = TxOut_clone(&orig->data[i]);
6154         }
6155         return ret;
6156 }
6157 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
6158 CHECK(owner->result_ok);
6159         return *owner->contents.result;
6160 }
6161 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6162         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(owner);
6163         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
6164         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6165         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6166         return ret_arr;
6167 }
6168
6169 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
6170 CHECK(!owner->result_ok);
6171         return *owner->contents.err;
6172 }
6173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6174         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(owner);
6175         CResult_TransactionNoneZ_get_err(owner_conv);
6176 }
6177
6178 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
6179         return ThirtyTwoBytes_clone(&owner->a);
6180 }
6181 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6182         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(owner);
6183         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6184         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data);
6185         return ret_arr;
6186 }
6187
6188 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
6189         LDKChannelMonitor ret = owner->b;
6190         ret.is_owned = false;
6191         return ret;
6192 }
6193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6194         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(owner);
6195         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
6196         int64_t ret_ref = 0;
6197         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6198         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6199         return ret_ref;
6200 }
6201
6202 static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
6203         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
6204         for (size_t i = 0; i < ret.datalen; i++) {
6205                 ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
6206         }
6207         return ret;
6208 }
6209 static inline struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
6210 CHECK(owner->result_ok);
6211         return CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(&*owner->contents.result);
6212 }
6213 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6214         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(owner);
6215         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret_var = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(owner_conv);
6216         int64_tArray ret_arr = NULL;
6217         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6218         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6219         for (size_t j = 0; j < ret_var.datalen; j++) {
6220                 LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
6221                 *ret_conv_35_conv = ret_var.data[j];
6222                 ret_arr_ptr[j] = tag_ptr(ret_conv_35_conv, true);
6223         }
6224         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6225         FREE(ret_var.data);
6226         return ret_arr;
6227 }
6228
6229 static inline enum LDKIOError CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
6230 CHECK(!owner->result_ok);
6231         return *owner->contents.err;
6232 }
6233 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6234         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(owner);
6235         jclass ret_conv = LDKIOError_to_java(env, CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(owner_conv));
6236         return ret_conv;
6237 }
6238
6239 static jclass LDKCOption_u16Z_Some_class = NULL;
6240 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
6241 static jclass LDKCOption_u16Z_None_class = NULL;
6242 static jmethodID LDKCOption_u16Z_None_meth = NULL;
6243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
6244         LDKCOption_u16Z_Some_class =
6245                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$Some"));
6246         CHECK(LDKCOption_u16Z_Some_class != NULL);
6247         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
6248         CHECK(LDKCOption_u16Z_Some_meth != NULL);
6249         LDKCOption_u16Z_None_class =
6250                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$None"));
6251         CHECK(LDKCOption_u16Z_None_class != NULL);
6252         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
6253         CHECK(LDKCOption_u16Z_None_meth != NULL);
6254 }
6255 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6256         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)untag_ptr(ptr);
6257         switch(obj->tag) {
6258                 case LDKCOption_u16Z_Some: {
6259                         int16_t some_conv = obj->some;
6260                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, some_conv);
6261                 }
6262                 case LDKCOption_u16Z_None: {
6263                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
6264                 }
6265                 default: abort();
6266         }
6267 }
6268 static jclass LDKAPIError_APIMisuseError_class = NULL;
6269 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
6270 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
6271 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
6272 static jclass LDKAPIError_RouteError_class = NULL;
6273 static jmethodID LDKAPIError_RouteError_meth = NULL;
6274 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
6275 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
6276 static jclass LDKAPIError_MonitorUpdateInProgress_class = NULL;
6277 static jmethodID LDKAPIError_MonitorUpdateInProgress_meth = NULL;
6278 static jclass LDKAPIError_IncompatibleShutdownScript_class = NULL;
6279 static jmethodID LDKAPIError_IncompatibleShutdownScript_meth = NULL;
6280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
6281         LDKAPIError_APIMisuseError_class =
6282                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$APIMisuseError"));
6283         CHECK(LDKAPIError_APIMisuseError_class != NULL);
6284         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
6285         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
6286         LDKAPIError_FeeRateTooHigh_class =
6287                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh"));
6288         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
6289         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
6290         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
6291         LDKAPIError_RouteError_class =
6292                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$RouteError"));
6293         CHECK(LDKAPIError_RouteError_class != NULL);
6294         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
6295         CHECK(LDKAPIError_RouteError_meth != NULL);
6296         LDKAPIError_ChannelUnavailable_class =
6297                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$ChannelUnavailable"));
6298         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
6299         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
6300         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
6301         LDKAPIError_MonitorUpdateInProgress_class =
6302                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$MonitorUpdateInProgress"));
6303         CHECK(LDKAPIError_MonitorUpdateInProgress_class != NULL);
6304         LDKAPIError_MonitorUpdateInProgress_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateInProgress_class, "<init>", "()V");
6305         CHECK(LDKAPIError_MonitorUpdateInProgress_meth != NULL);
6306         LDKAPIError_IncompatibleShutdownScript_class =
6307                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$IncompatibleShutdownScript"));
6308         CHECK(LDKAPIError_IncompatibleShutdownScript_class != NULL);
6309         LDKAPIError_IncompatibleShutdownScript_meth = (*env)->GetMethodID(env, LDKAPIError_IncompatibleShutdownScript_class, "<init>", "(J)V");
6310         CHECK(LDKAPIError_IncompatibleShutdownScript_meth != NULL);
6311 }
6312 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6313         LDKAPIError *obj = (LDKAPIError*)untag_ptr(ptr);
6314         switch(obj->tag) {
6315                 case LDKAPIError_APIMisuseError: {
6316                         LDKStr err_str = obj->api_misuse_error.err;
6317                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
6318                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
6319                 }
6320                 case LDKAPIError_FeeRateTooHigh: {
6321                         LDKStr err_str = obj->fee_rate_too_high.err;
6322                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
6323                         int32_t feerate_conv = obj->fee_rate_too_high.feerate;
6324                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, feerate_conv);
6325                 }
6326                 case LDKAPIError_RouteError: {
6327                         LDKStr err_str = obj->route_error.err;
6328                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
6329                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
6330                 }
6331                 case LDKAPIError_ChannelUnavailable: {
6332                         LDKStr err_str = obj->channel_unavailable.err;
6333                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
6334                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
6335                 }
6336                 case LDKAPIError_MonitorUpdateInProgress: {
6337                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateInProgress_class, LDKAPIError_MonitorUpdateInProgress_meth);
6338                 }
6339                 case LDKAPIError_IncompatibleShutdownScript: {
6340                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
6341                         int64_t script_ref = 0;
6342                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
6343                         script_ref = tag_ptr(script_var.inner, false);
6344                         return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
6345                 }
6346                 default: abort();
6347         }
6348 }
6349 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
6350 CHECK(owner->result_ok);
6351         return *owner->contents.result;
6352 }
6353 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6354         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(owner);
6355         CResult_NoneAPIErrorZ_get_ok(owner_conv);
6356 }
6357
6358 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
6359 CHECK(!owner->result_ok);
6360         return APIError_clone(&*owner->contents.err);
6361 }
6362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6363         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(owner);
6364         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6365         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
6366         int64_t ret_ref = tag_ptr(ret_copy, true);
6367         return ret_ref;
6368 }
6369
6370 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
6371         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
6372         for (size_t i = 0; i < ret.datalen; i++) {
6373                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
6374         }
6375         return ret;
6376 }
6377 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
6378         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
6379         for (size_t i = 0; i < ret.datalen; i++) {
6380                 ret.data[i] = APIError_clone(&orig->data[i]);
6381         }
6382         return ret;
6383 }
6384 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
6385 CHECK(owner->result_ok);
6386         return ThirtyTwoBytes_clone(&*owner->contents.result);
6387 }
6388 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6389         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(owner);
6390         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6391         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult__u832APIErrorZ_get_ok(owner_conv).data);
6392         return ret_arr;
6393 }
6394
6395 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
6396 CHECK(!owner->result_ok);
6397         return APIError_clone(&*owner->contents.err);
6398 }
6399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6400         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(owner);
6401         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6402         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
6403         int64_t ret_ref = tag_ptr(ret_copy, true);
6404         return ret_ref;
6405 }
6406
6407 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
6408 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
6409 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
6410 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
6411 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
6412 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
6413 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
6414 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
6415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
6416         LDKPaymentSendFailure_ParameterError_class =
6417                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError"));
6418         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
6419         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
6420         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
6421         LDKPaymentSendFailure_PathParameterError_class =
6422                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError"));
6423         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
6424         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
6425         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
6426         LDKPaymentSendFailure_AllFailedRetrySafe_class =
6427                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe"));
6428         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
6429         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
6430         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
6431         LDKPaymentSendFailure_PartialFailure_class =
6432                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure"));
6433         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
6434         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([JJ[B)V");
6435         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
6436 }
6437 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6438         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)untag_ptr(ptr);
6439         switch(obj->tag) {
6440                 case LDKPaymentSendFailure_ParameterError: {
6441                         int64_t parameter_error_ref = tag_ptr(&obj->parameter_error, false);
6442                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
6443                 }
6444                 case LDKPaymentSendFailure_PathParameterError: {
6445                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
6446                         int64_tArray path_parameter_error_arr = NULL;
6447                         path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
6448                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
6449                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
6450                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6451                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
6452                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
6453                                 path_parameter_error_arr_ptr[w] = tag_ptr(path_parameter_error_conv_22_conv, true);
6454                         }
6455                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
6456                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
6457                 }
6458                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
6459                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
6460                         int64_tArray all_failed_retry_safe_arr = NULL;
6461                         all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
6462                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
6463                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
6464                                 int64_t all_failed_retry_safe_conv_10_ref = tag_ptr(&all_failed_retry_safe_var.data[k], false);
6465                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
6466                         }
6467                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
6468                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
6469                 }
6470                 case LDKPaymentSendFailure_PartialFailure: {
6471                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
6472                         int64_tArray results_arr = NULL;
6473                         results_arr = (*env)->NewLongArray(env, results_var.datalen);
6474                         int64_t *results_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, results_arr, NULL);
6475                         for (size_t w = 0; w < results_var.datalen; w++) {
6476                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6477                                 *results_conv_22_conv = results_var.data[w];
6478                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
6479                                 results_arr_ptr[w] = tag_ptr(results_conv_22_conv, true);
6480                         }
6481                         (*env)->ReleasePrimitiveArrayCritical(env, results_arr, results_arr_ptr, 0);
6482                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
6483                         int64_t failed_paths_retry_ref = 0;
6484                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
6485                         failed_paths_retry_ref = tag_ptr(failed_paths_retry_var.inner, false);
6486                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
6487                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->partial_failure.payment_id.data);
6488                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, results_arr, failed_paths_retry_ref, payment_id_arr);
6489                 }
6490                 default: abort();
6491         }
6492 }
6493 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
6494 CHECK(owner->result_ok);
6495         return ThirtyTwoBytes_clone(&*owner->contents.result);
6496 }
6497 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6498         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)untag_ptr(owner);
6499         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6500         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data);
6501         return ret_arr;
6502 }
6503
6504 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
6505 CHECK(!owner->result_ok);
6506         return PaymentSendFailure_clone(&*owner->contents.err);
6507 }
6508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6509         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)untag_ptr(owner);
6510         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6511         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
6512         int64_t ret_ref = tag_ptr(ret_copy, true);
6513         return ret_ref;
6514 }
6515
6516 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
6517 CHECK(owner->result_ok);
6518         return *owner->contents.result;
6519 }
6520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6521         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(owner);
6522         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
6523 }
6524
6525 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
6526 CHECK(!owner->result_ok);
6527         return PaymentSendFailure_clone(&*owner->contents.err);
6528 }
6529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6530         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(owner);
6531         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6532         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
6533         int64_t ret_ref = tag_ptr(ret_copy, true);
6534         return ret_ref;
6535 }
6536
6537 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
6538         return ThirtyTwoBytes_clone(&owner->a);
6539 }
6540 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6541         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(owner);
6542         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6543         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data);
6544         return ret_arr;
6545 }
6546
6547 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
6548         return ThirtyTwoBytes_clone(&owner->b);
6549 }
6550 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6551         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(owner);
6552         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6553         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data);
6554         return ret_arr;
6555 }
6556
6557 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
6558 CHECK(owner->result_ok);
6559         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
6560 }
6561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6562         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(owner);
6563         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
6564         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
6565         return tag_ptr(ret_conv, true);
6566 }
6567
6568 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
6569 CHECK(!owner->result_ok);
6570         return PaymentSendFailure_clone(&*owner->contents.err);
6571 }
6572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6573         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(owner);
6574         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6575         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
6576         int64_t ret_ref = tag_ptr(ret_copy, true);
6577         return ret_ref;
6578 }
6579
6580 static inline LDKCVec_ThirtyTwoBytesZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_ThirtyTwoBytesZ *orig) {
6581         LDKCVec_ThirtyTwoBytesZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_ThirtyTwoBytesZ clone bytes"), .datalen = orig->datalen };
6582         for (size_t i = 0; i < ret.datalen; i++) {
6583                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
6584         }
6585         return ret;
6586 }
6587 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
6588         return ThirtyTwoBytes_clone(&owner->a);
6589 }
6590 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6591         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(owner);
6592         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6593         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data);
6594         return ret_arr;
6595 }
6596
6597 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
6598         return ThirtyTwoBytes_clone(&owner->b);
6599 }
6600 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6601         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(owner);
6602         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6603         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data);
6604         return ret_arr;
6605 }
6606
6607 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
6608 CHECK(owner->result_ok);
6609         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
6610 }
6611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6612         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(owner);
6613         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
6614         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
6615         return tag_ptr(ret_conv, true);
6616 }
6617
6618 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
6619 CHECK(!owner->result_ok);
6620         return *owner->contents.err;
6621 }
6622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6623         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(owner);
6624         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
6625 }
6626
6627 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
6628 CHECK(owner->result_ok);
6629         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
6630 }
6631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6632         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(owner);
6633         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
6634         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
6635         return tag_ptr(ret_conv, true);
6636 }
6637
6638 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
6639 CHECK(!owner->result_ok);
6640         return APIError_clone(&*owner->contents.err);
6641 }
6642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6643         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(owner);
6644         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6645         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
6646         int64_t ret_ref = tag_ptr(ret_copy, true);
6647         return ret_ref;
6648 }
6649
6650 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
6651 CHECK(owner->result_ok);
6652         return ThirtyTwoBytes_clone(&*owner->contents.result);
6653 }
6654 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6655         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(owner);
6656         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6657         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data);
6658         return ret_arr;
6659 }
6660
6661 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
6662 CHECK(!owner->result_ok);
6663         return *owner->contents.err;
6664 }
6665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6666         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(owner);
6667         CResult_PaymentSecretNoneZ_get_err(owner_conv);
6668 }
6669
6670 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
6671 CHECK(owner->result_ok);
6672         return ThirtyTwoBytes_clone(&*owner->contents.result);
6673 }
6674 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6675         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(owner);
6676         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6677         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data);
6678         return ret_arr;
6679 }
6680
6681 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
6682 CHECK(!owner->result_ok);
6683         return APIError_clone(&*owner->contents.err);
6684 }
6685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6686         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(owner);
6687         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6688         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
6689         int64_t ret_ref = tag_ptr(ret_copy, true);
6690         return ret_ref;
6691 }
6692
6693 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
6694 CHECK(owner->result_ok);
6695         return ThirtyTwoBytes_clone(&*owner->contents.result);
6696 }
6697 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6698         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(owner);
6699         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6700         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data);
6701         return ret_arr;
6702 }
6703
6704 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
6705 CHECK(!owner->result_ok);
6706         return APIError_clone(&*owner->contents.err);
6707 }
6708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6709         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(owner);
6710         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6711         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
6712         int64_t ret_ref = tag_ptr(ret_copy, true);
6713         return ret_ref;
6714 }
6715
6716 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
6717         LDKCounterpartyForwardingInfo ret = *owner->contents.result;
6718         ret.is_owned = false;
6719         return ret;
6720 }
6721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6722         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(owner);
6723         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
6724         int64_t ret_ref = 0;
6725         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6726         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6727         return ret_ref;
6728 }
6729
6730 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
6731 CHECK(!owner->result_ok);
6732         return DecodeError_clone(&*owner->contents.err);
6733 }
6734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6735         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(owner);
6736         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6737         *ret_copy = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
6738         int64_t ret_ref = tag_ptr(ret_copy, true);
6739         return ret_ref;
6740 }
6741
6742 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
6743         LDKChannelCounterparty ret = *owner->contents.result;
6744         ret.is_owned = false;
6745         return ret;
6746 }
6747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6748         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(owner);
6749         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
6750         int64_t ret_ref = 0;
6751         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6752         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6753         return ret_ref;
6754 }
6755
6756 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
6757 CHECK(!owner->result_ok);
6758         return DecodeError_clone(&*owner->contents.err);
6759 }
6760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6761         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(owner);
6762         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6763         *ret_copy = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
6764         int64_t ret_ref = tag_ptr(ret_copy, true);
6765         return ret_ref;
6766 }
6767
6768 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
6769         LDKChannelDetails ret = *owner->contents.result;
6770         ret.is_owned = false;
6771         return ret;
6772 }
6773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6774         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(owner);
6775         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
6776         int64_t ret_ref = 0;
6777         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6778         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6779         return ret_ref;
6780 }
6781
6782 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
6783 CHECK(!owner->result_ok);
6784         return DecodeError_clone(&*owner->contents.err);
6785 }
6786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6787         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(owner);
6788         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6789         *ret_copy = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
6790         int64_t ret_ref = tag_ptr(ret_copy, true);
6791         return ret_ref;
6792 }
6793
6794 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
6795         LDKPhantomRouteHints ret = *owner->contents.result;
6796         ret.is_owned = false;
6797         return ret;
6798 }
6799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6800         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(owner);
6801         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
6802         int64_t ret_ref = 0;
6803         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6804         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6805         return ret_ref;
6806 }
6807
6808 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
6809 CHECK(!owner->result_ok);
6810         return DecodeError_clone(&*owner->contents.err);
6811 }
6812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6813         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(owner);
6814         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6815         *ret_copy = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
6816         int64_t ret_ref = tag_ptr(ret_copy, true);
6817         return ret_ref;
6818 }
6819
6820 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
6821         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
6822         for (size_t i = 0; i < ret.datalen; i++) {
6823                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
6824         }
6825         return ret;
6826 }
6827 typedef struct LDKWatch_JCalls {
6828         atomic_size_t refcnt;
6829         JavaVM *vm;
6830         jweak o;
6831         jmethodID watch_channel_meth;
6832         jmethodID update_channel_meth;
6833         jmethodID release_pending_monitor_events_meth;
6834 } LDKWatch_JCalls;
6835 static void LDKWatch_JCalls_free(void* this_arg) {
6836         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6837         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6838                 JNIEnv *env;
6839                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6840                 if (get_jenv_res == JNI_EDETACHED) {
6841                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6842                 } else {
6843                         DO_ASSERT(get_jenv_res == JNI_OK);
6844                 }
6845                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6846                 if (get_jenv_res == JNI_EDETACHED) {
6847                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6848                 }
6849                 FREE(j_calls);
6850         }
6851 }
6852 LDKChannelMonitorUpdateStatus watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
6853         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6854         JNIEnv *env;
6855         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6856         if (get_jenv_res == JNI_EDETACHED) {
6857                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6858         } else {
6859                 DO_ASSERT(get_jenv_res == JNI_OK);
6860         }
6861         LDKOutPoint funding_txo_var = funding_txo;
6862         int64_t funding_txo_ref = 0;
6863         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
6864         funding_txo_ref = tag_ptr(funding_txo_var.inner, funding_txo_var.is_owned);
6865         LDKChannelMonitor monitor_var = monitor;
6866         int64_t monitor_ref = 0;
6867         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
6868         monitor_ref = tag_ptr(monitor_var.inner, monitor_var.is_owned);
6869         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6870         CHECK(obj != NULL);
6871         jclass ret = (*env)->CallObjectMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
6872         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6873                 (*env)->ExceptionDescribe(env);
6874                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
6875         }
6876         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_java(env, ret);
6877         if (get_jenv_res == JNI_EDETACHED) {
6878                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6879         }
6880         return ret_conv;
6881 }
6882 LDKChannelMonitorUpdateStatus update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
6883         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6884         JNIEnv *env;
6885         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6886         if (get_jenv_res == JNI_EDETACHED) {
6887                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6888         } else {
6889                 DO_ASSERT(get_jenv_res == JNI_OK);
6890         }
6891         LDKOutPoint funding_txo_var = funding_txo;
6892         int64_t funding_txo_ref = 0;
6893         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
6894         funding_txo_ref = tag_ptr(funding_txo_var.inner, funding_txo_var.is_owned);
6895         LDKChannelMonitorUpdate update_var = update;
6896         int64_t update_ref = 0;
6897         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
6898         update_ref = tag_ptr(update_var.inner, update_var.is_owned);
6899         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6900         CHECK(obj != NULL);
6901         jclass ret = (*env)->CallObjectMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
6902         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6903                 (*env)->ExceptionDescribe(env);
6904                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
6905         }
6906         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_java(env, ret);
6907         if (get_jenv_res == JNI_EDETACHED) {
6908                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6909         }
6910         return ret_conv;
6911 }
6912 LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
6913         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6914         JNIEnv *env;
6915         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6916         if (get_jenv_res == JNI_EDETACHED) {
6917                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6918         } else {
6919                 DO_ASSERT(get_jenv_res == JNI_OK);
6920         }
6921         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6922         CHECK(obj != NULL);
6923         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
6924         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6925                 (*env)->ExceptionDescribe(env);
6926                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
6927         }
6928         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_constr;
6929         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6930         if (ret_constr.datalen > 0)
6931                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
6932         else
6933                 ret_constr.data = NULL;
6934         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
6935         for (size_t x = 0; x < ret_constr.datalen; x++) {
6936                 int64_t ret_conv_49 = ret_vals[x];
6937                 void* ret_conv_49_ptr = untag_ptr(ret_conv_49);
6938                 CHECK_ACCESS(ret_conv_49_ptr);
6939                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ ret_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(ret_conv_49_ptr);
6940                 FREE(untag_ptr(ret_conv_49));
6941                 ret_constr.data[x] = ret_conv_49_conv;
6942         }
6943         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
6944         if (get_jenv_res == JNI_EDETACHED) {
6945                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6946         }
6947         return ret_constr;
6948 }
6949 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
6950         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
6951         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6952 }
6953 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
6954         jclass c = (*env)->GetObjectClass(env, o);
6955         CHECK(c != NULL);
6956         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
6957         atomic_init(&calls->refcnt, 1);
6958         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6959         calls->o = (*env)->NewWeakGlobalRef(env, o);
6960         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
6961         CHECK(calls->watch_channel_meth != NULL);
6962         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
6963         CHECK(calls->update_channel_meth != NULL);
6964         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
6965         CHECK(calls->release_pending_monitor_events_meth != NULL);
6966
6967         LDKWatch ret = {
6968                 .this_arg = (void*) calls,
6969                 .watch_channel = watch_channel_LDKWatch_jcall,
6970                 .update_channel = update_channel_LDKWatch_jcall,
6971                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
6972                 .free = LDKWatch_JCalls_free,
6973         };
6974         return ret;
6975 }
6976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
6977         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
6978         *res_ptr = LDKWatch_init(env, clz, o);
6979         return tag_ptr(res_ptr, true);
6980 }
6981 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Watch_1watch_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo, int64_t monitor) {
6982         void* this_arg_ptr = untag_ptr(this_arg);
6983         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6984         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6985         LDKOutPoint funding_txo_conv;
6986         funding_txo_conv.inner = untag_ptr(funding_txo);
6987         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
6988         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
6989         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
6990         LDKChannelMonitor monitor_conv;
6991         monitor_conv.inner = untag_ptr(monitor);
6992         monitor_conv.is_owned = ptr_is_owned(monitor);
6993         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
6994         monitor_conv = ChannelMonitor_clone(&monitor_conv);
6995         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv));
6996         return ret_conv;
6997 }
6998
6999 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Watch_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo, int64_t update) {
7000         void* this_arg_ptr = untag_ptr(this_arg);
7001         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7002         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
7003         LDKOutPoint funding_txo_conv;
7004         funding_txo_conv.inner = untag_ptr(funding_txo);
7005         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
7006         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
7007         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
7008         LDKChannelMonitorUpdate update_conv;
7009         update_conv.inner = untag_ptr(update);
7010         update_conv.is_owned = ptr_is_owned(update);
7011         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
7012         update_conv = ChannelMonitorUpdate_clone(&update_conv);
7013         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv));
7014         return ret_conv;
7015 }
7016
7017 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
7018         void* this_arg_ptr = untag_ptr(this_arg);
7019         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7020         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
7021         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
7022         int64_tArray ret_arr = NULL;
7023         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
7024         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
7025         for (size_t x = 0; x < ret_var.datalen; x++) {
7026                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv_49_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
7027                 *ret_conv_49_conv = ret_var.data[x];
7028                 ret_arr_ptr[x] = tag_ptr(ret_conv_49_conv, true);
7029         }
7030         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
7031         FREE(ret_var.data);
7032         return ret_arr;
7033 }
7034
7035 typedef struct LDKBroadcasterInterface_JCalls {
7036         atomic_size_t refcnt;
7037         JavaVM *vm;
7038         jweak o;
7039         jmethodID broadcast_transaction_meth;
7040 } LDKBroadcasterInterface_JCalls;
7041 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
7042         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
7043         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7044                 JNIEnv *env;
7045                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7046                 if (get_jenv_res == JNI_EDETACHED) {
7047                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7048                 } else {
7049                         DO_ASSERT(get_jenv_res == JNI_OK);
7050                 }
7051                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7052                 if (get_jenv_res == JNI_EDETACHED) {
7053                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7054                 }
7055                 FREE(j_calls);
7056         }
7057 }
7058 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
7059         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
7060         JNIEnv *env;
7061         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7062         if (get_jenv_res == JNI_EDETACHED) {
7063                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7064         } else {
7065                 DO_ASSERT(get_jenv_res == JNI_OK);
7066         }
7067         LDKTransaction tx_var = tx;
7068         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
7069         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
7070         Transaction_free(tx_var);
7071         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7072         CHECK(obj != NULL);
7073         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
7074         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7075                 (*env)->ExceptionDescribe(env);
7076                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
7077         }
7078         if (get_jenv_res == JNI_EDETACHED) {
7079                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7080         }
7081 }
7082 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
7083         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
7084         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7085 }
7086 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
7087         jclass c = (*env)->GetObjectClass(env, o);
7088         CHECK(c != NULL);
7089         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
7090         atomic_init(&calls->refcnt, 1);
7091         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7092         calls->o = (*env)->NewWeakGlobalRef(env, o);
7093         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
7094         CHECK(calls->broadcast_transaction_meth != NULL);
7095
7096         LDKBroadcasterInterface ret = {
7097                 .this_arg = (void*) calls,
7098                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
7099                 .free = LDKBroadcasterInterface_JCalls_free,
7100         };
7101         return ret;
7102 }
7103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
7104         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
7105         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
7106         return tag_ptr(res_ptr, true);
7107 }
7108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
7109         void* this_arg_ptr = untag_ptr(this_arg);
7110         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7111         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
7112         LDKTransaction tx_ref;
7113         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
7114         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
7115         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
7116         tx_ref.data_is_owned = true;
7117         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
7118 }
7119
7120 typedef struct LDKKeysInterface_JCalls {
7121         atomic_size_t refcnt;
7122         JavaVM *vm;
7123         jweak o;
7124         jmethodID get_node_secret_meth;
7125         jmethodID get_node_id_meth;
7126         jmethodID ecdh_meth;
7127         jmethodID get_destination_script_meth;
7128         jmethodID get_shutdown_scriptpubkey_meth;
7129         jmethodID get_channel_signer_meth;
7130         jmethodID get_secure_random_bytes_meth;
7131         jmethodID read_chan_signer_meth;
7132         jmethodID sign_invoice_meth;
7133         jmethodID get_inbound_payment_key_material_meth;
7134 } LDKKeysInterface_JCalls;
7135 static void LDKKeysInterface_JCalls_free(void* this_arg) {
7136         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7137         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7138                 JNIEnv *env;
7139                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7140                 if (get_jenv_res == JNI_EDETACHED) {
7141                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7142                 } else {
7143                         DO_ASSERT(get_jenv_res == JNI_OK);
7144                 }
7145                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7146                 if (get_jenv_res == JNI_EDETACHED) {
7147                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7148                 }
7149                 FREE(j_calls);
7150         }
7151 }
7152 LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
7153         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7154         JNIEnv *env;
7155         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7156         if (get_jenv_res == JNI_EDETACHED) {
7157                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7158         } else {
7159                 DO_ASSERT(get_jenv_res == JNI_OK);
7160         }
7161         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
7162         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7163         CHECK(obj != NULL);
7164         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_node_secret_meth, recipient_conv);
7165         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7166                 (*env)->ExceptionDescribe(env);
7167                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
7168         }
7169         void* ret_ptr = untag_ptr(ret);
7170         CHECK_ACCESS(ret_ptr);
7171         LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
7172         FREE(untag_ptr(ret));
7173         if (get_jenv_res == JNI_EDETACHED) {
7174                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7175         }
7176         return ret_conv;
7177 }
7178 LDKCResult_PublicKeyNoneZ get_node_id_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
7179         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7180         JNIEnv *env;
7181         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7182         if (get_jenv_res == JNI_EDETACHED) {
7183                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7184         } else {
7185                 DO_ASSERT(get_jenv_res == JNI_OK);
7186         }
7187         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
7188         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7189         CHECK(obj != NULL);
7190         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_node_id_meth, recipient_conv);
7191         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7192                 (*env)->ExceptionDescribe(env);
7193                 (*env)->FatalError(env, "A call to get_node_id in LDKKeysInterface from rust threw an exception.");
7194         }
7195         void* ret_ptr = untag_ptr(ret);
7196         CHECK_ACCESS(ret_ptr);
7197         LDKCResult_PublicKeyNoneZ ret_conv = *(LDKCResult_PublicKeyNoneZ*)(ret_ptr);
7198         FREE(untag_ptr(ret));
7199         if (get_jenv_res == JNI_EDETACHED) {
7200                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7201         }
7202         return ret_conv;
7203 }
7204 LDKCResult_SharedSecretNoneZ ecdh_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient, LDKPublicKey other_key, LDKCOption_ScalarZ tweak) {
7205         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7206         JNIEnv *env;
7207         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7208         if (get_jenv_res == JNI_EDETACHED) {
7209                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7210         } else {
7211                 DO_ASSERT(get_jenv_res == JNI_OK);
7212         }
7213         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
7214         int8_tArray other_key_arr = (*env)->NewByteArray(env, 33);
7215         (*env)->SetByteArrayRegion(env, other_key_arr, 0, 33, other_key.compressed_form);
7216         LDKCOption_ScalarZ *tweak_copy = MALLOC(sizeof(LDKCOption_ScalarZ), "LDKCOption_ScalarZ");
7217         *tweak_copy = tweak;
7218         int64_t tweak_ref = tag_ptr(tweak_copy, true);
7219         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7220         CHECK(obj != NULL);
7221         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->ecdh_meth, recipient_conv, other_key_arr, tweak_ref);
7222         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7223                 (*env)->ExceptionDescribe(env);
7224                 (*env)->FatalError(env, "A call to ecdh in LDKKeysInterface from rust threw an exception.");
7225         }
7226         void* ret_ptr = untag_ptr(ret);
7227         CHECK_ACCESS(ret_ptr);
7228         LDKCResult_SharedSecretNoneZ ret_conv = *(LDKCResult_SharedSecretNoneZ*)(ret_ptr);
7229         FREE(untag_ptr(ret));
7230         if (get_jenv_res == JNI_EDETACHED) {
7231                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7232         }
7233         return ret_conv;
7234 }
7235 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
7236         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7237         JNIEnv *env;
7238         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7239         if (get_jenv_res == JNI_EDETACHED) {
7240                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7241         } else {
7242                 DO_ASSERT(get_jenv_res == JNI_OK);
7243         }
7244         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7245         CHECK(obj != NULL);
7246         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
7247         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7248                 (*env)->ExceptionDescribe(env);
7249                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
7250         }
7251         LDKCVec_u8Z ret_ref;
7252         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
7253         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
7254         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
7255         if (get_jenv_res == JNI_EDETACHED) {
7256                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7257         }
7258         return ret_ref;
7259 }
7260 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
7261         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7262         JNIEnv *env;
7263         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7264         if (get_jenv_res == JNI_EDETACHED) {
7265                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7266         } else {
7267                 DO_ASSERT(get_jenv_res == JNI_OK);
7268         }
7269         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7270         CHECK(obj != NULL);
7271         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_shutdown_scriptpubkey_meth);
7272         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7273                 (*env)->ExceptionDescribe(env);
7274                 (*env)->FatalError(env, "A call to get_shutdown_scriptpubkey in LDKKeysInterface from rust threw an exception.");
7275         }
7276         LDKShutdownScript ret_conv;
7277         ret_conv.inner = untag_ptr(ret);
7278         ret_conv.is_owned = ptr_is_owned(ret);
7279         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
7280         if (get_jenv_res == JNI_EDETACHED) {
7281                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7282         }
7283         return ret_conv;
7284 }
7285 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
7286         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7287         JNIEnv *env;
7288         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7289         if (get_jenv_res == JNI_EDETACHED) {
7290                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7291         } else {
7292                 DO_ASSERT(get_jenv_res == JNI_OK);
7293         }
7294         jboolean inbound_conv = inbound;
7295         int64_t channel_value_satoshis_conv = channel_value_satoshis;
7296         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7297         CHECK(obj != NULL);
7298         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound_conv, channel_value_satoshis_conv);
7299         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7300                 (*env)->ExceptionDescribe(env);
7301                 (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
7302         }
7303         void* ret_ptr = untag_ptr(ret);
7304         CHECK_ACCESS(ret_ptr);
7305         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
7306         FREE(untag_ptr(ret));
7307         if (get_jenv_res == JNI_EDETACHED) {
7308                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7309         }
7310         return ret_conv;
7311 }
7312 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
7313         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7314         JNIEnv *env;
7315         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7316         if (get_jenv_res == JNI_EDETACHED) {
7317                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7318         } else {
7319                 DO_ASSERT(get_jenv_res == JNI_OK);
7320         }
7321         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7322         CHECK(obj != NULL);
7323         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
7324         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7325                 (*env)->ExceptionDescribe(env);
7326                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
7327         }
7328         LDKThirtyTwoBytes ret_ref;
7329         CHECK((*env)->GetArrayLength(env, ret) == 32);
7330         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
7331         if (get_jenv_res == JNI_EDETACHED) {
7332                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7333         }
7334         return ret_ref;
7335 }
7336 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
7337         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7338         JNIEnv *env;
7339         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7340         if (get_jenv_res == JNI_EDETACHED) {
7341                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7342         } else {
7343                 DO_ASSERT(get_jenv_res == JNI_OK);
7344         }
7345         LDKu8slice reader_var = reader;
7346         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
7347         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
7348         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7349         CHECK(obj != NULL);
7350         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
7351         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7352                 (*env)->ExceptionDescribe(env);
7353                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
7354         }
7355         void* ret_ptr = untag_ptr(ret);
7356         CHECK_ACCESS(ret_ptr);
7357         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
7358         FREE(untag_ptr(ret));
7359         if (get_jenv_res == JNI_EDETACHED) {
7360                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7361         }
7362         return ret_conv;
7363 }
7364 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_u5Z invoice_data, LDKRecipient receipient) {
7365         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7366         JNIEnv *env;
7367         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7368         if (get_jenv_res == JNI_EDETACHED) {
7369                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7370         } else {
7371                 DO_ASSERT(get_jenv_res == JNI_OK);
7372         }
7373         LDKu8slice hrp_bytes_var = hrp_bytes;
7374         int8_tArray hrp_bytes_arr = (*env)->NewByteArray(env, hrp_bytes_var.datalen);
7375         (*env)->SetByteArrayRegion(env, hrp_bytes_arr, 0, hrp_bytes_var.datalen, hrp_bytes_var.data);
7376         LDKCVec_u5Z invoice_data_var = invoice_data;
7377         jobjectArray invoice_data_arr = NULL;
7378         invoice_data_arr = (*env)->NewByteArray(env, invoice_data_var.datalen);
7379         int8_t *invoice_data_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, invoice_data_arr, NULL);
7380         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
7381                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
7382                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
7383         }
7384         (*env)->ReleasePrimitiveArrayCritical(env, invoice_data_arr, invoice_data_arr_ptr, 0);
7385         FREE(invoice_data_var.data);
7386         jclass receipient_conv = LDKRecipient_to_java(env, receipient);
7387         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7388         CHECK(obj != NULL);
7389         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, hrp_bytes_arr, invoice_data_arr, receipient_conv);
7390         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7391                 (*env)->ExceptionDescribe(env);
7392                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
7393         }
7394         void* ret_ptr = untag_ptr(ret);
7395         CHECK_ACCESS(ret_ptr);
7396         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
7397         FREE(untag_ptr(ret));
7398         if (get_jenv_res == JNI_EDETACHED) {
7399                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7400         }
7401         return ret_conv;
7402 }
7403 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
7404         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7405         JNIEnv *env;
7406         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7407         if (get_jenv_res == JNI_EDETACHED) {
7408                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7409         } else {
7410                 DO_ASSERT(get_jenv_res == JNI_OK);
7411         }
7412         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7413         CHECK(obj != NULL);
7414         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_inbound_payment_key_material_meth);
7415         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7416                 (*env)->ExceptionDescribe(env);
7417                 (*env)->FatalError(env, "A call to get_inbound_payment_key_material in LDKKeysInterface from rust threw an exception.");
7418         }
7419         LDKThirtyTwoBytes ret_ref;
7420         CHECK((*env)->GetArrayLength(env, ret) == 32);
7421         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
7422         if (get_jenv_res == JNI_EDETACHED) {
7423                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7424         }
7425         return ret_ref;
7426 }
7427 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
7428         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
7429         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7430 }
7431 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
7432         jclass c = (*env)->GetObjectClass(env, o);
7433         CHECK(c != NULL);
7434         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
7435         atomic_init(&calls->refcnt, 1);
7436         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7437         calls->o = (*env)->NewWeakGlobalRef(env, o);
7438         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "(Lorg/ldk/enums/Recipient;)J");
7439         CHECK(calls->get_node_secret_meth != NULL);
7440         calls->get_node_id_meth = (*env)->GetMethodID(env, c, "get_node_id", "(Lorg/ldk/enums/Recipient;)J");
7441         CHECK(calls->get_node_id_meth != NULL);
7442         calls->ecdh_meth = (*env)->GetMethodID(env, c, "ecdh", "(Lorg/ldk/enums/Recipient;[BJ)J");
7443         CHECK(calls->ecdh_meth != NULL);
7444         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
7445         CHECK(calls->get_destination_script_meth != NULL);
7446         calls->get_shutdown_scriptpubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_scriptpubkey", "()J");
7447         CHECK(calls->get_shutdown_scriptpubkey_meth != NULL);
7448         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
7449         CHECK(calls->get_channel_signer_meth != NULL);
7450         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
7451         CHECK(calls->get_secure_random_bytes_meth != NULL);
7452         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
7453         CHECK(calls->read_chan_signer_meth != NULL);
7454         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B[BLorg/ldk/enums/Recipient;)J");
7455         CHECK(calls->sign_invoice_meth != NULL);
7456         calls->get_inbound_payment_key_material_meth = (*env)->GetMethodID(env, c, "get_inbound_payment_key_material", "()[B");
7457         CHECK(calls->get_inbound_payment_key_material_meth != NULL);
7458
7459         LDKKeysInterface ret = {
7460                 .this_arg = (void*) calls,
7461                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
7462                 .get_node_id = get_node_id_LDKKeysInterface_jcall,
7463                 .ecdh = ecdh_LDKKeysInterface_jcall,
7464                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
7465                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
7466                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
7467                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
7468                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
7469                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
7470                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
7471                 .free = LDKKeysInterface_JCalls_free,
7472         };
7473         return ret;
7474 }
7475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
7476         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
7477         *res_ptr = LDKKeysInterface_init(env, clz, o);
7478         return tag_ptr(res_ptr, true);
7479 }
7480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg, jclass recipient) {
7481         void* this_arg_ptr = untag_ptr(this_arg);
7482         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7483         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7484         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
7485         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
7486         *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
7487         return tag_ptr(ret_conv, true);
7488 }
7489
7490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg, jclass recipient) {
7491         void* this_arg_ptr = untag_ptr(this_arg);
7492         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7493         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7494         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
7495         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
7496         *ret_conv = (this_arg_conv->get_node_id)(this_arg_conv->this_arg, recipient_conv);
7497         return tag_ptr(ret_conv, true);
7498 }
7499
7500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1ecdh(JNIEnv *env, jclass clz, int64_t this_arg, jclass recipient, int8_tArray other_key, int64_t tweak) {
7501         void* this_arg_ptr = untag_ptr(this_arg);
7502         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7503         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7504         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
7505         LDKPublicKey other_key_ref;
7506         CHECK((*env)->GetArrayLength(env, other_key) == 33);
7507         (*env)->GetByteArrayRegion(env, other_key, 0, 33, other_key_ref.compressed_form);
7508         void* tweak_ptr = untag_ptr(tweak);
7509         CHECK_ACCESS(tweak_ptr);
7510         LDKCOption_ScalarZ tweak_conv = *(LDKCOption_ScalarZ*)(tweak_ptr);
7511         // WARNING: we may need a move here but no clone is available for LDKCOption_ScalarZ
7512         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
7513         *ret_conv = (this_arg_conv->ecdh)(this_arg_conv->this_arg, recipient_conv, other_key_ref, tweak_conv);
7514         return tag_ptr(ret_conv, true);
7515 }
7516
7517 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
7518         void* this_arg_ptr = untag_ptr(this_arg);
7519         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7520         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7521         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
7522         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7523         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7524         CVec_u8Z_free(ret_var);
7525         return ret_arr;
7526 }
7527
7528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
7529         void* this_arg_ptr = untag_ptr(this_arg);
7530         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7531         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7532         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
7533         int64_t ret_ref = 0;
7534         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7535         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7536         return ret_ref;
7537 }
7538
7539 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) {
7540         void* this_arg_ptr = untag_ptr(this_arg);
7541         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7542         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7543         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
7544         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
7545         return tag_ptr(ret_ret, true);
7546 }
7547
7548 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
7549         void* this_arg_ptr = untag_ptr(this_arg);
7550         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7551         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7552         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7553         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
7554         return ret_arr;
7555 }
7556
7557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
7558         void* this_arg_ptr = untag_ptr(this_arg);
7559         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7560         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7561         LDKu8slice reader_ref;
7562         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
7563         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
7564         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7565         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
7566         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
7567         return tag_ptr(ret_conv, true);
7568 }
7569
7570 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) {
7571         void* this_arg_ptr = untag_ptr(this_arg);
7572         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7573         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7574         LDKu8slice hrp_bytes_ref;
7575         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
7576         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
7577         LDKCVec_u5Z invoice_data_constr;
7578         invoice_data_constr.datalen = (*env)->GetArrayLength(env, invoice_data);
7579         if (invoice_data_constr.datalen > 0)
7580                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
7581         else
7582                 invoice_data_constr.data = NULL;
7583         int8_t* invoice_data_vals = (*env)->GetByteArrayElements (env, invoice_data, NULL);
7584         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
7585                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
7586                 
7587                 invoice_data_constr.data[h] = (LDKu5){ ._0 = invoice_data_conv_7 };
7588         }
7589         (*env)->ReleaseByteArrayElements(env, invoice_data, invoice_data_vals, 0);
7590         LDKRecipient receipient_conv = LDKRecipient_from_java(env, receipient);
7591         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
7592         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
7593         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
7594         return tag_ptr(ret_conv, true);
7595 }
7596
7597 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1inbound_1payment_1key_1material(JNIEnv *env, jclass clz, int64_t this_arg) {
7598         void* this_arg_ptr = untag_ptr(this_arg);
7599         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7600         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7601         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7602         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data);
7603         return ret_arr;
7604 }
7605
7606 typedef struct LDKFeeEstimator_JCalls {
7607         atomic_size_t refcnt;
7608         JavaVM *vm;
7609         jweak o;
7610         jmethodID get_est_sat_per_1000_weight_meth;
7611 } LDKFeeEstimator_JCalls;
7612 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
7613         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
7614         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7615                 JNIEnv *env;
7616                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7617                 if (get_jenv_res == JNI_EDETACHED) {
7618                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7619                 } else {
7620                         DO_ASSERT(get_jenv_res == JNI_OK);
7621                 }
7622                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7623                 if (get_jenv_res == JNI_EDETACHED) {
7624                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7625                 }
7626                 FREE(j_calls);
7627         }
7628 }
7629 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
7630         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
7631         JNIEnv *env;
7632         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7633         if (get_jenv_res == JNI_EDETACHED) {
7634                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7635         } else {
7636                 DO_ASSERT(get_jenv_res == JNI_OK);
7637         }
7638         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
7639         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7640         CHECK(obj != NULL);
7641         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
7642         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7643                 (*env)->ExceptionDescribe(env);
7644                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
7645         }
7646         if (get_jenv_res == JNI_EDETACHED) {
7647                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7648         }
7649         return ret;
7650 }
7651 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
7652         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
7653         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7654 }
7655 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
7656         jclass c = (*env)->GetObjectClass(env, o);
7657         CHECK(c != NULL);
7658         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
7659         atomic_init(&calls->refcnt, 1);
7660         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7661         calls->o = (*env)->NewWeakGlobalRef(env, o);
7662         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
7663         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
7664
7665         LDKFeeEstimator ret = {
7666                 .this_arg = (void*) calls,
7667                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
7668                 .free = LDKFeeEstimator_JCalls_free,
7669         };
7670         return ret;
7671 }
7672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
7673         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
7674         *res_ptr = LDKFeeEstimator_init(env, clz, o);
7675         return tag_ptr(res_ptr, true);
7676 }
7677 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) {
7678         void* this_arg_ptr = untag_ptr(this_arg);
7679         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7680         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
7681         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
7682         int32_t ret_conv = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
7683         return ret_conv;
7684 }
7685
7686 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
7687         return ThirtyTwoBytes_clone(&owner->a);
7688 }
7689 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7690         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)untag_ptr(owner);
7691         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7692         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data);
7693         return ret_arr;
7694 }
7695
7696 static inline struct LDKChannelManager C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
7697         LDKChannelManager ret = owner->b;
7698         ret.is_owned = false;
7699         return ret;
7700 }
7701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7702         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)untag_ptr(owner);
7703         LDKChannelManager ret_var = C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
7704         int64_t ret_ref = 0;
7705         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7706         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7707         return ret_ref;
7708 }
7709
7710 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
7711 CHECK(owner->result_ok);
7712         return &*owner->contents.result;
7713 }
7714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7715         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(owner);
7716         int64_t ret_ret = tag_ptr(CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv), false);
7717         return ret_ret;
7718 }
7719
7720 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
7721 CHECK(!owner->result_ok);
7722         return DecodeError_clone(&*owner->contents.err);
7723 }
7724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7725         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(owner);
7726         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7727         *ret_copy = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
7728         int64_t ret_ref = tag_ptr(ret_copy, true);
7729         return ret_ref;
7730 }
7731
7732 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
7733         LDKChannelConfig ret = *owner->contents.result;
7734         ret.is_owned = false;
7735         return ret;
7736 }
7737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7738         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(owner);
7739         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
7740         int64_t ret_ref = 0;
7741         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7742         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7743         return ret_ref;
7744 }
7745
7746 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
7747 CHECK(!owner->result_ok);
7748         return DecodeError_clone(&*owner->contents.err);
7749 }
7750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7751         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(owner);
7752         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7753         *ret_copy = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
7754         int64_t ret_ref = tag_ptr(ret_copy, true);
7755         return ret_ref;
7756 }
7757
7758 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
7759         LDKOutPoint ret = *owner->contents.result;
7760         ret.is_owned = false;
7761         return ret;
7762 }
7763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7764         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(owner);
7765         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
7766         int64_t ret_ref = 0;
7767         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7768         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7769         return ret_ref;
7770 }
7771
7772 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
7773 CHECK(!owner->result_ok);
7774         return DecodeError_clone(&*owner->contents.err);
7775 }
7776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7777         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(owner);
7778         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7779         *ret_copy = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
7780         int64_t ret_ref = tag_ptr(ret_copy, true);
7781         return ret_ref;
7782 }
7783
7784 typedef struct LDKType_JCalls {
7785         atomic_size_t refcnt;
7786         JavaVM *vm;
7787         jweak o;
7788         jmethodID type_id_meth;
7789         jmethodID debug_str_meth;
7790         jmethodID write_meth;
7791 } LDKType_JCalls;
7792 static void LDKType_JCalls_free(void* this_arg) {
7793         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7794         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7795                 JNIEnv *env;
7796                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7797                 if (get_jenv_res == JNI_EDETACHED) {
7798                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7799                 } else {
7800                         DO_ASSERT(get_jenv_res == JNI_OK);
7801                 }
7802                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7803                 if (get_jenv_res == JNI_EDETACHED) {
7804                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7805                 }
7806                 FREE(j_calls);
7807         }
7808 }
7809 uint16_t type_id_LDKType_jcall(const void* this_arg) {
7810         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7811         JNIEnv *env;
7812         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7813         if (get_jenv_res == JNI_EDETACHED) {
7814                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7815         } else {
7816                 DO_ASSERT(get_jenv_res == JNI_OK);
7817         }
7818         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7819         CHECK(obj != NULL);
7820         int16_t ret = (*env)->CallShortMethod(env, obj, j_calls->type_id_meth);
7821         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7822                 (*env)->ExceptionDescribe(env);
7823                 (*env)->FatalError(env, "A call to type_id in LDKType from rust threw an exception.");
7824         }
7825         if (get_jenv_res == JNI_EDETACHED) {
7826                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7827         }
7828         return ret;
7829 }
7830 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
7831         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7832         JNIEnv *env;
7833         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7834         if (get_jenv_res == JNI_EDETACHED) {
7835                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7836         } else {
7837                 DO_ASSERT(get_jenv_res == JNI_OK);
7838         }
7839         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7840         CHECK(obj != NULL);
7841         jstring ret = (*env)->CallObjectMethod(env, obj, j_calls->debug_str_meth);
7842         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7843                 (*env)->ExceptionDescribe(env);
7844                 (*env)->FatalError(env, "A call to debug_str in LDKType from rust threw an exception.");
7845         }
7846         LDKStr ret_conv = java_to_owned_str(env, ret);
7847         if (get_jenv_res == JNI_EDETACHED) {
7848                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7849         }
7850         return ret_conv;
7851 }
7852 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
7853         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7854         JNIEnv *env;
7855         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7856         if (get_jenv_res == JNI_EDETACHED) {
7857                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7858         } else {
7859                 DO_ASSERT(get_jenv_res == JNI_OK);
7860         }
7861         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7862         CHECK(obj != NULL);
7863         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
7864         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7865                 (*env)->ExceptionDescribe(env);
7866                 (*env)->FatalError(env, "A call to write in LDKType from rust threw an exception.");
7867         }
7868         LDKCVec_u8Z ret_ref;
7869         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
7870         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
7871         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
7872         if (get_jenv_res == JNI_EDETACHED) {
7873                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7874         }
7875         return ret_ref;
7876 }
7877 static void LDKType_JCalls_cloned(LDKType* new_obj) {
7878         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
7879         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7880 }
7881 static inline LDKType LDKType_init (JNIEnv *env, jclass clz, jobject o) {
7882         jclass c = (*env)->GetObjectClass(env, o);
7883         CHECK(c != NULL);
7884         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
7885         atomic_init(&calls->refcnt, 1);
7886         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7887         calls->o = (*env)->NewWeakGlobalRef(env, o);
7888         calls->type_id_meth = (*env)->GetMethodID(env, c, "type_id", "()S");
7889         CHECK(calls->type_id_meth != NULL);
7890         calls->debug_str_meth = (*env)->GetMethodID(env, c, "debug_str", "()Ljava/lang/String;");
7891         CHECK(calls->debug_str_meth != NULL);
7892         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
7893         CHECK(calls->write_meth != NULL);
7894
7895         LDKType ret = {
7896                 .this_arg = (void*) calls,
7897                 .type_id = type_id_LDKType_jcall,
7898                 .debug_str = debug_str_LDKType_jcall,
7899                 .write = write_LDKType_jcall,
7900                 .cloned = LDKType_JCalls_cloned,
7901                 .free = LDKType_JCalls_free,
7902         };
7903         return ret;
7904 }
7905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, jclass clz, jobject o) {
7906         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
7907         *res_ptr = LDKType_init(env, clz, o);
7908         return tag_ptr(res_ptr, true);
7909 }
7910 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Type_1type_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
7911         void* this_arg_ptr = untag_ptr(this_arg);
7912         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7913         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7914         int16_t ret_conv = (this_arg_conv->type_id)(this_arg_conv->this_arg);
7915         return ret_conv;
7916 }
7917
7918 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *env, jclass clz, int64_t this_arg) {
7919         void* this_arg_ptr = untag_ptr(this_arg);
7920         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7921         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7922         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
7923         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
7924         Str_free(ret_str);
7925         return ret_conv;
7926 }
7927
7928 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Type_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
7929         void* this_arg_ptr = untag_ptr(this_arg);
7930         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7931         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7932         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
7933         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7934         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7935         CVec_u8Z_free(ret_var);
7936         return ret_arr;
7937 }
7938
7939 static jclass LDKCOption_TypeZ_Some_class = NULL;
7940 static jmethodID LDKCOption_TypeZ_Some_meth = NULL;
7941 static jclass LDKCOption_TypeZ_None_class = NULL;
7942 static jmethodID LDKCOption_TypeZ_None_meth = NULL;
7943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init (JNIEnv *env, jclass clz) {
7944         LDKCOption_TypeZ_Some_class =
7945                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$Some"));
7946         CHECK(LDKCOption_TypeZ_Some_class != NULL);
7947         LDKCOption_TypeZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_Some_class, "<init>", "(J)V");
7948         CHECK(LDKCOption_TypeZ_Some_meth != NULL);
7949         LDKCOption_TypeZ_None_class =
7950                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$None"));
7951         CHECK(LDKCOption_TypeZ_None_class != NULL);
7952         LDKCOption_TypeZ_None_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_None_class, "<init>", "()V");
7953         CHECK(LDKCOption_TypeZ_None_meth != NULL);
7954 }
7955 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7956         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)untag_ptr(ptr);
7957         switch(obj->tag) {
7958                 case LDKCOption_TypeZ_Some: {
7959                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
7960                         *some_ret = Type_clone(&obj->some);
7961                         return (*env)->NewObject(env, LDKCOption_TypeZ_Some_class, LDKCOption_TypeZ_Some_meth, tag_ptr(some_ret, true));
7962                 }
7963                 case LDKCOption_TypeZ_None: {
7964                         return (*env)->NewObject(env, LDKCOption_TypeZ_None_class, LDKCOption_TypeZ_None_meth);
7965                 }
7966                 default: abort();
7967         }
7968 }
7969 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
7970 CHECK(owner->result_ok);
7971         return COption_TypeZ_clone(&*owner->contents.result);
7972 }
7973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7974         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(owner);
7975         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
7976         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
7977         int64_t ret_ref = tag_ptr(ret_copy, true);
7978         return ret_ref;
7979 }
7980
7981 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
7982 CHECK(!owner->result_ok);
7983         return DecodeError_clone(&*owner->contents.err);
7984 }
7985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7986         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(owner);
7987         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7988         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
7989         int64_t ret_ref = tag_ptr(ret_copy, true);
7990         return ret_ref;
7991 }
7992
7993 static jclass LDKPaymentError_Invoice_class = NULL;
7994 static jmethodID LDKPaymentError_Invoice_meth = NULL;
7995 static jclass LDKPaymentError_Routing_class = NULL;
7996 static jmethodID LDKPaymentError_Routing_meth = NULL;
7997 static jclass LDKPaymentError_Sending_class = NULL;
7998 static jmethodID LDKPaymentError_Sending_meth = NULL;
7999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentError_init (JNIEnv *env, jclass clz) {
8000         LDKPaymentError_Invoice_class =
8001                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Invoice"));
8002         CHECK(LDKPaymentError_Invoice_class != NULL);
8003         LDKPaymentError_Invoice_meth = (*env)->GetMethodID(env, LDKPaymentError_Invoice_class, "<init>", "(Ljava/lang/String;)V");
8004         CHECK(LDKPaymentError_Invoice_meth != NULL);
8005         LDKPaymentError_Routing_class =
8006                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Routing"));
8007         CHECK(LDKPaymentError_Routing_class != NULL);
8008         LDKPaymentError_Routing_meth = (*env)->GetMethodID(env, LDKPaymentError_Routing_class, "<init>", "(J)V");
8009         CHECK(LDKPaymentError_Routing_meth != NULL);
8010         LDKPaymentError_Sending_class =
8011                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Sending"));
8012         CHECK(LDKPaymentError_Sending_class != NULL);
8013         LDKPaymentError_Sending_meth = (*env)->GetMethodID(env, LDKPaymentError_Sending_class, "<init>", "(J)V");
8014         CHECK(LDKPaymentError_Sending_meth != NULL);
8015 }
8016 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8017         LDKPaymentError *obj = (LDKPaymentError*)untag_ptr(ptr);
8018         switch(obj->tag) {
8019                 case LDKPaymentError_Invoice: {
8020                         LDKStr invoice_str = obj->invoice;
8021                         jstring invoice_conv = str_ref_to_java(env, invoice_str.chars, invoice_str.len);
8022                         return (*env)->NewObject(env, LDKPaymentError_Invoice_class, LDKPaymentError_Invoice_meth, invoice_conv);
8023                 }
8024                 case LDKPaymentError_Routing: {
8025                         LDKLightningError routing_var = obj->routing;
8026                         int64_t routing_ref = 0;
8027                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
8028                         routing_ref = tag_ptr(routing_var.inner, false);
8029                         return (*env)->NewObject(env, LDKPaymentError_Routing_class, LDKPaymentError_Routing_meth, routing_ref);
8030                 }
8031                 case LDKPaymentError_Sending: {
8032                         int64_t sending_ref = tag_ptr(&obj->sending, false);
8033                         return (*env)->NewObject(env, LDKPaymentError_Sending_class, LDKPaymentError_Sending_meth, sending_ref);
8034                 }
8035                 default: abort();
8036         }
8037 }
8038 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
8039 CHECK(owner->result_ok);
8040         return ThirtyTwoBytes_clone(&*owner->contents.result);
8041 }
8042 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8043         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(owner);
8044         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8045         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data);
8046         return ret_arr;
8047 }
8048
8049 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
8050 CHECK(!owner->result_ok);
8051         return PaymentError_clone(&*owner->contents.err);
8052 }
8053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8054         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(owner);
8055         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
8056         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
8057         int64_t ret_ref = tag_ptr(ret_copy, true);
8058         return ret_ref;
8059 }
8060
8061 static inline struct LDKInFlightHtlcs CResult_InFlightHtlcsDecodeErrorZ_get_ok(LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR owner){
8062         LDKInFlightHtlcs ret = *owner->contents.result;
8063         ret.is_owned = false;
8064         return ret;
8065 }
8066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8067         LDKCResult_InFlightHtlcsDecodeErrorZ* owner_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(owner);
8068         LDKInFlightHtlcs ret_var = CResult_InFlightHtlcsDecodeErrorZ_get_ok(owner_conv);
8069         int64_t ret_ref = 0;
8070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8071         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8072         return ret_ref;
8073 }
8074
8075 static inline struct LDKDecodeError CResult_InFlightHtlcsDecodeErrorZ_get_err(LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR owner){
8076 CHECK(!owner->result_ok);
8077         return DecodeError_clone(&*owner->contents.err);
8078 }
8079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8080         LDKCResult_InFlightHtlcsDecodeErrorZ* owner_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(owner);
8081         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8082         *ret_copy = CResult_InFlightHtlcsDecodeErrorZ_get_err(owner_conv);
8083         int64_t ret_ref = tag_ptr(ret_copy, true);
8084         return ret_ref;
8085 }
8086
8087 static jclass LDKParseError_Bech32Error_class = NULL;
8088 static jmethodID LDKParseError_Bech32Error_meth = NULL;
8089 static jclass LDKParseError_ParseAmountError_class = NULL;
8090 static jmethodID LDKParseError_ParseAmountError_meth = NULL;
8091 static jclass LDKParseError_MalformedSignature_class = NULL;
8092 static jmethodID LDKParseError_MalformedSignature_meth = NULL;
8093 static jclass LDKParseError_BadPrefix_class = NULL;
8094 static jmethodID LDKParseError_BadPrefix_meth = NULL;
8095 static jclass LDKParseError_UnknownCurrency_class = NULL;
8096 static jmethodID LDKParseError_UnknownCurrency_meth = NULL;
8097 static jclass LDKParseError_UnknownSiPrefix_class = NULL;
8098 static jmethodID LDKParseError_UnknownSiPrefix_meth = NULL;
8099 static jclass LDKParseError_MalformedHRP_class = NULL;
8100 static jmethodID LDKParseError_MalformedHRP_meth = NULL;
8101 static jclass LDKParseError_TooShortDataPart_class = NULL;
8102 static jmethodID LDKParseError_TooShortDataPart_meth = NULL;
8103 static jclass LDKParseError_UnexpectedEndOfTaggedFields_class = NULL;
8104 static jmethodID LDKParseError_UnexpectedEndOfTaggedFields_meth = NULL;
8105 static jclass LDKParseError_DescriptionDecodeError_class = NULL;
8106 static jmethodID LDKParseError_DescriptionDecodeError_meth = NULL;
8107 static jclass LDKParseError_PaddingError_class = NULL;
8108 static jmethodID LDKParseError_PaddingError_meth = NULL;
8109 static jclass LDKParseError_IntegerOverflowError_class = NULL;
8110 static jmethodID LDKParseError_IntegerOverflowError_meth = NULL;
8111 static jclass LDKParseError_InvalidSegWitProgramLength_class = NULL;
8112 static jmethodID LDKParseError_InvalidSegWitProgramLength_meth = NULL;
8113 static jclass LDKParseError_InvalidPubKeyHashLength_class = NULL;
8114 static jmethodID LDKParseError_InvalidPubKeyHashLength_meth = NULL;
8115 static jclass LDKParseError_InvalidScriptHashLength_class = NULL;
8116 static jmethodID LDKParseError_InvalidScriptHashLength_meth = NULL;
8117 static jclass LDKParseError_InvalidRecoveryId_class = NULL;
8118 static jmethodID LDKParseError_InvalidRecoveryId_meth = NULL;
8119 static jclass LDKParseError_InvalidSliceLength_class = NULL;
8120 static jmethodID LDKParseError_InvalidSliceLength_meth = NULL;
8121 static jclass LDKParseError_Skip_class = NULL;
8122 static jmethodID LDKParseError_Skip_meth = NULL;
8123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseError_init (JNIEnv *env, jclass clz) {
8124         LDKParseError_Bech32Error_class =
8125                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Bech32Error"));
8126         CHECK(LDKParseError_Bech32Error_class != NULL);
8127         LDKParseError_Bech32Error_meth = (*env)->GetMethodID(env, LDKParseError_Bech32Error_class, "<init>", "(J)V");
8128         CHECK(LDKParseError_Bech32Error_meth != NULL);
8129         LDKParseError_ParseAmountError_class =
8130                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$ParseAmountError"));
8131         CHECK(LDKParseError_ParseAmountError_class != NULL);
8132         LDKParseError_ParseAmountError_meth = (*env)->GetMethodID(env, LDKParseError_ParseAmountError_class, "<init>", "(I)V");
8133         CHECK(LDKParseError_ParseAmountError_meth != NULL);
8134         LDKParseError_MalformedSignature_class =
8135                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedSignature"));
8136         CHECK(LDKParseError_MalformedSignature_class != NULL);
8137         LDKParseError_MalformedSignature_meth = (*env)->GetMethodID(env, LDKParseError_MalformedSignature_class, "<init>", "(Lorg/ldk/enums/Secp256k1Error;)V");
8138         CHECK(LDKParseError_MalformedSignature_meth != NULL);
8139         LDKParseError_BadPrefix_class =
8140                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$BadPrefix"));
8141         CHECK(LDKParseError_BadPrefix_class != NULL);
8142         LDKParseError_BadPrefix_meth = (*env)->GetMethodID(env, LDKParseError_BadPrefix_class, "<init>", "()V");
8143         CHECK(LDKParseError_BadPrefix_meth != NULL);
8144         LDKParseError_UnknownCurrency_class =
8145                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownCurrency"));
8146         CHECK(LDKParseError_UnknownCurrency_class != NULL);
8147         LDKParseError_UnknownCurrency_meth = (*env)->GetMethodID(env, LDKParseError_UnknownCurrency_class, "<init>", "()V");
8148         CHECK(LDKParseError_UnknownCurrency_meth != NULL);
8149         LDKParseError_UnknownSiPrefix_class =
8150                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownSiPrefix"));
8151         CHECK(LDKParseError_UnknownSiPrefix_class != NULL);
8152         LDKParseError_UnknownSiPrefix_meth = (*env)->GetMethodID(env, LDKParseError_UnknownSiPrefix_class, "<init>", "()V");
8153         CHECK(LDKParseError_UnknownSiPrefix_meth != NULL);
8154         LDKParseError_MalformedHRP_class =
8155                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedHRP"));
8156         CHECK(LDKParseError_MalformedHRP_class != NULL);
8157         LDKParseError_MalformedHRP_meth = (*env)->GetMethodID(env, LDKParseError_MalformedHRP_class, "<init>", "()V");
8158         CHECK(LDKParseError_MalformedHRP_meth != NULL);
8159         LDKParseError_TooShortDataPart_class =
8160                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$TooShortDataPart"));
8161         CHECK(LDKParseError_TooShortDataPart_class != NULL);
8162         LDKParseError_TooShortDataPart_meth = (*env)->GetMethodID(env, LDKParseError_TooShortDataPart_class, "<init>", "()V");
8163         CHECK(LDKParseError_TooShortDataPart_meth != NULL);
8164         LDKParseError_UnexpectedEndOfTaggedFields_class =
8165                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnexpectedEndOfTaggedFields"));
8166         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_class != NULL);
8167         LDKParseError_UnexpectedEndOfTaggedFields_meth = (*env)->GetMethodID(env, LDKParseError_UnexpectedEndOfTaggedFields_class, "<init>", "()V");
8168         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_meth != NULL);
8169         LDKParseError_DescriptionDecodeError_class =
8170                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$DescriptionDecodeError"));
8171         CHECK(LDKParseError_DescriptionDecodeError_class != NULL);
8172         LDKParseError_DescriptionDecodeError_meth = (*env)->GetMethodID(env, LDKParseError_DescriptionDecodeError_class, "<init>", "(I)V");
8173         CHECK(LDKParseError_DescriptionDecodeError_meth != NULL);
8174         LDKParseError_PaddingError_class =
8175                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$PaddingError"));
8176         CHECK(LDKParseError_PaddingError_class != NULL);
8177         LDKParseError_PaddingError_meth = (*env)->GetMethodID(env, LDKParseError_PaddingError_class, "<init>", "()V");
8178         CHECK(LDKParseError_PaddingError_meth != NULL);
8179         LDKParseError_IntegerOverflowError_class =
8180                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$IntegerOverflowError"));
8181         CHECK(LDKParseError_IntegerOverflowError_class != NULL);
8182         LDKParseError_IntegerOverflowError_meth = (*env)->GetMethodID(env, LDKParseError_IntegerOverflowError_class, "<init>", "()V");
8183         CHECK(LDKParseError_IntegerOverflowError_meth != NULL);
8184         LDKParseError_InvalidSegWitProgramLength_class =
8185                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSegWitProgramLength"));
8186         CHECK(LDKParseError_InvalidSegWitProgramLength_class != NULL);
8187         LDKParseError_InvalidSegWitProgramLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSegWitProgramLength_class, "<init>", "()V");
8188         CHECK(LDKParseError_InvalidSegWitProgramLength_meth != NULL);
8189         LDKParseError_InvalidPubKeyHashLength_class =
8190                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidPubKeyHashLength"));
8191         CHECK(LDKParseError_InvalidPubKeyHashLength_class != NULL);
8192         LDKParseError_InvalidPubKeyHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidPubKeyHashLength_class, "<init>", "()V");
8193         CHECK(LDKParseError_InvalidPubKeyHashLength_meth != NULL);
8194         LDKParseError_InvalidScriptHashLength_class =
8195                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidScriptHashLength"));
8196         CHECK(LDKParseError_InvalidScriptHashLength_class != NULL);
8197         LDKParseError_InvalidScriptHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidScriptHashLength_class, "<init>", "()V");
8198         CHECK(LDKParseError_InvalidScriptHashLength_meth != NULL);
8199         LDKParseError_InvalidRecoveryId_class =
8200                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidRecoveryId"));
8201         CHECK(LDKParseError_InvalidRecoveryId_class != NULL);
8202         LDKParseError_InvalidRecoveryId_meth = (*env)->GetMethodID(env, LDKParseError_InvalidRecoveryId_class, "<init>", "()V");
8203         CHECK(LDKParseError_InvalidRecoveryId_meth != NULL);
8204         LDKParseError_InvalidSliceLength_class =
8205                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSliceLength"));
8206         CHECK(LDKParseError_InvalidSliceLength_class != NULL);
8207         LDKParseError_InvalidSliceLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSliceLength_class, "<init>", "(Ljava/lang/String;)V");
8208         CHECK(LDKParseError_InvalidSliceLength_meth != NULL);
8209         LDKParseError_Skip_class =
8210                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Skip"));
8211         CHECK(LDKParseError_Skip_class != NULL);
8212         LDKParseError_Skip_meth = (*env)->GetMethodID(env, LDKParseError_Skip_class, "<init>", "()V");
8213         CHECK(LDKParseError_Skip_meth != NULL);
8214 }
8215 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8216         LDKParseError *obj = (LDKParseError*)untag_ptr(ptr);
8217         switch(obj->tag) {
8218                 case LDKParseError_Bech32Error: {
8219                         int64_t bech32_error_ref = tag_ptr(&obj->bech32_error, false);
8220                         return (*env)->NewObject(env, LDKParseError_Bech32Error_class, LDKParseError_Bech32Error_meth, bech32_error_ref);
8221                 }
8222                 case LDKParseError_ParseAmountError: {
8223                         /*obj->parse_amount_error*/
8224                         return (*env)->NewObject(env, LDKParseError_ParseAmountError_class, LDKParseError_ParseAmountError_meth, 0);
8225                 }
8226                 case LDKParseError_MalformedSignature: {
8227                         jclass malformed_signature_conv = LDKSecp256k1Error_to_java(env, obj->malformed_signature);
8228                         return (*env)->NewObject(env, LDKParseError_MalformedSignature_class, LDKParseError_MalformedSignature_meth, malformed_signature_conv);
8229                 }
8230                 case LDKParseError_BadPrefix: {
8231                         return (*env)->NewObject(env, LDKParseError_BadPrefix_class, LDKParseError_BadPrefix_meth);
8232                 }
8233                 case LDKParseError_UnknownCurrency: {
8234                         return (*env)->NewObject(env, LDKParseError_UnknownCurrency_class, LDKParseError_UnknownCurrency_meth);
8235                 }
8236                 case LDKParseError_UnknownSiPrefix: {
8237                         return (*env)->NewObject(env, LDKParseError_UnknownSiPrefix_class, LDKParseError_UnknownSiPrefix_meth);
8238                 }
8239                 case LDKParseError_MalformedHRP: {
8240                         return (*env)->NewObject(env, LDKParseError_MalformedHRP_class, LDKParseError_MalformedHRP_meth);
8241                 }
8242                 case LDKParseError_TooShortDataPart: {
8243                         return (*env)->NewObject(env, LDKParseError_TooShortDataPart_class, LDKParseError_TooShortDataPart_meth);
8244                 }
8245                 case LDKParseError_UnexpectedEndOfTaggedFields: {
8246                         return (*env)->NewObject(env, LDKParseError_UnexpectedEndOfTaggedFields_class, LDKParseError_UnexpectedEndOfTaggedFields_meth);
8247                 }
8248                 case LDKParseError_DescriptionDecodeError: {
8249                         /*obj->description_decode_error*/
8250                         return (*env)->NewObject(env, LDKParseError_DescriptionDecodeError_class, LDKParseError_DescriptionDecodeError_meth, 0);
8251                 }
8252                 case LDKParseError_PaddingError: {
8253                         return (*env)->NewObject(env, LDKParseError_PaddingError_class, LDKParseError_PaddingError_meth);
8254                 }
8255                 case LDKParseError_IntegerOverflowError: {
8256                         return (*env)->NewObject(env, LDKParseError_IntegerOverflowError_class, LDKParseError_IntegerOverflowError_meth);
8257                 }
8258                 case LDKParseError_InvalidSegWitProgramLength: {
8259                         return (*env)->NewObject(env, LDKParseError_InvalidSegWitProgramLength_class, LDKParseError_InvalidSegWitProgramLength_meth);
8260                 }
8261                 case LDKParseError_InvalidPubKeyHashLength: {
8262                         return (*env)->NewObject(env, LDKParseError_InvalidPubKeyHashLength_class, LDKParseError_InvalidPubKeyHashLength_meth);
8263                 }
8264                 case LDKParseError_InvalidScriptHashLength: {
8265                         return (*env)->NewObject(env, LDKParseError_InvalidScriptHashLength_class, LDKParseError_InvalidScriptHashLength_meth);
8266                 }
8267                 case LDKParseError_InvalidRecoveryId: {
8268                         return (*env)->NewObject(env, LDKParseError_InvalidRecoveryId_class, LDKParseError_InvalidRecoveryId_meth);
8269                 }
8270                 case LDKParseError_InvalidSliceLength: {
8271                         LDKStr invalid_slice_length_str = obj->invalid_slice_length;
8272                         jstring invalid_slice_length_conv = str_ref_to_java(env, invalid_slice_length_str.chars, invalid_slice_length_str.len);
8273                         return (*env)->NewObject(env, LDKParseError_InvalidSliceLength_class, LDKParseError_InvalidSliceLength_meth, invalid_slice_length_conv);
8274                 }
8275                 case LDKParseError_Skip: {
8276                         return (*env)->NewObject(env, LDKParseError_Skip_class, LDKParseError_Skip_meth);
8277                 }
8278                 default: abort();
8279         }
8280 }
8281 static inline enum LDKSiPrefix CResult_SiPrefixParseErrorZ_get_ok(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
8282 CHECK(owner->result_ok);
8283         return SiPrefix_clone(&*owner->contents.result);
8284 }
8285 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8286         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(owner);
8287         jclass ret_conv = LDKSiPrefix_to_java(env, CResult_SiPrefixParseErrorZ_get_ok(owner_conv));
8288         return ret_conv;
8289 }
8290
8291 static inline struct LDKParseError CResult_SiPrefixParseErrorZ_get_err(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
8292 CHECK(!owner->result_ok);
8293         return ParseError_clone(&*owner->contents.err);
8294 }
8295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8296         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(owner);
8297         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
8298         *ret_copy = CResult_SiPrefixParseErrorZ_get_err(owner_conv);
8299         int64_t ret_ref = tag_ptr(ret_copy, true);
8300         return ret_ref;
8301 }
8302
8303 static jclass LDKParseOrSemanticError_ParseError_class = NULL;
8304 static jmethodID LDKParseOrSemanticError_ParseError_meth = NULL;
8305 static jclass LDKParseOrSemanticError_SemanticError_class = NULL;
8306 static jmethodID LDKParseOrSemanticError_SemanticError_meth = NULL;
8307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseOrSemanticError_init (JNIEnv *env, jclass clz) {
8308         LDKParseOrSemanticError_ParseError_class =
8309                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$ParseError"));
8310         CHECK(LDKParseOrSemanticError_ParseError_class != NULL);
8311         LDKParseOrSemanticError_ParseError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_ParseError_class, "<init>", "(J)V");
8312         CHECK(LDKParseOrSemanticError_ParseError_meth != NULL);
8313         LDKParseOrSemanticError_SemanticError_class =
8314                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$SemanticError"));
8315         CHECK(LDKParseOrSemanticError_SemanticError_class != NULL);
8316         LDKParseOrSemanticError_SemanticError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_SemanticError_class, "<init>", "(Lorg/ldk/enums/SemanticError;)V");
8317         CHECK(LDKParseOrSemanticError_SemanticError_meth != NULL);
8318 }
8319 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseOrSemanticError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8320         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)untag_ptr(ptr);
8321         switch(obj->tag) {
8322                 case LDKParseOrSemanticError_ParseError: {
8323                         int64_t parse_error_ref = tag_ptr(&obj->parse_error, false);
8324                         return (*env)->NewObject(env, LDKParseOrSemanticError_ParseError_class, LDKParseOrSemanticError_ParseError_meth, parse_error_ref);
8325                 }
8326                 case LDKParseOrSemanticError_SemanticError: {
8327                         jclass semantic_error_conv = LDKSemanticError_to_java(env, obj->semantic_error);
8328                         return (*env)->NewObject(env, LDKParseOrSemanticError_SemanticError_class, LDKParseOrSemanticError_SemanticError_meth, semantic_error_conv);
8329                 }
8330                 default: abort();
8331         }
8332 }
8333 static inline struct LDKInvoice CResult_InvoiceParseOrSemanticErrorZ_get_ok(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
8334         LDKInvoice ret = *owner->contents.result;
8335         ret.is_owned = false;
8336         return ret;
8337 }
8338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8339         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(owner);
8340         LDKInvoice ret_var = CResult_InvoiceParseOrSemanticErrorZ_get_ok(owner_conv);
8341         int64_t ret_ref = 0;
8342         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8343         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8344         return ret_ref;
8345 }
8346
8347 static inline struct LDKParseOrSemanticError CResult_InvoiceParseOrSemanticErrorZ_get_err(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
8348 CHECK(!owner->result_ok);
8349         return ParseOrSemanticError_clone(&*owner->contents.err);
8350 }
8351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8352         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(owner);
8353         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
8354         *ret_copy = CResult_InvoiceParseOrSemanticErrorZ_get_err(owner_conv);
8355         int64_t ret_ref = tag_ptr(ret_copy, true);
8356         return ret_ref;
8357 }
8358
8359 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceParseErrorZ_get_ok(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
8360         LDKSignedRawInvoice ret = *owner->contents.result;
8361         ret.is_owned = false;
8362         return ret;
8363 }
8364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8365         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(owner);
8366         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceParseErrorZ_get_ok(owner_conv);
8367         int64_t ret_ref = 0;
8368         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8369         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8370         return ret_ref;
8371 }
8372
8373 static inline struct LDKParseError CResult_SignedRawInvoiceParseErrorZ_get_err(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
8374 CHECK(!owner->result_ok);
8375         return ParseError_clone(&*owner->contents.err);
8376 }
8377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8378         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(owner);
8379         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
8380         *ret_copy = CResult_SignedRawInvoiceParseErrorZ_get_err(owner_conv);
8381         int64_t ret_ref = tag_ptr(ret_copy, true);
8382         return ret_ref;
8383 }
8384
8385 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
8386         LDKRawInvoice ret = owner->a;
8387         ret.is_owned = false;
8388         return ret;
8389 }
8390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8391         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(owner);
8392         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
8393         int64_t ret_ref = 0;
8394         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8395         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8396         return ret_ref;
8397 }
8398
8399 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
8400         return ThirtyTwoBytes_clone(&owner->b);
8401 }
8402 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8403         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(owner);
8404         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8405         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data);
8406         return ret_arr;
8407 }
8408
8409 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
8410         LDKInvoiceSignature ret = owner->c;
8411         ret.is_owned = false;
8412         return ret;
8413 }
8414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
8415         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(owner);
8416         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
8417         int64_t ret_ref = 0;
8418         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8419         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8420         return ret_ref;
8421 }
8422
8423 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
8424         LDKPayeePubKey ret = *owner->contents.result;
8425         ret.is_owned = false;
8426         return ret;
8427 }
8428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8429         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(owner);
8430         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_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 enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
8438 CHECK(!owner->result_ok);
8439         return *owner->contents.err;
8440 }
8441 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8442         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(owner);
8443         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PayeePubKeyErrorZ_get_err(owner_conv));
8444         return ret_conv;
8445 }
8446
8447 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
8448         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
8449         for (size_t i = 0; i < ret.datalen; i++) {
8450                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
8451         }
8452         return ret;
8453 }
8454 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
8455         LDKPositiveTimestamp ret = *owner->contents.result;
8456         ret.is_owned = false;
8457         return ret;
8458 }
8459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8460         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(owner);
8461         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
8462         int64_t ret_ref = 0;
8463         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8464         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8465         return ret_ref;
8466 }
8467
8468 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
8469 CHECK(!owner->result_ok);
8470         return CreationError_clone(&*owner->contents.err);
8471 }
8472 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8473         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(owner);
8474         jclass ret_conv = LDKCreationError_to_java(env, CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
8475         return ret_conv;
8476 }
8477
8478 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
8479 CHECK(owner->result_ok);
8480         return *owner->contents.result;
8481 }
8482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8483         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(owner);
8484         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
8485 }
8486
8487 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
8488 CHECK(!owner->result_ok);
8489         return SemanticError_clone(&*owner->contents.err);
8490 }
8491 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8492         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(owner);
8493         jclass ret_conv = LDKSemanticError_to_java(env, CResult_NoneSemanticErrorZ_get_err(owner_conv));
8494         return ret_conv;
8495 }
8496
8497 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
8498         LDKInvoice ret = *owner->contents.result;
8499         ret.is_owned = false;
8500         return ret;
8501 }
8502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8503         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(owner);
8504         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
8505         int64_t ret_ref = 0;
8506         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8507         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8508         return ret_ref;
8509 }
8510
8511 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
8512 CHECK(!owner->result_ok);
8513         return SemanticError_clone(&*owner->contents.err);
8514 }
8515 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8516         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(owner);
8517         jclass ret_conv = LDKSemanticError_to_java(env, CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
8518         return ret_conv;
8519 }
8520
8521 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
8522         LDKDescription ret = *owner->contents.result;
8523         ret.is_owned = false;
8524         return ret;
8525 }
8526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8527         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(owner);
8528         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
8529         int64_t ret_ref = 0;
8530         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8531         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8532         return ret_ref;
8533 }
8534
8535 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
8536 CHECK(!owner->result_ok);
8537         return CreationError_clone(&*owner->contents.err);
8538 }
8539 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8540         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(owner);
8541         jclass ret_conv = LDKCreationError_to_java(env, CResult_DescriptionCreationErrorZ_get_err(owner_conv));
8542         return ret_conv;
8543 }
8544
8545 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
8546         LDKPrivateRoute ret = *owner->contents.result;
8547         ret.is_owned = false;
8548         return ret;
8549 }
8550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8551         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(owner);
8552         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
8553         int64_t ret_ref = 0;
8554         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8555         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8556         return ret_ref;
8557 }
8558
8559 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
8560 CHECK(!owner->result_ok);
8561         return CreationError_clone(&*owner->contents.err);
8562 }
8563 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8564         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(owner);
8565         jclass ret_conv = LDKCreationError_to_java(env, CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
8566         return ret_conv;
8567 }
8568
8569 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
8570 CHECK(owner->result_ok);
8571         return *owner->contents.result;
8572 }
8573 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8574         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)untag_ptr(owner);
8575         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
8576         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
8577         return ret_conv;
8578 }
8579
8580 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
8581 CHECK(!owner->result_ok);
8582         return *owner->contents.err;
8583 }
8584 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8585         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)untag_ptr(owner);
8586         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_StringErrorZ_get_err(owner_conv));
8587         return ret_conv;
8588 }
8589
8590 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
8591         LDKChannelMonitorUpdate ret = *owner->contents.result;
8592         ret.is_owned = false;
8593         return ret;
8594 }
8595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8596         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(owner);
8597         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
8598         int64_t ret_ref = 0;
8599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8600         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8601         return ret_ref;
8602 }
8603
8604 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
8605 CHECK(!owner->result_ok);
8606         return DecodeError_clone(&*owner->contents.err);
8607 }
8608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8609         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(owner);
8610         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8611         *ret_copy = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
8612         int64_t ret_ref = tag_ptr(ret_copy, true);
8613         return ret_ref;
8614 }
8615
8616 static jclass LDKCOption_MonitorEventZ_Some_class = NULL;
8617 static jmethodID LDKCOption_MonitorEventZ_Some_meth = NULL;
8618 static jclass LDKCOption_MonitorEventZ_None_class = NULL;
8619 static jmethodID LDKCOption_MonitorEventZ_None_meth = NULL;
8620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1MonitorEventZ_init (JNIEnv *env, jclass clz) {
8621         LDKCOption_MonitorEventZ_Some_class =
8622                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$Some"));
8623         CHECK(LDKCOption_MonitorEventZ_Some_class != NULL);
8624         LDKCOption_MonitorEventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_Some_class, "<init>", "(J)V");
8625         CHECK(LDKCOption_MonitorEventZ_Some_meth != NULL);
8626         LDKCOption_MonitorEventZ_None_class =
8627                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$None"));
8628         CHECK(LDKCOption_MonitorEventZ_None_class != NULL);
8629         LDKCOption_MonitorEventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_None_class, "<init>", "()V");
8630         CHECK(LDKCOption_MonitorEventZ_None_meth != NULL);
8631 }
8632 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1MonitorEventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8633         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)untag_ptr(ptr);
8634         switch(obj->tag) {
8635                 case LDKCOption_MonitorEventZ_Some: {
8636                         int64_t some_ref = tag_ptr(&obj->some, false);
8637                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_Some_class, LDKCOption_MonitorEventZ_Some_meth, some_ref);
8638                 }
8639                 case LDKCOption_MonitorEventZ_None: {
8640                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_None_class, LDKCOption_MonitorEventZ_None_meth);
8641                 }
8642                 default: abort();
8643         }
8644 }
8645 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
8646 CHECK(owner->result_ok);
8647         return COption_MonitorEventZ_clone(&*owner->contents.result);
8648 }
8649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8650         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(owner);
8651         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
8652         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
8653         int64_t ret_ref = tag_ptr(ret_copy, true);
8654         return ret_ref;
8655 }
8656
8657 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
8658 CHECK(!owner->result_ok);
8659         return DecodeError_clone(&*owner->contents.err);
8660 }
8661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8662         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(owner);
8663         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8664         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
8665         int64_t ret_ref = tag_ptr(ret_copy, true);
8666         return ret_ref;
8667 }
8668
8669 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
8670         LDKHTLCUpdate ret = *owner->contents.result;
8671         ret.is_owned = false;
8672         return ret;
8673 }
8674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8675         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(owner);
8676         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
8677         int64_t ret_ref = 0;
8678         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8679         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8680         return ret_ref;
8681 }
8682
8683 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
8684 CHECK(!owner->result_ok);
8685         return DecodeError_clone(&*owner->contents.err);
8686 }
8687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8688         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(owner);
8689         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8690         *ret_copy = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
8691         int64_t ret_ref = tag_ptr(ret_copy, true);
8692         return ret_ref;
8693 }
8694
8695 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
8696         LDKOutPoint ret = owner->a;
8697         ret.is_owned = false;
8698         return ret;
8699 }
8700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8701         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(owner);
8702         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
8703         int64_t ret_ref = 0;
8704         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8705         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8706         return ret_ref;
8707 }
8708
8709 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
8710         return CVec_u8Z_clone(&owner->b);
8711 }
8712 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8713         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(owner);
8714         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
8715         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8716         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8717         CVec_u8Z_free(ret_var);
8718         return ret_arr;
8719 }
8720
8721 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
8722         return owner->a;
8723 }
8724 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8725         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(owner);
8726         int32_t ret_conv = C2Tuple_u32ScriptZ_get_a(owner_conv);
8727         return ret_conv;
8728 }
8729
8730 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
8731         return CVec_u8Z_clone(&owner->b);
8732 }
8733 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8734         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(owner);
8735         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
8736         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8737         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8738         CVec_u8Z_free(ret_var);
8739         return ret_arr;
8740 }
8741
8742 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
8743         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
8744         for (size_t i = 0; i < ret.datalen; i++) {
8745                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
8746         }
8747         return ret;
8748 }
8749 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
8750         return ThirtyTwoBytes_clone(&owner->a);
8751 }
8752 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8753         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(owner);
8754         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8755         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data);
8756         return ret_arr;
8757 }
8758
8759 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
8760         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
8761 }
8762 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8763         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(owner);
8764         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
8765         int64_tArray ret_arr = NULL;
8766         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8767         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8768         for (size_t v = 0; v < ret_var.datalen; v++) {
8769                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
8770                 *ret_conv_21_conv = ret_var.data[v];
8771                 ret_arr_ptr[v] = tag_ptr(ret_conv_21_conv, true);
8772         }
8773         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8774         FREE(ret_var.data);
8775         return ret_arr;
8776 }
8777
8778 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
8779         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 };
8780         for (size_t i = 0; i < ret.datalen; i++) {
8781                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
8782         }
8783         return ret;
8784 }
8785 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
8786         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
8787         for (size_t i = 0; i < ret.datalen; i++) {
8788                 ret.data[i] = Event_clone(&orig->data[i]);
8789         }
8790         return ret;
8791 }
8792 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
8793         return owner->a;
8794 }
8795 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8796         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(owner);
8797         int32_t ret_conv = C2Tuple_u32TxOutZ_get_a(owner_conv);
8798         return ret_conv;
8799 }
8800
8801 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
8802         return TxOut_clone(&owner->b);
8803 }
8804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8805         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(owner);
8806         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8807         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
8808         return tag_ptr(ret_ref, true);
8809 }
8810
8811 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
8812         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
8813         for (size_t i = 0; i < ret.datalen; i++) {
8814                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
8815         }
8816         return ret;
8817 }
8818 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
8819         return ThirtyTwoBytes_clone(&owner->a);
8820 }
8821 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8822         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(owner);
8823         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8824         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data);
8825         return ret_arr;
8826 }
8827
8828 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
8829         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
8830 }
8831 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8832         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(owner);
8833         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
8834         int64_tArray ret_arr = NULL;
8835         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8836         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8837         for (size_t u = 0; u < ret_var.datalen; u++) {
8838                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
8839                 *ret_conv_20_conv = ret_var.data[u];
8840                 ret_arr_ptr[u] = tag_ptr(ret_conv_20_conv, true);
8841         }
8842         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8843         FREE(ret_var.data);
8844         return ret_arr;
8845 }
8846
8847 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
8848         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 };
8849         for (size_t i = 0; i < ret.datalen; i++) {
8850                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
8851         }
8852         return ret;
8853 }
8854 static jclass LDKBalance_ClaimableOnChannelClose_class = NULL;
8855 static jmethodID LDKBalance_ClaimableOnChannelClose_meth = NULL;
8856 static jclass LDKBalance_ClaimableAwaitingConfirmations_class = NULL;
8857 static jmethodID LDKBalance_ClaimableAwaitingConfirmations_meth = NULL;
8858 static jclass LDKBalance_ContentiousClaimable_class = NULL;
8859 static jmethodID LDKBalance_ContentiousClaimable_meth = NULL;
8860 static jclass LDKBalance_MaybeTimeoutClaimableHTLC_class = NULL;
8861 static jmethodID LDKBalance_MaybeTimeoutClaimableHTLC_meth = NULL;
8862 static jclass LDKBalance_MaybePreimageClaimableHTLC_class = NULL;
8863 static jmethodID LDKBalance_MaybePreimageClaimableHTLC_meth = NULL;
8864 static jclass LDKBalance_CounterpartyRevokedOutputClaimable_class = NULL;
8865 static jmethodID LDKBalance_CounterpartyRevokedOutputClaimable_meth = NULL;
8866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init (JNIEnv *env, jclass clz) {
8867         LDKBalance_ClaimableOnChannelClose_class =
8868                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableOnChannelClose"));
8869         CHECK(LDKBalance_ClaimableOnChannelClose_class != NULL);
8870         LDKBalance_ClaimableOnChannelClose_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableOnChannelClose_class, "<init>", "(J)V");
8871         CHECK(LDKBalance_ClaimableOnChannelClose_meth != NULL);
8872         LDKBalance_ClaimableAwaitingConfirmations_class =
8873                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableAwaitingConfirmations"));
8874         CHECK(LDKBalance_ClaimableAwaitingConfirmations_class != NULL);
8875         LDKBalance_ClaimableAwaitingConfirmations_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableAwaitingConfirmations_class, "<init>", "(JI)V");
8876         CHECK(LDKBalance_ClaimableAwaitingConfirmations_meth != NULL);
8877         LDKBalance_ContentiousClaimable_class =
8878                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ContentiousClaimable"));
8879         CHECK(LDKBalance_ContentiousClaimable_class != NULL);
8880         LDKBalance_ContentiousClaimable_meth = (*env)->GetMethodID(env, LDKBalance_ContentiousClaimable_class, "<init>", "(JI)V");
8881         CHECK(LDKBalance_ContentiousClaimable_meth != NULL);
8882         LDKBalance_MaybeTimeoutClaimableHTLC_class =
8883                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$MaybeTimeoutClaimableHTLC"));
8884         CHECK(LDKBalance_MaybeTimeoutClaimableHTLC_class != NULL);
8885         LDKBalance_MaybeTimeoutClaimableHTLC_meth = (*env)->GetMethodID(env, LDKBalance_MaybeTimeoutClaimableHTLC_class, "<init>", "(JI)V");
8886         CHECK(LDKBalance_MaybeTimeoutClaimableHTLC_meth != NULL);
8887         LDKBalance_MaybePreimageClaimableHTLC_class =
8888                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$MaybePreimageClaimableHTLC"));
8889         CHECK(LDKBalance_MaybePreimageClaimableHTLC_class != NULL);
8890         LDKBalance_MaybePreimageClaimableHTLC_meth = (*env)->GetMethodID(env, LDKBalance_MaybePreimageClaimableHTLC_class, "<init>", "(JI)V");
8891         CHECK(LDKBalance_MaybePreimageClaimableHTLC_meth != NULL);
8892         LDKBalance_CounterpartyRevokedOutputClaimable_class =
8893                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$CounterpartyRevokedOutputClaimable"));
8894         CHECK(LDKBalance_CounterpartyRevokedOutputClaimable_class != NULL);
8895         LDKBalance_CounterpartyRevokedOutputClaimable_meth = (*env)->GetMethodID(env, LDKBalance_CounterpartyRevokedOutputClaimable_class, "<init>", "(J)V");
8896         CHECK(LDKBalance_CounterpartyRevokedOutputClaimable_meth != NULL);
8897 }
8898 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8899         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
8900         switch(obj->tag) {
8901                 case LDKBalance_ClaimableOnChannelClose: {
8902                         int64_t claimable_amount_satoshis_conv = obj->claimable_on_channel_close.claimable_amount_satoshis;
8903                         return (*env)->NewObject(env, LDKBalance_ClaimableOnChannelClose_class, LDKBalance_ClaimableOnChannelClose_meth, claimable_amount_satoshis_conv);
8904                 }
8905                 case LDKBalance_ClaimableAwaitingConfirmations: {
8906                         int64_t claimable_amount_satoshis_conv = obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
8907                         int32_t confirmation_height_conv = obj->claimable_awaiting_confirmations.confirmation_height;
8908                         return (*env)->NewObject(env, LDKBalance_ClaimableAwaitingConfirmations_class, LDKBalance_ClaimableAwaitingConfirmations_meth, claimable_amount_satoshis_conv, confirmation_height_conv);
8909                 }
8910                 case LDKBalance_ContentiousClaimable: {
8911                         int64_t claimable_amount_satoshis_conv = obj->contentious_claimable.claimable_amount_satoshis;
8912                         int32_t timeout_height_conv = obj->contentious_claimable.timeout_height;
8913                         return (*env)->NewObject(env, LDKBalance_ContentiousClaimable_class, LDKBalance_ContentiousClaimable_meth, claimable_amount_satoshis_conv, timeout_height_conv);
8914                 }
8915                 case LDKBalance_MaybeTimeoutClaimableHTLC: {
8916                         int64_t claimable_amount_satoshis_conv = obj->maybe_timeout_claimable_htlc.claimable_amount_satoshis;
8917                         int32_t claimable_height_conv = obj->maybe_timeout_claimable_htlc.claimable_height;
8918                         return (*env)->NewObject(env, LDKBalance_MaybeTimeoutClaimableHTLC_class, LDKBalance_MaybeTimeoutClaimableHTLC_meth, claimable_amount_satoshis_conv, claimable_height_conv);
8919                 }
8920                 case LDKBalance_MaybePreimageClaimableHTLC: {
8921                         int64_t claimable_amount_satoshis_conv = obj->maybe_preimage_claimable_htlc.claimable_amount_satoshis;
8922                         int32_t expiry_height_conv = obj->maybe_preimage_claimable_htlc.expiry_height;
8923                         return (*env)->NewObject(env, LDKBalance_MaybePreimageClaimableHTLC_class, LDKBalance_MaybePreimageClaimableHTLC_meth, claimable_amount_satoshis_conv, expiry_height_conv);
8924                 }
8925                 case LDKBalance_CounterpartyRevokedOutputClaimable: {
8926                         int64_t claimable_amount_satoshis_conv = obj->counterparty_revoked_output_claimable.claimable_amount_satoshis;
8927                         return (*env)->NewObject(env, LDKBalance_CounterpartyRevokedOutputClaimable_class, LDKBalance_CounterpartyRevokedOutputClaimable_meth, claimable_amount_satoshis_conv);
8928                 }
8929                 default: abort();
8930         }
8931 }
8932 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
8933         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
8934         for (size_t i = 0; i < ret.datalen; i++) {
8935                 ret.data[i] = Balance_clone(&orig->data[i]);
8936         }
8937         return ret;
8938 }
8939 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
8940 CHECK(owner->result_ok);
8941         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
8942 }
8943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8944         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(owner);
8945         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
8946         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
8947         return tag_ptr(ret_conv, true);
8948 }
8949
8950 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
8951 CHECK(!owner->result_ok);
8952         return DecodeError_clone(&*owner->contents.err);
8953 }
8954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8955         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(owner);
8956         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8957         *ret_copy = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
8958         int64_t ret_ref = tag_ptr(ret_copy, true);
8959         return ret_ref;
8960 }
8961
8962 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
8963         return owner->a;
8964 }
8965 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8966         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(owner);
8967         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
8968         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form);
8969         return ret_arr;
8970 }
8971
8972 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
8973         return Type_clone(&owner->b);
8974 }
8975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8976         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(owner);
8977         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
8978         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
8979         return tag_ptr(ret_ret, true);
8980 }
8981
8982 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
8983         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
8984         for (size_t i = 0; i < ret.datalen; i++) {
8985                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
8986         }
8987         return ret;
8988 }
8989 typedef struct LDKCustomOnionMessageContents_JCalls {
8990         atomic_size_t refcnt;
8991         JavaVM *vm;
8992         jweak o;
8993         jmethodID tlv_type_meth;
8994         jmethodID write_meth;
8995 } LDKCustomOnionMessageContents_JCalls;
8996 static void LDKCustomOnionMessageContents_JCalls_free(void* this_arg) {
8997         LDKCustomOnionMessageContents_JCalls *j_calls = (LDKCustomOnionMessageContents_JCalls*) this_arg;
8998         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8999                 JNIEnv *env;
9000                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9001                 if (get_jenv_res == JNI_EDETACHED) {
9002                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9003                 } else {
9004                         DO_ASSERT(get_jenv_res == JNI_OK);
9005                 }
9006                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9007                 if (get_jenv_res == JNI_EDETACHED) {
9008                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9009                 }
9010                 FREE(j_calls);
9011         }
9012 }
9013 uint64_t tlv_type_LDKCustomOnionMessageContents_jcall(const void* this_arg) {
9014         LDKCustomOnionMessageContents_JCalls *j_calls = (LDKCustomOnionMessageContents_JCalls*) this_arg;
9015         JNIEnv *env;
9016         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9017         if (get_jenv_res == JNI_EDETACHED) {
9018                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9019         } else {
9020                 DO_ASSERT(get_jenv_res == JNI_OK);
9021         }
9022         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9023         CHECK(obj != NULL);
9024         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->tlv_type_meth);
9025         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9026                 (*env)->ExceptionDescribe(env);
9027                 (*env)->FatalError(env, "A call to tlv_type in LDKCustomOnionMessageContents from rust threw an exception.");
9028         }
9029         if (get_jenv_res == JNI_EDETACHED) {
9030                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9031         }
9032         return ret;
9033 }
9034 LDKCVec_u8Z write_LDKCustomOnionMessageContents_jcall(const void* this_arg) {
9035         LDKCustomOnionMessageContents_JCalls *j_calls = (LDKCustomOnionMessageContents_JCalls*) this_arg;
9036         JNIEnv *env;
9037         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9038         if (get_jenv_res == JNI_EDETACHED) {
9039                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9040         } else {
9041                 DO_ASSERT(get_jenv_res == JNI_OK);
9042         }
9043         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9044         CHECK(obj != NULL);
9045         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
9046         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9047                 (*env)->ExceptionDescribe(env);
9048                 (*env)->FatalError(env, "A call to write in LDKCustomOnionMessageContents from rust threw an exception.");
9049         }
9050         LDKCVec_u8Z ret_ref;
9051         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
9052         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
9053         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
9054         if (get_jenv_res == JNI_EDETACHED) {
9055                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9056         }
9057         return ret_ref;
9058 }
9059 static void LDKCustomOnionMessageContents_JCalls_cloned(LDKCustomOnionMessageContents* new_obj) {
9060         LDKCustomOnionMessageContents_JCalls *j_calls = (LDKCustomOnionMessageContents_JCalls*) new_obj->this_arg;
9061         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9062 }
9063 static inline LDKCustomOnionMessageContents LDKCustomOnionMessageContents_init (JNIEnv *env, jclass clz, jobject o) {
9064         jclass c = (*env)->GetObjectClass(env, o);
9065         CHECK(c != NULL);
9066         LDKCustomOnionMessageContents_JCalls *calls = MALLOC(sizeof(LDKCustomOnionMessageContents_JCalls), "LDKCustomOnionMessageContents_JCalls");
9067         atomic_init(&calls->refcnt, 1);
9068         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9069         calls->o = (*env)->NewWeakGlobalRef(env, o);
9070         calls->tlv_type_meth = (*env)->GetMethodID(env, c, "tlv_type", "()J");
9071         CHECK(calls->tlv_type_meth != NULL);
9072         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
9073         CHECK(calls->write_meth != NULL);
9074
9075         LDKCustomOnionMessageContents ret = {
9076                 .this_arg = (void*) calls,
9077                 .tlv_type = tlv_type_LDKCustomOnionMessageContents_jcall,
9078                 .write = write_LDKCustomOnionMessageContents_jcall,
9079                 .cloned = LDKCustomOnionMessageContents_JCalls_cloned,
9080                 .free = LDKCustomOnionMessageContents_JCalls_free,
9081         };
9082         return ret;
9083 }
9084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomOnionMessageContents_1new(JNIEnv *env, jclass clz, jobject o) {
9085         LDKCustomOnionMessageContents *res_ptr = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
9086         *res_ptr = LDKCustomOnionMessageContents_init(env, clz, o);
9087         return tag_ptr(res_ptr, true);
9088 }
9089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1tlv_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
9090         void* this_arg_ptr = untag_ptr(this_arg);
9091         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9092         LDKCustomOnionMessageContents* this_arg_conv = (LDKCustomOnionMessageContents*)this_arg_ptr;
9093         int64_t ret_conv = (this_arg_conv->tlv_type)(this_arg_conv->this_arg);
9094         return ret_conv;
9095 }
9096
9097 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
9098         void* this_arg_ptr = untag_ptr(this_arg);
9099         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9100         LDKCustomOnionMessageContents* this_arg_conv = (LDKCustomOnionMessageContents*)this_arg_ptr;
9101         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
9102         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
9103         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
9104         CVec_u8Z_free(ret_var);
9105         return ret_arr;
9106 }
9107
9108 static jclass LDKCOption_CustomOnionMessageContentsZ_Some_class = NULL;
9109 static jmethodID LDKCOption_CustomOnionMessageContentsZ_Some_meth = NULL;
9110 static jclass LDKCOption_CustomOnionMessageContentsZ_None_class = NULL;
9111 static jmethodID LDKCOption_CustomOnionMessageContentsZ_None_meth = NULL;
9112 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CustomOnionMessageContentsZ_init (JNIEnv *env, jclass clz) {
9113         LDKCOption_CustomOnionMessageContentsZ_Some_class =
9114                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CustomOnionMessageContentsZ$Some"));
9115         CHECK(LDKCOption_CustomOnionMessageContentsZ_Some_class != NULL);
9116         LDKCOption_CustomOnionMessageContentsZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CustomOnionMessageContentsZ_Some_class, "<init>", "(J)V");
9117         CHECK(LDKCOption_CustomOnionMessageContentsZ_Some_meth != NULL);
9118         LDKCOption_CustomOnionMessageContentsZ_None_class =
9119                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CustomOnionMessageContentsZ$None"));
9120         CHECK(LDKCOption_CustomOnionMessageContentsZ_None_class != NULL);
9121         LDKCOption_CustomOnionMessageContentsZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CustomOnionMessageContentsZ_None_class, "<init>", "()V");
9122         CHECK(LDKCOption_CustomOnionMessageContentsZ_None_meth != NULL);
9123 }
9124 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CustomOnionMessageContentsZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9125         LDKCOption_CustomOnionMessageContentsZ *obj = (LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(ptr);
9126         switch(obj->tag) {
9127                 case LDKCOption_CustomOnionMessageContentsZ_Some: {
9128                         LDKCustomOnionMessageContents* some_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
9129                         *some_ret = CustomOnionMessageContents_clone(&obj->some);
9130                         return (*env)->NewObject(env, LDKCOption_CustomOnionMessageContentsZ_Some_class, LDKCOption_CustomOnionMessageContentsZ_Some_meth, tag_ptr(some_ret, true));
9131                 }
9132                 case LDKCOption_CustomOnionMessageContentsZ_None: {
9133                         return (*env)->NewObject(env, LDKCOption_CustomOnionMessageContentsZ_None_class, LDKCOption_CustomOnionMessageContentsZ_None_meth);
9134                 }
9135                 default: abort();
9136         }
9137 }
9138 static inline struct LDKCOption_CustomOnionMessageContentsZ CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_get_ok(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ *NONNULL_PTR owner){
9139 CHECK(owner->result_ok);
9140         return COption_CustomOnionMessageContentsZ_clone(&*owner->contents.result);
9141 }
9142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9143         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* owner_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(owner);
9144         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
9145         *ret_copy = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_get_ok(owner_conv);
9146         int64_t ret_ref = tag_ptr(ret_copy, true);
9147         return ret_ref;
9148 }
9149
9150 static inline struct LDKDecodeError CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_get_err(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ *NONNULL_PTR owner){
9151 CHECK(!owner->result_ok);
9152         return DecodeError_clone(&*owner->contents.err);
9153 }
9154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9155         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* owner_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(owner);
9156         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9157         *ret_copy = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_get_err(owner_conv);
9158         int64_t ret_ref = tag_ptr(ret_copy, true);
9159         return ret_ref;
9160 }
9161
9162 static jclass LDKCOption_NetAddressZ_Some_class = NULL;
9163 static jmethodID LDKCOption_NetAddressZ_Some_meth = NULL;
9164 static jclass LDKCOption_NetAddressZ_None_class = NULL;
9165 static jmethodID LDKCOption_NetAddressZ_None_meth = NULL;
9166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetAddressZ_init (JNIEnv *env, jclass clz) {
9167         LDKCOption_NetAddressZ_Some_class =
9168                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$Some"));
9169         CHECK(LDKCOption_NetAddressZ_Some_class != NULL);
9170         LDKCOption_NetAddressZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_Some_class, "<init>", "(J)V");
9171         CHECK(LDKCOption_NetAddressZ_Some_meth != NULL);
9172         LDKCOption_NetAddressZ_None_class =
9173                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$None"));
9174         CHECK(LDKCOption_NetAddressZ_None_class != NULL);
9175         LDKCOption_NetAddressZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_None_class, "<init>", "()V");
9176         CHECK(LDKCOption_NetAddressZ_None_meth != NULL);
9177 }
9178 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetAddressZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9179         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)untag_ptr(ptr);
9180         switch(obj->tag) {
9181                 case LDKCOption_NetAddressZ_Some: {
9182                         int64_t some_ref = tag_ptr(&obj->some, false);
9183                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_Some_class, LDKCOption_NetAddressZ_Some_meth, some_ref);
9184                 }
9185                 case LDKCOption_NetAddressZ_None: {
9186                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_None_class, LDKCOption_NetAddressZ_None_meth);
9187                 }
9188                 default: abort();
9189         }
9190 }
9191 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
9192 CHECK(owner->result_ok);
9193         return CVec_u8Z_clone(&*owner->contents.result);
9194 }
9195 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9196         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(owner);
9197         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
9198         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
9199         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
9200         CVec_u8Z_free(ret_var);
9201         return ret_arr;
9202 }
9203
9204 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
9205         LDKPeerHandleError ret = *owner->contents.err;
9206         ret.is_owned = false;
9207         return ret;
9208 }
9209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9210         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(owner);
9211         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
9212         int64_t ret_ref = 0;
9213         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9214         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9215         return ret_ref;
9216 }
9217
9218 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
9219 CHECK(owner->result_ok);
9220         return *owner->contents.result;
9221 }
9222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9223         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(owner);
9224         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
9225 }
9226
9227 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
9228         LDKPeerHandleError ret = *owner->contents.err;
9229         ret.is_owned = false;
9230         return ret;
9231 }
9232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9233         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(owner);
9234         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
9235         int64_t ret_ref = 0;
9236         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9237         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9238         return ret_ref;
9239 }
9240
9241 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
9242 CHECK(owner->result_ok);
9243         return *owner->contents.result;
9244 }
9245 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9246         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(owner);
9247         jboolean ret_conv = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
9248         return ret_conv;
9249 }
9250
9251 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
9252         LDKPeerHandleError ret = *owner->contents.err;
9253         ret.is_owned = false;
9254         return ret;
9255 }
9256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9257         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(owner);
9258         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
9259         int64_t ret_ref = 0;
9260         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9261         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9262         return ret_ref;
9263 }
9264
9265 static jclass LDKSendError_Secp256k1_class = NULL;
9266 static jmethodID LDKSendError_Secp256k1_meth = NULL;
9267 static jclass LDKSendError_TooBigPacket_class = NULL;
9268 static jmethodID LDKSendError_TooBigPacket_meth = NULL;
9269 static jclass LDKSendError_TooFewBlindedHops_class = NULL;
9270 static jmethodID LDKSendError_TooFewBlindedHops_meth = NULL;
9271 static jclass LDKSendError_InvalidFirstHop_class = NULL;
9272 static jmethodID LDKSendError_InvalidFirstHop_meth = NULL;
9273 static jclass LDKSendError_InvalidMessage_class = NULL;
9274 static jmethodID LDKSendError_InvalidMessage_meth = NULL;
9275 static jclass LDKSendError_BufferFull_class = NULL;
9276 static jmethodID LDKSendError_BufferFull_meth = NULL;
9277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSendError_init (JNIEnv *env, jclass clz) {
9278         LDKSendError_Secp256k1_class =
9279                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$Secp256k1"));
9280         CHECK(LDKSendError_Secp256k1_class != NULL);
9281         LDKSendError_Secp256k1_meth = (*env)->GetMethodID(env, LDKSendError_Secp256k1_class, "<init>", "(Lorg/ldk/enums/Secp256k1Error;)V");
9282         CHECK(LDKSendError_Secp256k1_meth != NULL);
9283         LDKSendError_TooBigPacket_class =
9284                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$TooBigPacket"));
9285         CHECK(LDKSendError_TooBigPacket_class != NULL);
9286         LDKSendError_TooBigPacket_meth = (*env)->GetMethodID(env, LDKSendError_TooBigPacket_class, "<init>", "()V");
9287         CHECK(LDKSendError_TooBigPacket_meth != NULL);
9288         LDKSendError_TooFewBlindedHops_class =
9289                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$TooFewBlindedHops"));
9290         CHECK(LDKSendError_TooFewBlindedHops_class != NULL);
9291         LDKSendError_TooFewBlindedHops_meth = (*env)->GetMethodID(env, LDKSendError_TooFewBlindedHops_class, "<init>", "()V");
9292         CHECK(LDKSendError_TooFewBlindedHops_meth != NULL);
9293         LDKSendError_InvalidFirstHop_class =
9294                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$InvalidFirstHop"));
9295         CHECK(LDKSendError_InvalidFirstHop_class != NULL);
9296         LDKSendError_InvalidFirstHop_meth = (*env)->GetMethodID(env, LDKSendError_InvalidFirstHop_class, "<init>", "()V");
9297         CHECK(LDKSendError_InvalidFirstHop_meth != NULL);
9298         LDKSendError_InvalidMessage_class =
9299                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$InvalidMessage"));
9300         CHECK(LDKSendError_InvalidMessage_class != NULL);
9301         LDKSendError_InvalidMessage_meth = (*env)->GetMethodID(env, LDKSendError_InvalidMessage_class, "<init>", "()V");
9302         CHECK(LDKSendError_InvalidMessage_meth != NULL);
9303         LDKSendError_BufferFull_class =
9304                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$BufferFull"));
9305         CHECK(LDKSendError_BufferFull_class != NULL);
9306         LDKSendError_BufferFull_meth = (*env)->GetMethodID(env, LDKSendError_BufferFull_class, "<init>", "()V");
9307         CHECK(LDKSendError_BufferFull_meth != NULL);
9308 }
9309 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSendError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9310         LDKSendError *obj = (LDKSendError*)untag_ptr(ptr);
9311         switch(obj->tag) {
9312                 case LDKSendError_Secp256k1: {
9313                         jclass secp256k1_conv = LDKSecp256k1Error_to_java(env, obj->secp256k1);
9314                         return (*env)->NewObject(env, LDKSendError_Secp256k1_class, LDKSendError_Secp256k1_meth, secp256k1_conv);
9315                 }
9316                 case LDKSendError_TooBigPacket: {
9317                         return (*env)->NewObject(env, LDKSendError_TooBigPacket_class, LDKSendError_TooBigPacket_meth);
9318                 }
9319                 case LDKSendError_TooFewBlindedHops: {
9320                         return (*env)->NewObject(env, LDKSendError_TooFewBlindedHops_class, LDKSendError_TooFewBlindedHops_meth);
9321                 }
9322                 case LDKSendError_InvalidFirstHop: {
9323                         return (*env)->NewObject(env, LDKSendError_InvalidFirstHop_class, LDKSendError_InvalidFirstHop_meth);
9324                 }
9325                 case LDKSendError_InvalidMessage: {
9326                         return (*env)->NewObject(env, LDKSendError_InvalidMessage_class, LDKSendError_InvalidMessage_meth);
9327                 }
9328                 case LDKSendError_BufferFull: {
9329                         return (*env)->NewObject(env, LDKSendError_BufferFull_class, LDKSendError_BufferFull_meth);
9330                 }
9331                 default: abort();
9332         }
9333 }
9334 static inline void CResult_NoneSendErrorZ_get_ok(LDKCResult_NoneSendErrorZ *NONNULL_PTR owner){
9335 CHECK(owner->result_ok);
9336         return *owner->contents.result;
9337 }
9338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9339         LDKCResult_NoneSendErrorZ* owner_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(owner);
9340         CResult_NoneSendErrorZ_get_ok(owner_conv);
9341 }
9342
9343 static inline struct LDKSendError CResult_NoneSendErrorZ_get_err(LDKCResult_NoneSendErrorZ *NONNULL_PTR owner){
9344 CHECK(!owner->result_ok);
9345         return SendError_clone(&*owner->contents.err);
9346 }
9347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9348         LDKCResult_NoneSendErrorZ* owner_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(owner);
9349         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
9350         *ret_copy = CResult_NoneSendErrorZ_get_err(owner_conv);
9351         int64_t ret_ref = tag_ptr(ret_copy, true);
9352         return ret_ref;
9353 }
9354
9355 static jclass LDKGraphSyncError_DecodeError_class = NULL;
9356 static jmethodID LDKGraphSyncError_DecodeError_meth = NULL;
9357 static jclass LDKGraphSyncError_LightningError_class = NULL;
9358 static jmethodID LDKGraphSyncError_LightningError_meth = NULL;
9359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKGraphSyncError_init (JNIEnv *env, jclass clz) {
9360         LDKGraphSyncError_DecodeError_class =
9361                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGraphSyncError$DecodeError"));
9362         CHECK(LDKGraphSyncError_DecodeError_class != NULL);
9363         LDKGraphSyncError_DecodeError_meth = (*env)->GetMethodID(env, LDKGraphSyncError_DecodeError_class, "<init>", "(J)V");
9364         CHECK(LDKGraphSyncError_DecodeError_meth != NULL);
9365         LDKGraphSyncError_LightningError_class =
9366                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGraphSyncError$LightningError"));
9367         CHECK(LDKGraphSyncError_LightningError_class != NULL);
9368         LDKGraphSyncError_LightningError_meth = (*env)->GetMethodID(env, LDKGraphSyncError_LightningError_class, "<init>", "(J)V");
9369         CHECK(LDKGraphSyncError_LightningError_meth != NULL);
9370 }
9371 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKGraphSyncError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9372         LDKGraphSyncError *obj = (LDKGraphSyncError*)untag_ptr(ptr);
9373         switch(obj->tag) {
9374                 case LDKGraphSyncError_DecodeError: {
9375                         int64_t decode_error_ref = tag_ptr(&obj->decode_error, false);
9376                         return (*env)->NewObject(env, LDKGraphSyncError_DecodeError_class, LDKGraphSyncError_DecodeError_meth, decode_error_ref);
9377                 }
9378                 case LDKGraphSyncError_LightningError: {
9379                         LDKLightningError lightning_error_var = obj->lightning_error;
9380                         int64_t lightning_error_ref = 0;
9381                         CHECK_INNER_FIELD_ACCESS_OR_NULL(lightning_error_var);
9382                         lightning_error_ref = tag_ptr(lightning_error_var.inner, false);
9383                         return (*env)->NewObject(env, LDKGraphSyncError_LightningError_class, LDKGraphSyncError_LightningError_meth, lightning_error_ref);
9384                 }
9385                 default: abort();
9386         }
9387 }
9388 static inline uint32_t CResult_u32GraphSyncErrorZ_get_ok(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
9389 CHECK(owner->result_ok);
9390         return *owner->contents.result;
9391 }
9392 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9393         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(owner);
9394         int32_t ret_conv = CResult_u32GraphSyncErrorZ_get_ok(owner_conv);
9395         return ret_conv;
9396 }
9397
9398 static inline struct LDKGraphSyncError CResult_u32GraphSyncErrorZ_get_err(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
9399 CHECK(!owner->result_ok);
9400         return GraphSyncError_clone(&*owner->contents.err);
9401 }
9402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9403         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(owner);
9404         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
9405         *ret_copy = CResult_u32GraphSyncErrorZ_get_err(owner_conv);
9406         int64_t ret_ref = tag_ptr(ret_copy, true);
9407         return ret_ref;
9408 }
9409
9410 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
9411 CHECK(owner->result_ok);
9412         return NetAddress_clone(&*owner->contents.result);
9413 }
9414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9415         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(owner);
9416         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
9417         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
9418         int64_t ret_ref = tag_ptr(ret_copy, true);
9419         return ret_ref;
9420 }
9421
9422 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
9423 CHECK(!owner->result_ok);
9424         return DecodeError_clone(&*owner->contents.err);
9425 }
9426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9427         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(owner);
9428         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9429         *ret_copy = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
9430         int64_t ret_ref = tag_ptr(ret_copy, true);
9431         return ret_ref;
9432 }
9433
9434 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
9435         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
9436         for (size_t i = 0; i < ret.datalen; i++) {
9437                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
9438         }
9439         return ret;
9440 }
9441 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
9442         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
9443         for (size_t i = 0; i < ret.datalen; i++) {
9444                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
9445         }
9446         return ret;
9447 }
9448 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
9449         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
9450         for (size_t i = 0; i < ret.datalen; i++) {
9451                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
9452         }
9453         return ret;
9454 }
9455 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
9456         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
9457         for (size_t i = 0; i < ret.datalen; i++) {
9458                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
9459         }
9460         return ret;
9461 }
9462 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
9463         LDKAcceptChannel ret = *owner->contents.result;
9464         ret.is_owned = false;
9465         return ret;
9466 }
9467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9468         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(owner);
9469         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
9470         int64_t ret_ref = 0;
9471         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9472         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9473         return ret_ref;
9474 }
9475
9476 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
9477 CHECK(!owner->result_ok);
9478         return DecodeError_clone(&*owner->contents.err);
9479 }
9480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9481         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(owner);
9482         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9483         *ret_copy = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
9484         int64_t ret_ref = tag_ptr(ret_copy, true);
9485         return ret_ref;
9486 }
9487
9488 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
9489         LDKAnnouncementSignatures ret = *owner->contents.result;
9490         ret.is_owned = false;
9491         return ret;
9492 }
9493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9494         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(owner);
9495         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
9496         int64_t ret_ref = 0;
9497         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9498         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9499         return ret_ref;
9500 }
9501
9502 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
9503 CHECK(!owner->result_ok);
9504         return DecodeError_clone(&*owner->contents.err);
9505 }
9506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9507         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(owner);
9508         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9509         *ret_copy = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
9510         int64_t ret_ref = tag_ptr(ret_copy, true);
9511         return ret_ref;
9512 }
9513
9514 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
9515         LDKChannelReestablish ret = *owner->contents.result;
9516         ret.is_owned = false;
9517         return ret;
9518 }
9519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9520         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(owner);
9521         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
9522         int64_t ret_ref = 0;
9523         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9524         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9525         return ret_ref;
9526 }
9527
9528 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
9529 CHECK(!owner->result_ok);
9530         return DecodeError_clone(&*owner->contents.err);
9531 }
9532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9533         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(owner);
9534         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9535         *ret_copy = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
9536         int64_t ret_ref = tag_ptr(ret_copy, true);
9537         return ret_ref;
9538 }
9539
9540 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
9541         LDKClosingSigned ret = *owner->contents.result;
9542         ret.is_owned = false;
9543         return ret;
9544 }
9545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9546         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(owner);
9547         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
9548         int64_t ret_ref = 0;
9549         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9550         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9551         return ret_ref;
9552 }
9553
9554 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
9555 CHECK(!owner->result_ok);
9556         return DecodeError_clone(&*owner->contents.err);
9557 }
9558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9559         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(owner);
9560         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9561         *ret_copy = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
9562         int64_t ret_ref = tag_ptr(ret_copy, true);
9563         return ret_ref;
9564 }
9565
9566 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
9567         LDKClosingSignedFeeRange ret = *owner->contents.result;
9568         ret.is_owned = false;
9569         return ret;
9570 }
9571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9572         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(owner);
9573         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
9574         int64_t ret_ref = 0;
9575         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9576         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9577         return ret_ref;
9578 }
9579
9580 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
9581 CHECK(!owner->result_ok);
9582         return DecodeError_clone(&*owner->contents.err);
9583 }
9584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9585         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(owner);
9586         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9587         *ret_copy = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
9588         int64_t ret_ref = tag_ptr(ret_copy, true);
9589         return ret_ref;
9590 }
9591
9592 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
9593         LDKCommitmentSigned ret = *owner->contents.result;
9594         ret.is_owned = false;
9595         return ret;
9596 }
9597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9598         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(owner);
9599         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
9600         int64_t ret_ref = 0;
9601         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9602         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9603         return ret_ref;
9604 }
9605
9606 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
9607 CHECK(!owner->result_ok);
9608         return DecodeError_clone(&*owner->contents.err);
9609 }
9610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9611         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(owner);
9612         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9613         *ret_copy = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
9614         int64_t ret_ref = tag_ptr(ret_copy, true);
9615         return ret_ref;
9616 }
9617
9618 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
9619         LDKFundingCreated ret = *owner->contents.result;
9620         ret.is_owned = false;
9621         return ret;
9622 }
9623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9624         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(owner);
9625         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
9626         int64_t ret_ref = 0;
9627         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9628         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9629         return ret_ref;
9630 }
9631
9632 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
9633 CHECK(!owner->result_ok);
9634         return DecodeError_clone(&*owner->contents.err);
9635 }
9636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9637         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(owner);
9638         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9639         *ret_copy = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
9640         int64_t ret_ref = tag_ptr(ret_copy, true);
9641         return ret_ref;
9642 }
9643
9644 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
9645         LDKFundingSigned ret = *owner->contents.result;
9646         ret.is_owned = false;
9647         return ret;
9648 }
9649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9650         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(owner);
9651         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
9652         int64_t ret_ref = 0;
9653         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9654         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9655         return ret_ref;
9656 }
9657
9658 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
9659 CHECK(!owner->result_ok);
9660         return DecodeError_clone(&*owner->contents.err);
9661 }
9662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9663         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(owner);
9664         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9665         *ret_copy = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
9666         int64_t ret_ref = tag_ptr(ret_copy, true);
9667         return ret_ref;
9668 }
9669
9670 static inline struct LDKChannelReady CResult_ChannelReadyDecodeErrorZ_get_ok(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
9671         LDKChannelReady ret = *owner->contents.result;
9672         ret.is_owned = false;
9673         return ret;
9674 }
9675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9676         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(owner);
9677         LDKChannelReady ret_var = CResult_ChannelReadyDecodeErrorZ_get_ok(owner_conv);
9678         int64_t ret_ref = 0;
9679         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9680         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9681         return ret_ref;
9682 }
9683
9684 static inline struct LDKDecodeError CResult_ChannelReadyDecodeErrorZ_get_err(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
9685 CHECK(!owner->result_ok);
9686         return DecodeError_clone(&*owner->contents.err);
9687 }
9688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9689         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(owner);
9690         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9691         *ret_copy = CResult_ChannelReadyDecodeErrorZ_get_err(owner_conv);
9692         int64_t ret_ref = tag_ptr(ret_copy, true);
9693         return ret_ref;
9694 }
9695
9696 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
9697         LDKInit ret = *owner->contents.result;
9698         ret.is_owned = false;
9699         return ret;
9700 }
9701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9702         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(owner);
9703         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
9704         int64_t ret_ref = 0;
9705         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9706         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9707         return ret_ref;
9708 }
9709
9710 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
9711 CHECK(!owner->result_ok);
9712         return DecodeError_clone(&*owner->contents.err);
9713 }
9714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9715         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(owner);
9716         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9717         *ret_copy = CResult_InitDecodeErrorZ_get_err(owner_conv);
9718         int64_t ret_ref = tag_ptr(ret_copy, true);
9719         return ret_ref;
9720 }
9721
9722 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
9723         LDKOpenChannel ret = *owner->contents.result;
9724         ret.is_owned = false;
9725         return ret;
9726 }
9727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9728         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(owner);
9729         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
9730         int64_t ret_ref = 0;
9731         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9732         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9733         return ret_ref;
9734 }
9735
9736 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
9737 CHECK(!owner->result_ok);
9738         return DecodeError_clone(&*owner->contents.err);
9739 }
9740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9741         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(owner);
9742         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9743         *ret_copy = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
9744         int64_t ret_ref = tag_ptr(ret_copy, true);
9745         return ret_ref;
9746 }
9747
9748 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
9749         LDKRevokeAndACK ret = *owner->contents.result;
9750         ret.is_owned = false;
9751         return ret;
9752 }
9753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9754         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(owner);
9755         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
9756         int64_t ret_ref = 0;
9757         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9758         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9759         return ret_ref;
9760 }
9761
9762 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
9763 CHECK(!owner->result_ok);
9764         return DecodeError_clone(&*owner->contents.err);
9765 }
9766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9767         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(owner);
9768         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9769         *ret_copy = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
9770         int64_t ret_ref = tag_ptr(ret_copy, true);
9771         return ret_ref;
9772 }
9773
9774 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
9775         LDKShutdown ret = *owner->contents.result;
9776         ret.is_owned = false;
9777         return ret;
9778 }
9779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9780         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(owner);
9781         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
9782         int64_t ret_ref = 0;
9783         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9784         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9785         return ret_ref;
9786 }
9787
9788 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
9789 CHECK(!owner->result_ok);
9790         return DecodeError_clone(&*owner->contents.err);
9791 }
9792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9793         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(owner);
9794         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9795         *ret_copy = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
9796         int64_t ret_ref = tag_ptr(ret_copy, true);
9797         return ret_ref;
9798 }
9799
9800 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
9801         LDKUpdateFailHTLC ret = *owner->contents.result;
9802         ret.is_owned = false;
9803         return ret;
9804 }
9805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9806         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(owner);
9807         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
9808         int64_t ret_ref = 0;
9809         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9810         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9811         return ret_ref;
9812 }
9813
9814 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
9815 CHECK(!owner->result_ok);
9816         return DecodeError_clone(&*owner->contents.err);
9817 }
9818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9819         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(owner);
9820         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9821         *ret_copy = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
9822         int64_t ret_ref = tag_ptr(ret_copy, true);
9823         return ret_ref;
9824 }
9825
9826 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
9827         LDKUpdateFailMalformedHTLC ret = *owner->contents.result;
9828         ret.is_owned = false;
9829         return ret;
9830 }
9831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9832         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(owner);
9833         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
9834         int64_t ret_ref = 0;
9835         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9836         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9837         return ret_ref;
9838 }
9839
9840 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
9841 CHECK(!owner->result_ok);
9842         return DecodeError_clone(&*owner->contents.err);
9843 }
9844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9845         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(owner);
9846         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9847         *ret_copy = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
9848         int64_t ret_ref = tag_ptr(ret_copy, true);
9849         return ret_ref;
9850 }
9851
9852 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
9853         LDKUpdateFee ret = *owner->contents.result;
9854         ret.is_owned = false;
9855         return ret;
9856 }
9857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9858         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(owner);
9859         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
9860         int64_t ret_ref = 0;
9861         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9862         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9863         return ret_ref;
9864 }
9865
9866 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
9867 CHECK(!owner->result_ok);
9868         return DecodeError_clone(&*owner->contents.err);
9869 }
9870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9871         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(owner);
9872         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9873         *ret_copy = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
9874         int64_t ret_ref = tag_ptr(ret_copy, true);
9875         return ret_ref;
9876 }
9877
9878 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
9879         LDKUpdateFulfillHTLC ret = *owner->contents.result;
9880         ret.is_owned = false;
9881         return ret;
9882 }
9883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9884         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(owner);
9885         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
9886         int64_t ret_ref = 0;
9887         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9888         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9889         return ret_ref;
9890 }
9891
9892 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
9893 CHECK(!owner->result_ok);
9894         return DecodeError_clone(&*owner->contents.err);
9895 }
9896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9897         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(owner);
9898         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9899         *ret_copy = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
9900         int64_t ret_ref = tag_ptr(ret_copy, true);
9901         return ret_ref;
9902 }
9903
9904 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
9905         LDKUpdateAddHTLC ret = *owner->contents.result;
9906         ret.is_owned = false;
9907         return ret;
9908 }
9909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9910         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(owner);
9911         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
9912         int64_t ret_ref = 0;
9913         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9914         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9915         return ret_ref;
9916 }
9917
9918 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
9919 CHECK(!owner->result_ok);
9920         return DecodeError_clone(&*owner->contents.err);
9921 }
9922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9923         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(owner);
9924         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9925         *ret_copy = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
9926         int64_t ret_ref = tag_ptr(ret_copy, true);
9927         return ret_ref;
9928 }
9929
9930 static inline struct LDKOnionMessage CResult_OnionMessageDecodeErrorZ_get_ok(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR owner){
9931         LDKOnionMessage ret = *owner->contents.result;
9932         ret.is_owned = false;
9933         return ret;
9934 }
9935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9936         LDKCResult_OnionMessageDecodeErrorZ* owner_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(owner);
9937         LDKOnionMessage ret_var = CResult_OnionMessageDecodeErrorZ_get_ok(owner_conv);
9938         int64_t ret_ref = 0;
9939         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9940         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9941         return ret_ref;
9942 }
9943
9944 static inline struct LDKDecodeError CResult_OnionMessageDecodeErrorZ_get_err(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR owner){
9945 CHECK(!owner->result_ok);
9946         return DecodeError_clone(&*owner->contents.err);
9947 }
9948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9949         LDKCResult_OnionMessageDecodeErrorZ* owner_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(owner);
9950         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9951         *ret_copy = CResult_OnionMessageDecodeErrorZ_get_err(owner_conv);
9952         int64_t ret_ref = tag_ptr(ret_copy, true);
9953         return ret_ref;
9954 }
9955
9956 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
9957         LDKPing ret = *owner->contents.result;
9958         ret.is_owned = false;
9959         return ret;
9960 }
9961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9962         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(owner);
9963         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
9964         int64_t ret_ref = 0;
9965         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9966         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9967         return ret_ref;
9968 }
9969
9970 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
9971 CHECK(!owner->result_ok);
9972         return DecodeError_clone(&*owner->contents.err);
9973 }
9974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9975         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(owner);
9976         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9977         *ret_copy = CResult_PingDecodeErrorZ_get_err(owner_conv);
9978         int64_t ret_ref = tag_ptr(ret_copy, true);
9979         return ret_ref;
9980 }
9981
9982 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
9983         LDKPong ret = *owner->contents.result;
9984         ret.is_owned = false;
9985         return ret;
9986 }
9987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9988         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(owner);
9989         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
9990         int64_t ret_ref = 0;
9991         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9992         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9993         return ret_ref;
9994 }
9995
9996 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
9997 CHECK(!owner->result_ok);
9998         return DecodeError_clone(&*owner->contents.err);
9999 }
10000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10001         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(owner);
10002         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10003         *ret_copy = CResult_PongDecodeErrorZ_get_err(owner_conv);
10004         int64_t ret_ref = tag_ptr(ret_copy, true);
10005         return ret_ref;
10006 }
10007
10008 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10009         LDKUnsignedChannelAnnouncement ret = *owner->contents.result;
10010         ret.is_owned = false;
10011         return ret;
10012 }
10013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10014         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
10015         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
10016         int64_t ret_ref = 0;
10017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10018         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10019         return ret_ref;
10020 }
10021
10022 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10023 CHECK(!owner->result_ok);
10024         return DecodeError_clone(&*owner->contents.err);
10025 }
10026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10027         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
10028         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10029         *ret_copy = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
10030         int64_t ret_ref = tag_ptr(ret_copy, true);
10031         return ret_ref;
10032 }
10033
10034 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10035         LDKChannelAnnouncement ret = *owner->contents.result;
10036         ret.is_owned = false;
10037         return ret;
10038 }
10039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10040         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
10041         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
10042         int64_t ret_ref = 0;
10043         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10044         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10045         return ret_ref;
10046 }
10047
10048 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10049 CHECK(!owner->result_ok);
10050         return DecodeError_clone(&*owner->contents.err);
10051 }
10052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10053         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
10054         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10055         *ret_copy = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
10056         int64_t ret_ref = tag_ptr(ret_copy, true);
10057         return ret_ref;
10058 }
10059
10060 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
10061         LDKUnsignedChannelUpdate ret = *owner->contents.result;
10062         ret.is_owned = false;
10063         return ret;
10064 }
10065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10066         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(owner);
10067         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
10068         int64_t ret_ref = 0;
10069         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10070         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10071         return ret_ref;
10072 }
10073
10074 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
10075 CHECK(!owner->result_ok);
10076         return DecodeError_clone(&*owner->contents.err);
10077 }
10078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10079         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(owner);
10080         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10081         *ret_copy = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
10082         int64_t ret_ref = tag_ptr(ret_copy, true);
10083         return ret_ref;
10084 }
10085
10086 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
10087         LDKChannelUpdate ret = *owner->contents.result;
10088         ret.is_owned = false;
10089         return ret;
10090 }
10091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10092         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(owner);
10093         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
10094         int64_t ret_ref = 0;
10095         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10096         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10097         return ret_ref;
10098 }
10099
10100 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
10101 CHECK(!owner->result_ok);
10102         return DecodeError_clone(&*owner->contents.err);
10103 }
10104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10105         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(owner);
10106         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10107         *ret_copy = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
10108         int64_t ret_ref = tag_ptr(ret_copy, true);
10109         return ret_ref;
10110 }
10111
10112 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
10113         LDKErrorMessage ret = *owner->contents.result;
10114         ret.is_owned = false;
10115         return ret;
10116 }
10117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10118         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(owner);
10119         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
10120         int64_t ret_ref = 0;
10121         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10122         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10123         return ret_ref;
10124 }
10125
10126 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
10127 CHECK(!owner->result_ok);
10128         return DecodeError_clone(&*owner->contents.err);
10129 }
10130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10131         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(owner);
10132         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10133         *ret_copy = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
10134         int64_t ret_ref = tag_ptr(ret_copy, true);
10135         return ret_ref;
10136 }
10137
10138 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
10139         LDKWarningMessage ret = *owner->contents.result;
10140         ret.is_owned = false;
10141         return ret;
10142 }
10143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10144         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(owner);
10145         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
10146         int64_t ret_ref = 0;
10147         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10148         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10149         return ret_ref;
10150 }
10151
10152 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
10153 CHECK(!owner->result_ok);
10154         return DecodeError_clone(&*owner->contents.err);
10155 }
10156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10157         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(owner);
10158         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10159         *ret_copy = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
10160         int64_t ret_ref = tag_ptr(ret_copy, true);
10161         return ret_ref;
10162 }
10163
10164 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10165         LDKUnsignedNodeAnnouncement ret = *owner->contents.result;
10166         ret.is_owned = false;
10167         return ret;
10168 }
10169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10170         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
10171         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
10172         int64_t ret_ref = 0;
10173         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10174         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10175         return ret_ref;
10176 }
10177
10178 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10179 CHECK(!owner->result_ok);
10180         return DecodeError_clone(&*owner->contents.err);
10181 }
10182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10183         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
10184         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10185         *ret_copy = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
10186         int64_t ret_ref = tag_ptr(ret_copy, true);
10187         return ret_ref;
10188 }
10189
10190 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10191         LDKNodeAnnouncement ret = *owner->contents.result;
10192         ret.is_owned = false;
10193         return ret;
10194 }
10195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10196         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
10197         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
10198         int64_t ret_ref = 0;
10199         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10200         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10201         return ret_ref;
10202 }
10203
10204 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10205 CHECK(!owner->result_ok);
10206         return DecodeError_clone(&*owner->contents.err);
10207 }
10208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10209         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
10210         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10211         *ret_copy = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
10212         int64_t ret_ref = tag_ptr(ret_copy, true);
10213         return ret_ref;
10214 }
10215
10216 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
10217         LDKQueryShortChannelIds ret = *owner->contents.result;
10218         ret.is_owned = false;
10219         return ret;
10220 }
10221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10222         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(owner);
10223         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
10224         int64_t ret_ref = 0;
10225         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10226         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10227         return ret_ref;
10228 }
10229
10230 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
10231 CHECK(!owner->result_ok);
10232         return DecodeError_clone(&*owner->contents.err);
10233 }
10234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10235         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(owner);
10236         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10237         *ret_copy = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
10238         int64_t ret_ref = tag_ptr(ret_copy, true);
10239         return ret_ref;
10240 }
10241
10242 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
10243         LDKReplyShortChannelIdsEnd ret = *owner->contents.result;
10244         ret.is_owned = false;
10245         return ret;
10246 }
10247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10248         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(owner);
10249         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
10250         int64_t ret_ref = 0;
10251         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10252         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10253         return ret_ref;
10254 }
10255
10256 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
10257 CHECK(!owner->result_ok);
10258         return DecodeError_clone(&*owner->contents.err);
10259 }
10260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10261         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(owner);
10262         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10263         *ret_copy = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
10264         int64_t ret_ref = tag_ptr(ret_copy, true);
10265         return ret_ref;
10266 }
10267
10268 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
10269         LDKQueryChannelRange ret = *owner->contents.result;
10270         ret.is_owned = false;
10271         return ret;
10272 }
10273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10274         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(owner);
10275         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
10276         int64_t ret_ref = 0;
10277         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10278         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10279         return ret_ref;
10280 }
10281
10282 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
10283 CHECK(!owner->result_ok);
10284         return DecodeError_clone(&*owner->contents.err);
10285 }
10286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10287         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(owner);
10288         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10289         *ret_copy = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
10290         int64_t ret_ref = tag_ptr(ret_copy, true);
10291         return ret_ref;
10292 }
10293
10294 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
10295         LDKReplyChannelRange ret = *owner->contents.result;
10296         ret.is_owned = false;
10297         return ret;
10298 }
10299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10300         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(owner);
10301         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
10302         int64_t ret_ref = 0;
10303         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10304         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10305         return ret_ref;
10306 }
10307
10308 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
10309 CHECK(!owner->result_ok);
10310         return DecodeError_clone(&*owner->contents.err);
10311 }
10312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10313         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(owner);
10314         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10315         *ret_copy = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
10316         int64_t ret_ref = tag_ptr(ret_copy, true);
10317         return ret_ref;
10318 }
10319
10320 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
10321         LDKGossipTimestampFilter ret = *owner->contents.result;
10322         ret.is_owned = false;
10323         return ret;
10324 }
10325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10326         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(owner);
10327         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
10328         int64_t ret_ref = 0;
10329         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10330         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10331         return ret_ref;
10332 }
10333
10334 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
10335 CHECK(!owner->result_ok);
10336         return DecodeError_clone(&*owner->contents.err);
10337 }
10338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10339         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(owner);
10340         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10341         *ret_copy = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
10342         int64_t ret_ref = tag_ptr(ret_copy, true);
10343         return ret_ref;
10344 }
10345
10346 static inline LDKCVec_PhantomRouteHintsZ CVec_PhantomRouteHintsZ_clone(const LDKCVec_PhantomRouteHintsZ *orig) {
10347         LDKCVec_PhantomRouteHintsZ ret = { .data = MALLOC(sizeof(LDKPhantomRouteHints) * orig->datalen, "LDKCVec_PhantomRouteHintsZ clone bytes"), .datalen = orig->datalen };
10348         for (size_t i = 0; i < ret.datalen; i++) {
10349                 ret.data[i] = PhantomRouteHints_clone(&orig->data[i]);
10350         }
10351         return ret;
10352 }
10353 static jclass LDKSignOrCreationError_SignError_class = NULL;
10354 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
10355 static jclass LDKSignOrCreationError_CreationError_class = NULL;
10356 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
10357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
10358         LDKSignOrCreationError_SignError_class =
10359                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$SignError"));
10360         CHECK(LDKSignOrCreationError_SignError_class != NULL);
10361         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
10362         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
10363         LDKSignOrCreationError_CreationError_class =
10364                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$CreationError"));
10365         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
10366         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
10367         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
10368 }
10369 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10370         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)untag_ptr(ptr);
10371         switch(obj->tag) {
10372                 case LDKSignOrCreationError_SignError: {
10373                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
10374                 }
10375                 case LDKSignOrCreationError_CreationError: {
10376                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
10377                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
10378                 }
10379                 default: abort();
10380         }
10381 }
10382 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
10383         LDKInvoice ret = *owner->contents.result;
10384         ret.is_owned = false;
10385         return ret;
10386 }
10387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10388         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(owner);
10389         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
10390         int64_t ret_ref = 0;
10391         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10392         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10393         return ret_ref;
10394 }
10395
10396 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
10397 CHECK(!owner->result_ok);
10398         return SignOrCreationError_clone(&*owner->contents.err);
10399 }
10400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10401         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(owner);
10402         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
10403         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
10404         int64_t ret_ref = tag_ptr(ret_copy, true);
10405         return ret_ref;
10406 }
10407
10408 typedef struct LDKFilter_JCalls {
10409         atomic_size_t refcnt;
10410         JavaVM *vm;
10411         jweak o;
10412         jmethodID register_tx_meth;
10413         jmethodID register_output_meth;
10414 } LDKFilter_JCalls;
10415 static void LDKFilter_JCalls_free(void* this_arg) {
10416         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
10417         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10418                 JNIEnv *env;
10419                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10420                 if (get_jenv_res == JNI_EDETACHED) {
10421                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10422                 } else {
10423                         DO_ASSERT(get_jenv_res == JNI_OK);
10424                 }
10425                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10426                 if (get_jenv_res == JNI_EDETACHED) {
10427                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10428                 }
10429                 FREE(j_calls);
10430         }
10431 }
10432 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
10433         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
10434         JNIEnv *env;
10435         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10436         if (get_jenv_res == JNI_EDETACHED) {
10437                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10438         } else {
10439                 DO_ASSERT(get_jenv_res == JNI_OK);
10440         }
10441         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
10442         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
10443         LDKu8slice script_pubkey_var = script_pubkey;
10444         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
10445         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
10446         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10447         CHECK(obj != NULL);
10448         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
10449         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10450                 (*env)->ExceptionDescribe(env);
10451                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
10452         }
10453         if (get_jenv_res == JNI_EDETACHED) {
10454                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10455         }
10456 }
10457 void register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
10458         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
10459         JNIEnv *env;
10460         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10461         if (get_jenv_res == JNI_EDETACHED) {
10462                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10463         } else {
10464                 DO_ASSERT(get_jenv_res == JNI_OK);
10465         }
10466         LDKWatchedOutput output_var = output;
10467         int64_t output_ref = 0;
10468         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
10469         output_ref = tag_ptr(output_var.inner, output_var.is_owned);
10470         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10471         CHECK(obj != NULL);
10472         (*env)->CallVoidMethod(env, obj, j_calls->register_output_meth, output_ref);
10473         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10474                 (*env)->ExceptionDescribe(env);
10475                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
10476         }
10477         if (get_jenv_res == JNI_EDETACHED) {
10478                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10479         }
10480 }
10481 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
10482         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
10483         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10484 }
10485 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
10486         jclass c = (*env)->GetObjectClass(env, o);
10487         CHECK(c != NULL);
10488         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
10489         atomic_init(&calls->refcnt, 1);
10490         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10491         calls->o = (*env)->NewWeakGlobalRef(env, o);
10492         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
10493         CHECK(calls->register_tx_meth != NULL);
10494         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)V");
10495         CHECK(calls->register_output_meth != NULL);
10496
10497         LDKFilter ret = {
10498                 .this_arg = (void*) calls,
10499                 .register_tx = register_tx_LDKFilter_jcall,
10500                 .register_output = register_output_LDKFilter_jcall,
10501                 .free = LDKFilter_JCalls_free,
10502         };
10503         return ret;
10504 }
10505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
10506         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
10507         *res_ptr = LDKFilter_init(env, clz, o);
10508         return tag_ptr(res_ptr, true);
10509 }
10510 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) {
10511         void* this_arg_ptr = untag_ptr(this_arg);
10512         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10513         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
10514         unsigned char txid_arr[32];
10515         CHECK((*env)->GetArrayLength(env, txid) == 32);
10516         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
10517         unsigned char (*txid_ref)[32] = &txid_arr;
10518         LDKu8slice script_pubkey_ref;
10519         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
10520         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
10521         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
10522         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
10523 }
10524
10525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
10526         void* this_arg_ptr = untag_ptr(this_arg);
10527         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10528         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
10529         LDKWatchedOutput output_conv;
10530         output_conv.inner = untag_ptr(output);
10531         output_conv.is_owned = ptr_is_owned(output);
10532         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
10533         output_conv = WatchedOutput_clone(&output_conv);
10534         (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
10535 }
10536
10537 static jclass LDKCOption_FilterZ_Some_class = NULL;
10538 static jmethodID LDKCOption_FilterZ_Some_meth = NULL;
10539 static jclass LDKCOption_FilterZ_None_class = NULL;
10540 static jmethodID LDKCOption_FilterZ_None_meth = NULL;
10541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init (JNIEnv *env, jclass clz) {
10542         LDKCOption_FilterZ_Some_class =
10543                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$Some"));
10544         CHECK(LDKCOption_FilterZ_Some_class != NULL);
10545         LDKCOption_FilterZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_Some_class, "<init>", "(J)V");
10546         CHECK(LDKCOption_FilterZ_Some_meth != NULL);
10547         LDKCOption_FilterZ_None_class =
10548                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$None"));
10549         CHECK(LDKCOption_FilterZ_None_class != NULL);
10550         LDKCOption_FilterZ_None_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_None_class, "<init>", "()V");
10551         CHECK(LDKCOption_FilterZ_None_meth != NULL);
10552 }
10553 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10554         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)untag_ptr(ptr);
10555         switch(obj->tag) {
10556                 case LDKCOption_FilterZ_Some: {
10557                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
10558                         *some_ret = obj->some;
10559                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
10560                         if ((*some_ret).free == LDKFilter_JCalls_free) {
10561                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10562                                 LDKFilter_JCalls_cloned(&(*some_ret));
10563                         }
10564                         return (*env)->NewObject(env, LDKCOption_FilterZ_Some_class, LDKCOption_FilterZ_Some_meth, tag_ptr(some_ret, true));
10565                 }
10566                 case LDKCOption_FilterZ_None: {
10567                         return (*env)->NewObject(env, LDKCOption_FilterZ_None_class, LDKCOption_FilterZ_None_meth);
10568                 }
10569                 default: abort();
10570         }
10571 }
10572 static inline struct LDKLockedChannelMonitor CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
10573         LDKLockedChannelMonitor ret = *owner->contents.result;
10574         ret.is_owned = false;
10575         return ret;
10576 }
10577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10578         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(owner);
10579         LDKLockedChannelMonitor ret_var = CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
10580         int64_t ret_ref = 0;
10581         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10582         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10583         return ret_ref;
10584 }
10585
10586 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
10587 CHECK(!owner->result_ok);
10588         return *owner->contents.err;
10589 }
10590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10591         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(owner);
10592         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
10593 }
10594
10595 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
10596         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
10597         for (size_t i = 0; i < ret.datalen; i++) {
10598                 ret.data[i] = OutPoint_clone(&orig->data[i]);
10599         }
10600         return ret;
10601 }
10602 typedef struct LDKMessageSendEventsProvider_JCalls {
10603         atomic_size_t refcnt;
10604         JavaVM *vm;
10605         jweak o;
10606         jmethodID get_and_clear_pending_msg_events_meth;
10607 } LDKMessageSendEventsProvider_JCalls;
10608 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
10609         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
10610         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10611                 JNIEnv *env;
10612                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10613                 if (get_jenv_res == JNI_EDETACHED) {
10614                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10615                 } else {
10616                         DO_ASSERT(get_jenv_res == JNI_OK);
10617                 }
10618                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10619                 if (get_jenv_res == JNI_EDETACHED) {
10620                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10621                 }
10622                 FREE(j_calls);
10623         }
10624 }
10625 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
10626         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
10627         JNIEnv *env;
10628         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10629         if (get_jenv_res == JNI_EDETACHED) {
10630                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10631         } else {
10632                 DO_ASSERT(get_jenv_res == JNI_OK);
10633         }
10634         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10635         CHECK(obj != NULL);
10636         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
10637         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10638                 (*env)->ExceptionDescribe(env);
10639                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
10640         }
10641         LDKCVec_MessageSendEventZ ret_constr;
10642         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
10643         if (ret_constr.datalen > 0)
10644                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
10645         else
10646                 ret_constr.data = NULL;
10647         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
10648         for (size_t s = 0; s < ret_constr.datalen; s++) {
10649                 int64_t ret_conv_18 = ret_vals[s];
10650                 void* ret_conv_18_ptr = untag_ptr(ret_conv_18);
10651                 CHECK_ACCESS(ret_conv_18_ptr);
10652                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
10653                 FREE(untag_ptr(ret_conv_18));
10654                 ret_constr.data[s] = ret_conv_18_conv;
10655         }
10656         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
10657         if (get_jenv_res == JNI_EDETACHED) {
10658                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10659         }
10660         return ret_constr;
10661 }
10662 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
10663         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
10664         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10665 }
10666 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
10667         jclass c = (*env)->GetObjectClass(env, o);
10668         CHECK(c != NULL);
10669         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
10670         atomic_init(&calls->refcnt, 1);
10671         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10672         calls->o = (*env)->NewWeakGlobalRef(env, o);
10673         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
10674         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
10675
10676         LDKMessageSendEventsProvider ret = {
10677                 .this_arg = (void*) calls,
10678                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
10679                 .free = LDKMessageSendEventsProvider_JCalls_free,
10680         };
10681         return ret;
10682 }
10683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
10684         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
10685         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
10686         return tag_ptr(res_ptr, true);
10687 }
10688 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
10689         void* this_arg_ptr = untag_ptr(this_arg);
10690         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10691         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
10692         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
10693         int64_tArray ret_arr = NULL;
10694         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10695         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10696         for (size_t s = 0; s < ret_var.datalen; s++) {
10697                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
10698                 *ret_conv_18_copy = ret_var.data[s];
10699                 int64_t ret_conv_18_ref = tag_ptr(ret_conv_18_copy, true);
10700                 ret_arr_ptr[s] = ret_conv_18_ref;
10701         }
10702         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10703         FREE(ret_var.data);
10704         return ret_arr;
10705 }
10706
10707 typedef struct LDKOnionMessageProvider_JCalls {
10708         atomic_size_t refcnt;
10709         JavaVM *vm;
10710         jweak o;
10711         jmethodID next_onion_message_for_peer_meth;
10712 } LDKOnionMessageProvider_JCalls;
10713 static void LDKOnionMessageProvider_JCalls_free(void* this_arg) {
10714         LDKOnionMessageProvider_JCalls *j_calls = (LDKOnionMessageProvider_JCalls*) this_arg;
10715         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10716                 JNIEnv *env;
10717                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10718                 if (get_jenv_res == JNI_EDETACHED) {
10719                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10720                 } else {
10721                         DO_ASSERT(get_jenv_res == JNI_OK);
10722                 }
10723                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10724                 if (get_jenv_res == JNI_EDETACHED) {
10725                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10726                 }
10727                 FREE(j_calls);
10728         }
10729 }
10730 LDKOnionMessage next_onion_message_for_peer_LDKOnionMessageProvider_jcall(const void* this_arg, LDKPublicKey peer_node_id) {
10731         LDKOnionMessageProvider_JCalls *j_calls = (LDKOnionMessageProvider_JCalls*) this_arg;
10732         JNIEnv *env;
10733         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10734         if (get_jenv_res == JNI_EDETACHED) {
10735                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10736         } else {
10737                 DO_ASSERT(get_jenv_res == JNI_OK);
10738         }
10739         int8_tArray peer_node_id_arr = (*env)->NewByteArray(env, 33);
10740         (*env)->SetByteArrayRegion(env, peer_node_id_arr, 0, 33, peer_node_id.compressed_form);
10741         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10742         CHECK(obj != NULL);
10743         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->next_onion_message_for_peer_meth, peer_node_id_arr);
10744         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10745                 (*env)->ExceptionDescribe(env);
10746                 (*env)->FatalError(env, "A call to next_onion_message_for_peer in LDKOnionMessageProvider from rust threw an exception.");
10747         }
10748         LDKOnionMessage ret_conv;
10749         ret_conv.inner = untag_ptr(ret);
10750         ret_conv.is_owned = ptr_is_owned(ret);
10751         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
10752         if (get_jenv_res == JNI_EDETACHED) {
10753                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10754         }
10755         return ret_conv;
10756 }
10757 static void LDKOnionMessageProvider_JCalls_cloned(LDKOnionMessageProvider* new_obj) {
10758         LDKOnionMessageProvider_JCalls *j_calls = (LDKOnionMessageProvider_JCalls*) new_obj->this_arg;
10759         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10760 }
10761 static inline LDKOnionMessageProvider LDKOnionMessageProvider_init (JNIEnv *env, jclass clz, jobject o) {
10762         jclass c = (*env)->GetObjectClass(env, o);
10763         CHECK(c != NULL);
10764         LDKOnionMessageProvider_JCalls *calls = MALLOC(sizeof(LDKOnionMessageProvider_JCalls), "LDKOnionMessageProvider_JCalls");
10765         atomic_init(&calls->refcnt, 1);
10766         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10767         calls->o = (*env)->NewWeakGlobalRef(env, o);
10768         calls->next_onion_message_for_peer_meth = (*env)->GetMethodID(env, c, "next_onion_message_for_peer", "([B)J");
10769         CHECK(calls->next_onion_message_for_peer_meth != NULL);
10770
10771         LDKOnionMessageProvider ret = {
10772                 .this_arg = (void*) calls,
10773                 .next_onion_message_for_peer = next_onion_message_for_peer_LDKOnionMessageProvider_jcall,
10774                 .free = LDKOnionMessageProvider_JCalls_free,
10775         };
10776         return ret;
10777 }
10778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKOnionMessageProvider_1new(JNIEnv *env, jclass clz, jobject o) {
10779         LDKOnionMessageProvider *res_ptr = MALLOC(sizeof(LDKOnionMessageProvider), "LDKOnionMessageProvider");
10780         *res_ptr = LDKOnionMessageProvider_init(env, clz, o);
10781         return tag_ptr(res_ptr, true);
10782 }
10783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageProvider_1next_1onion_1message_1for_1peer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray peer_node_id) {
10784         void* this_arg_ptr = untag_ptr(this_arg);
10785         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10786         LDKOnionMessageProvider* this_arg_conv = (LDKOnionMessageProvider*)this_arg_ptr;
10787         LDKPublicKey peer_node_id_ref;
10788         CHECK((*env)->GetArrayLength(env, peer_node_id) == 33);
10789         (*env)->GetByteArrayRegion(env, peer_node_id, 0, 33, peer_node_id_ref.compressed_form);
10790         LDKOnionMessage ret_var = (this_arg_conv->next_onion_message_for_peer)(this_arg_conv->this_arg, peer_node_id_ref);
10791         int64_t ret_ref = 0;
10792         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10793         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10794         return ret_ref;
10795 }
10796
10797 typedef struct LDKEventHandler_JCalls {
10798         atomic_size_t refcnt;
10799         JavaVM *vm;
10800         jweak o;
10801         jmethodID handle_event_meth;
10802 } LDKEventHandler_JCalls;
10803 static void LDKEventHandler_JCalls_free(void* this_arg) {
10804         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
10805         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10806                 JNIEnv *env;
10807                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10808                 if (get_jenv_res == JNI_EDETACHED) {
10809                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10810                 } else {
10811                         DO_ASSERT(get_jenv_res == JNI_OK);
10812                 }
10813                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10814                 if (get_jenv_res == JNI_EDETACHED) {
10815                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10816                 }
10817                 FREE(j_calls);
10818         }
10819 }
10820 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
10821         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
10822         JNIEnv *env;
10823         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10824         if (get_jenv_res == JNI_EDETACHED) {
10825                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10826         } else {
10827                 DO_ASSERT(get_jenv_res == JNI_OK);
10828         }
10829         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
10830         *ret_event = Event_clone(event);
10831         int64_t ref_event = tag_ptr(ret_event, true);
10832         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10833         CHECK(obj != NULL);
10834         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, ref_event);
10835         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10836                 (*env)->ExceptionDescribe(env);
10837                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
10838         }
10839         if (get_jenv_res == JNI_EDETACHED) {
10840                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10841         }
10842 }
10843 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
10844         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
10845         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10846 }
10847 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
10848         jclass c = (*env)->GetObjectClass(env, o);
10849         CHECK(c != NULL);
10850         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
10851         atomic_init(&calls->refcnt, 1);
10852         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10853         calls->o = (*env)->NewWeakGlobalRef(env, o);
10854         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
10855         CHECK(calls->handle_event_meth != NULL);
10856
10857         LDKEventHandler ret = {
10858                 .this_arg = (void*) calls,
10859                 .handle_event = handle_event_LDKEventHandler_jcall,
10860                 .free = LDKEventHandler_JCalls_free,
10861         };
10862         return ret;
10863 }
10864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
10865         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
10866         *res_ptr = LDKEventHandler_init(env, clz, o);
10867         return tag_ptr(res_ptr, true);
10868 }
10869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
10870         void* this_arg_ptr = untag_ptr(this_arg);
10871         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10872         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
10873         LDKEvent* event_conv = (LDKEvent*)untag_ptr(event);
10874         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
10875 }
10876
10877 typedef struct LDKEventsProvider_JCalls {
10878         atomic_size_t refcnt;
10879         JavaVM *vm;
10880         jweak o;
10881         jmethodID process_pending_events_meth;
10882 } LDKEventsProvider_JCalls;
10883 static void LDKEventsProvider_JCalls_free(void* this_arg) {
10884         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
10885         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
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                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10894                 if (get_jenv_res == JNI_EDETACHED) {
10895                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10896                 }
10897                 FREE(j_calls);
10898         }
10899 }
10900 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
10901         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
10902         JNIEnv *env;
10903         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10904         if (get_jenv_res == JNI_EDETACHED) {
10905                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10906         } else {
10907                 DO_ASSERT(get_jenv_res == JNI_OK);
10908         }
10909         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
10910         *handler_ret = handler;
10911         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10912         CHECK(obj != NULL);
10913         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, tag_ptr(handler_ret, true));
10914         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10915                 (*env)->ExceptionDescribe(env);
10916                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
10917         }
10918         if (get_jenv_res == JNI_EDETACHED) {
10919                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10920         }
10921 }
10922 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
10923         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
10924         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10925 }
10926 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
10927         jclass c = (*env)->GetObjectClass(env, o);
10928         CHECK(c != NULL);
10929         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
10930         atomic_init(&calls->refcnt, 1);
10931         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10932         calls->o = (*env)->NewWeakGlobalRef(env, o);
10933         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
10934         CHECK(calls->process_pending_events_meth != NULL);
10935
10936         LDKEventsProvider ret = {
10937                 .this_arg = (void*) calls,
10938                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
10939                 .free = LDKEventsProvider_JCalls_free,
10940         };
10941         return ret;
10942 }
10943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
10944         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
10945         *res_ptr = LDKEventsProvider_init(env, clz, o);
10946         return tag_ptr(res_ptr, true);
10947 }
10948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
10949         void* this_arg_ptr = untag_ptr(this_arg);
10950         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10951         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
10952         void* handler_ptr = untag_ptr(handler);
10953         CHECK_ACCESS(handler_ptr);
10954         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
10955         if (handler_conv.free == LDKEventHandler_JCalls_free) {
10956                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10957                 LDKEventHandler_JCalls_cloned(&handler_conv);
10958         }
10959         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
10960 }
10961
10962 typedef struct LDKPersister_JCalls {
10963         atomic_size_t refcnt;
10964         JavaVM *vm;
10965         jweak o;
10966         jmethodID persist_manager_meth;
10967         jmethodID persist_graph_meth;
10968         jmethodID persist_scorer_meth;
10969 } LDKPersister_JCalls;
10970 static void LDKPersister_JCalls_free(void* this_arg) {
10971         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
10972         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10973                 JNIEnv *env;
10974                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10975                 if (get_jenv_res == JNI_EDETACHED) {
10976                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10977                 } else {
10978                         DO_ASSERT(get_jenv_res == JNI_OK);
10979                 }
10980                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10981                 if (get_jenv_res == JNI_EDETACHED) {
10982                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10983                 }
10984                 FREE(j_calls);
10985         }
10986 }
10987 LDKCResult_NoneErrorZ persist_manager_LDKPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
10988         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
10989         JNIEnv *env;
10990         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10991         if (get_jenv_res == JNI_EDETACHED) {
10992                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10993         } else {
10994                 DO_ASSERT(get_jenv_res == JNI_OK);
10995         }
10996         LDKChannelManager channel_manager_var = *channel_manager;
10997         int64_t channel_manager_ref = 0;
10998         // WARNING: we may need a move here but no clone is available for LDKChannelManager
10999         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
11000         channel_manager_ref = tag_ptr(channel_manager_var.inner, channel_manager_var.is_owned);
11001         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11002         CHECK(obj != NULL);
11003         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
11004         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11005                 (*env)->ExceptionDescribe(env);
11006                 (*env)->FatalError(env, "A call to persist_manager in LDKPersister from rust threw an exception.");
11007         }
11008         void* ret_ptr = untag_ptr(ret);
11009         CHECK_ACCESS(ret_ptr);
11010         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
11011         FREE(untag_ptr(ret));
11012         if (get_jenv_res == JNI_EDETACHED) {
11013                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11014         }
11015         return ret_conv;
11016 }
11017 LDKCResult_NoneErrorZ persist_graph_LDKPersister_jcall(const void* this_arg, const LDKNetworkGraph * network_graph) {
11018         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
11019         JNIEnv *env;
11020         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11021         if (get_jenv_res == JNI_EDETACHED) {
11022                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11023         } else {
11024                 DO_ASSERT(get_jenv_res == JNI_OK);
11025         }
11026         LDKNetworkGraph network_graph_var = *network_graph;
11027         int64_t network_graph_ref = 0;
11028         // WARNING: we may need a move here but no clone is available for LDKNetworkGraph
11029         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_var);
11030         network_graph_ref = tag_ptr(network_graph_var.inner, network_graph_var.is_owned);
11031         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11032         CHECK(obj != NULL);
11033         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_graph_meth, network_graph_ref);
11034         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11035                 (*env)->ExceptionDescribe(env);
11036                 (*env)->FatalError(env, "A call to persist_graph in LDKPersister from rust threw an exception.");
11037         }
11038         void* ret_ptr = untag_ptr(ret);
11039         CHECK_ACCESS(ret_ptr);
11040         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
11041         FREE(untag_ptr(ret));
11042         if (get_jenv_res == JNI_EDETACHED) {
11043                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11044         }
11045         return ret_conv;
11046 }
11047 LDKCResult_NoneErrorZ persist_scorer_LDKPersister_jcall(const void* this_arg, const LDKWriteableScore * scorer) {
11048         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
11049         JNIEnv *env;
11050         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11051         if (get_jenv_res == JNI_EDETACHED) {
11052                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11053         } else {
11054                 DO_ASSERT(get_jenv_res == JNI_OK);
11055         }
11056         // WARNING: This object doesn't live past this scope, needs clone!
11057         int64_t ret_scorer = tag_ptr(scorer, false);
11058         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11059         CHECK(obj != NULL);
11060         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_scorer_meth, ret_scorer);
11061         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11062                 (*env)->ExceptionDescribe(env);
11063                 (*env)->FatalError(env, "A call to persist_scorer in LDKPersister from rust threw an exception.");
11064         }
11065         void* ret_ptr = untag_ptr(ret);
11066         CHECK_ACCESS(ret_ptr);
11067         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
11068         FREE(untag_ptr(ret));
11069         if (get_jenv_res == JNI_EDETACHED) {
11070                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11071         }
11072         return ret_conv;
11073 }
11074 static void LDKPersister_JCalls_cloned(LDKPersister* new_obj) {
11075         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) new_obj->this_arg;
11076         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11077 }
11078 static inline LDKPersister LDKPersister_init (JNIEnv *env, jclass clz, jobject o) {
11079         jclass c = (*env)->GetObjectClass(env, o);
11080         CHECK(c != NULL);
11081         LDKPersister_JCalls *calls = MALLOC(sizeof(LDKPersister_JCalls), "LDKPersister_JCalls");
11082         atomic_init(&calls->refcnt, 1);
11083         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11084         calls->o = (*env)->NewWeakGlobalRef(env, o);
11085         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
11086         CHECK(calls->persist_manager_meth != NULL);
11087         calls->persist_graph_meth = (*env)->GetMethodID(env, c, "persist_graph", "(J)J");
11088         CHECK(calls->persist_graph_meth != NULL);
11089         calls->persist_scorer_meth = (*env)->GetMethodID(env, c, "persist_scorer", "(J)J");
11090         CHECK(calls->persist_scorer_meth != NULL);
11091
11092         LDKPersister ret = {
11093                 .this_arg = (void*) calls,
11094                 .persist_manager = persist_manager_LDKPersister_jcall,
11095                 .persist_graph = persist_graph_LDKPersister_jcall,
11096                 .persist_scorer = persist_scorer_LDKPersister_jcall,
11097                 .free = LDKPersister_JCalls_free,
11098         };
11099         return ret;
11100 }
11101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersister_1new(JNIEnv *env, jclass clz, jobject o) {
11102         LDKPersister *res_ptr = MALLOC(sizeof(LDKPersister), "LDKPersister");
11103         *res_ptr = LDKPersister_init(env, clz, o);
11104         return tag_ptr(res_ptr, true);
11105 }
11106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
11107         void* this_arg_ptr = untag_ptr(this_arg);
11108         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11109         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
11110         LDKChannelManager channel_manager_conv;
11111         channel_manager_conv.inner = untag_ptr(channel_manager);
11112         channel_manager_conv.is_owned = ptr_is_owned(channel_manager);
11113         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
11114         channel_manager_conv.is_owned = false;
11115         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11116         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
11117         return tag_ptr(ret_conv, true);
11118 }
11119
11120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1graph(JNIEnv *env, jclass clz, int64_t this_arg, int64_t network_graph) {
11121         void* this_arg_ptr = untag_ptr(this_arg);
11122         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11123         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
11124         LDKNetworkGraph network_graph_conv;
11125         network_graph_conv.inner = untag_ptr(network_graph);
11126         network_graph_conv.is_owned = ptr_is_owned(network_graph);
11127         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
11128         network_graph_conv.is_owned = false;
11129         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11130         *ret_conv = (this_arg_conv->persist_graph)(this_arg_conv->this_arg, &network_graph_conv);
11131         return tag_ptr(ret_conv, true);
11132 }
11133
11134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1scorer(JNIEnv *env, jclass clz, int64_t this_arg, int64_t scorer) {
11135         void* this_arg_ptr = untag_ptr(this_arg);
11136         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11137         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
11138         void* scorer_ptr = untag_ptr(scorer);
11139         if (ptr_is_owned(scorer)) { CHECK_ACCESS(scorer_ptr); }
11140         LDKWriteableScore* scorer_conv = (LDKWriteableScore*)scorer_ptr;
11141         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11142         *ret_conv = (this_arg_conv->persist_scorer)(this_arg_conv->this_arg, scorer_conv);
11143         return tag_ptr(ret_conv, true);
11144 }
11145
11146 typedef struct LDKFutureCallback_JCalls {
11147         atomic_size_t refcnt;
11148         JavaVM *vm;
11149         jweak o;
11150         jmethodID call_meth;
11151 } LDKFutureCallback_JCalls;
11152 static void LDKFutureCallback_JCalls_free(void* this_arg) {
11153         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) this_arg;
11154         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11155                 JNIEnv *env;
11156                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11157                 if (get_jenv_res == JNI_EDETACHED) {
11158                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11159                 } else {
11160                         DO_ASSERT(get_jenv_res == JNI_OK);
11161                 }
11162                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11163                 if (get_jenv_res == JNI_EDETACHED) {
11164                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11165                 }
11166                 FREE(j_calls);
11167         }
11168 }
11169 void call_LDKFutureCallback_jcall(const void* this_arg) {
11170         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) this_arg;
11171         JNIEnv *env;
11172         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11173         if (get_jenv_res == JNI_EDETACHED) {
11174                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11175         } else {
11176                 DO_ASSERT(get_jenv_res == JNI_OK);
11177         }
11178         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11179         CHECK(obj != NULL);
11180         (*env)->CallVoidMethod(env, obj, j_calls->call_meth);
11181         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11182                 (*env)->ExceptionDescribe(env);
11183                 (*env)->FatalError(env, "A call to call in LDKFutureCallback from rust threw an exception.");
11184         }
11185         if (get_jenv_res == JNI_EDETACHED) {
11186                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11187         }
11188 }
11189 static void LDKFutureCallback_JCalls_cloned(LDKFutureCallback* new_obj) {
11190         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) new_obj->this_arg;
11191         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11192 }
11193 static inline LDKFutureCallback LDKFutureCallback_init (JNIEnv *env, jclass clz, jobject o) {
11194         jclass c = (*env)->GetObjectClass(env, o);
11195         CHECK(c != NULL);
11196         LDKFutureCallback_JCalls *calls = MALLOC(sizeof(LDKFutureCallback_JCalls), "LDKFutureCallback_JCalls");
11197         atomic_init(&calls->refcnt, 1);
11198         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11199         calls->o = (*env)->NewWeakGlobalRef(env, o);
11200         calls->call_meth = (*env)->GetMethodID(env, c, "call", "()V");
11201         CHECK(calls->call_meth != NULL);
11202
11203         LDKFutureCallback ret = {
11204                 .this_arg = (void*) calls,
11205                 .call = call_LDKFutureCallback_jcall,
11206                 .free = LDKFutureCallback_JCalls_free,
11207         };
11208         return ret;
11209 }
11210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFutureCallback_1new(JNIEnv *env, jclass clz, jobject o) {
11211         LDKFutureCallback *res_ptr = MALLOC(sizeof(LDKFutureCallback), "LDKFutureCallback");
11212         *res_ptr = LDKFutureCallback_init(env, clz, o);
11213         return tag_ptr(res_ptr, true);
11214 }
11215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FutureCallback_1call(JNIEnv *env, jclass clz, int64_t this_arg) {
11216         void* this_arg_ptr = untag_ptr(this_arg);
11217         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11218         LDKFutureCallback* this_arg_conv = (LDKFutureCallback*)this_arg_ptr;
11219         (this_arg_conv->call)(this_arg_conv->this_arg);
11220 }
11221
11222 typedef struct LDKListen_JCalls {
11223         atomic_size_t refcnt;
11224         JavaVM *vm;
11225         jweak o;
11226         jmethodID filtered_block_connected_meth;
11227         jmethodID block_connected_meth;
11228         jmethodID block_disconnected_meth;
11229 } LDKListen_JCalls;
11230 static void LDKListen_JCalls_free(void* this_arg) {
11231         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11232         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11233                 JNIEnv *env;
11234                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11235                 if (get_jenv_res == JNI_EDETACHED) {
11236                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11237                 } else {
11238                         DO_ASSERT(get_jenv_res == JNI_OK);
11239                 }
11240                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11241                 if (get_jenv_res == JNI_EDETACHED) {
11242                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11243                 }
11244                 FREE(j_calls);
11245         }
11246 }
11247 void filtered_block_connected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
11248         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11249         JNIEnv *env;
11250         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11251         if (get_jenv_res == JNI_EDETACHED) {
11252                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11253         } else {
11254                 DO_ASSERT(get_jenv_res == JNI_OK);
11255         }
11256         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11257         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11258         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
11259         int64_tArray txdata_arr = NULL;
11260         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
11261         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
11262         for (size_t c = 0; c < txdata_var.datalen; c++) {
11263                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
11264                 *txdata_conv_28_conv = txdata_var.data[c];
11265                 txdata_arr_ptr[c] = tag_ptr(txdata_conv_28_conv, true);
11266         }
11267         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
11268         FREE(txdata_var.data);
11269         int32_t height_conv = height;
11270         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11271         CHECK(obj != NULL);
11272         (*env)->CallVoidMethod(env, obj, j_calls->filtered_block_connected_meth, header_arr, txdata_arr, height_conv);
11273         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11274                 (*env)->ExceptionDescribe(env);
11275                 (*env)->FatalError(env, "A call to filtered_block_connected in LDKListen from rust threw an exception.");
11276         }
11277         if (get_jenv_res == JNI_EDETACHED) {
11278                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11279         }
11280 }
11281 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
11282         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11283         JNIEnv *env;
11284         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11285         if (get_jenv_res == JNI_EDETACHED) {
11286                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11287         } else {
11288                 DO_ASSERT(get_jenv_res == JNI_OK);
11289         }
11290         LDKu8slice block_var = block;
11291         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
11292         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
11293         int32_t height_conv = height;
11294         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11295         CHECK(obj != NULL);
11296         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height_conv);
11297         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11298                 (*env)->ExceptionDescribe(env);
11299                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
11300         }
11301         if (get_jenv_res == JNI_EDETACHED) {
11302                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11303         }
11304 }
11305 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
11306         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11307         JNIEnv *env;
11308         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11309         if (get_jenv_res == JNI_EDETACHED) {
11310                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11311         } else {
11312                 DO_ASSERT(get_jenv_res == JNI_OK);
11313         }
11314         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11315         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11316         int32_t height_conv = height;
11317         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11318         CHECK(obj != NULL);
11319         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height_conv);
11320         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11321                 (*env)->ExceptionDescribe(env);
11322                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
11323         }
11324         if (get_jenv_res == JNI_EDETACHED) {
11325                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11326         }
11327 }
11328 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
11329         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
11330         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11331 }
11332 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
11333         jclass c = (*env)->GetObjectClass(env, o);
11334         CHECK(c != NULL);
11335         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
11336         atomic_init(&calls->refcnt, 1);
11337         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11338         calls->o = (*env)->NewWeakGlobalRef(env, o);
11339         calls->filtered_block_connected_meth = (*env)->GetMethodID(env, c, "filtered_block_connected", "([B[JI)V");
11340         CHECK(calls->filtered_block_connected_meth != NULL);
11341         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
11342         CHECK(calls->block_connected_meth != NULL);
11343         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
11344         CHECK(calls->block_disconnected_meth != NULL);
11345
11346         LDKListen ret = {
11347                 .this_arg = (void*) calls,
11348                 .filtered_block_connected = filtered_block_connected_LDKListen_jcall,
11349                 .block_connected = block_connected_LDKListen_jcall,
11350                 .block_disconnected = block_disconnected_LDKListen_jcall,
11351                 .free = LDKListen_JCalls_free,
11352         };
11353         return ret;
11354 }
11355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
11356         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
11357         *res_ptr = LDKListen_init(env, clz, o);
11358         return tag_ptr(res_ptr, true);
11359 }
11360 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) {
11361         void* this_arg_ptr = untag_ptr(this_arg);
11362         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11363         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
11364         unsigned char header_arr[80];
11365         CHECK((*env)->GetArrayLength(env, header) == 80);
11366         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11367         unsigned char (*header_ref)[80] = &header_arr;
11368         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11369         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
11370         if (txdata_constr.datalen > 0)
11371                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11372         else
11373                 txdata_constr.data = NULL;
11374         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
11375         for (size_t c = 0; c < txdata_constr.datalen; c++) {
11376                 int64_t txdata_conv_28 = txdata_vals[c];
11377                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
11378                 CHECK_ACCESS(txdata_conv_28_ptr);
11379                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
11380                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
11381                 txdata_constr.data[c] = txdata_conv_28_conv;
11382         }
11383         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
11384         (this_arg_conv->filtered_block_connected)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
11385 }
11386
11387 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) {
11388         void* this_arg_ptr = untag_ptr(this_arg);
11389         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11390         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
11391         LDKu8slice block_ref;
11392         block_ref.datalen = (*env)->GetArrayLength(env, block);
11393         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
11394         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
11395         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
11396 }
11397
11398 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) {
11399         void* this_arg_ptr = untag_ptr(this_arg);
11400         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11401         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
11402         unsigned char header_arr[80];
11403         CHECK((*env)->GetArrayLength(env, header) == 80);
11404         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11405         unsigned char (*header_ref)[80] = &header_arr;
11406         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
11407 }
11408
11409 typedef struct LDKConfirm_JCalls {
11410         atomic_size_t refcnt;
11411         JavaVM *vm;
11412         jweak o;
11413         jmethodID transactions_confirmed_meth;
11414         jmethodID transaction_unconfirmed_meth;
11415         jmethodID best_block_updated_meth;
11416         jmethodID get_relevant_txids_meth;
11417 } LDKConfirm_JCalls;
11418 static void LDKConfirm_JCalls_free(void* this_arg) {
11419         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11420         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11421                 JNIEnv *env;
11422                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11423                 if (get_jenv_res == JNI_EDETACHED) {
11424                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11425                 } else {
11426                         DO_ASSERT(get_jenv_res == JNI_OK);
11427                 }
11428                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11429                 if (get_jenv_res == JNI_EDETACHED) {
11430                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11431                 }
11432                 FREE(j_calls);
11433         }
11434 }
11435 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
11436         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11437         JNIEnv *env;
11438         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11439         if (get_jenv_res == JNI_EDETACHED) {
11440                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11441         } else {
11442                 DO_ASSERT(get_jenv_res == JNI_OK);
11443         }
11444         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11445         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11446         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
11447         int64_tArray txdata_arr = NULL;
11448         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
11449         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
11450         for (size_t c = 0; c < txdata_var.datalen; c++) {
11451                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
11452                 *txdata_conv_28_conv = txdata_var.data[c];
11453                 txdata_arr_ptr[c] = tag_ptr(txdata_conv_28_conv, true);
11454         }
11455         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
11456         FREE(txdata_var.data);
11457         int32_t height_conv = height;
11458         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11459         CHECK(obj != NULL);
11460         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height_conv);
11461         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11462                 (*env)->ExceptionDescribe(env);
11463                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
11464         }
11465         if (get_jenv_res == JNI_EDETACHED) {
11466                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11467         }
11468 }
11469 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
11470         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11471         JNIEnv *env;
11472         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11473         if (get_jenv_res == JNI_EDETACHED) {
11474                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11475         } else {
11476                 DO_ASSERT(get_jenv_res == JNI_OK);
11477         }
11478         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
11479         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
11480         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11481         CHECK(obj != NULL);
11482         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
11483         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11484                 (*env)->ExceptionDescribe(env);
11485                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
11486         }
11487         if (get_jenv_res == JNI_EDETACHED) {
11488                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11489         }
11490 }
11491 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
11492         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11493         JNIEnv *env;
11494         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11495         if (get_jenv_res == JNI_EDETACHED) {
11496                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11497         } else {
11498                 DO_ASSERT(get_jenv_res == JNI_OK);
11499         }
11500         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11501         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11502         int32_t height_conv = height;
11503         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11504         CHECK(obj != NULL);
11505         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height_conv);
11506         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11507                 (*env)->ExceptionDescribe(env);
11508                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
11509         }
11510         if (get_jenv_res == JNI_EDETACHED) {
11511                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11512         }
11513 }
11514 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
11515         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11516         JNIEnv *env;
11517         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11518         if (get_jenv_res == JNI_EDETACHED) {
11519                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11520         } else {
11521                 DO_ASSERT(get_jenv_res == JNI_OK);
11522         }
11523         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11524         CHECK(obj != NULL);
11525         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
11526         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11527                 (*env)->ExceptionDescribe(env);
11528                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
11529         }
11530         LDKCVec_TxidZ ret_constr;
11531         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
11532         if (ret_constr.datalen > 0)
11533                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
11534         else
11535                 ret_constr.data = NULL;
11536         for (size_t i = 0; i < ret_constr.datalen; i++) {
11537                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
11538                 LDKThirtyTwoBytes ret_conv_8_ref;
11539                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
11540                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
11541                 ret_constr.data[i] = ret_conv_8_ref;
11542         }
11543         if (get_jenv_res == JNI_EDETACHED) {
11544                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11545         }
11546         return ret_constr;
11547 }
11548 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
11549         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
11550         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11551 }
11552 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
11553         jclass c = (*env)->GetObjectClass(env, o);
11554         CHECK(c != NULL);
11555         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
11556         atomic_init(&calls->refcnt, 1);
11557         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11558         calls->o = (*env)->NewWeakGlobalRef(env, o);
11559         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
11560         CHECK(calls->transactions_confirmed_meth != NULL);
11561         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
11562         CHECK(calls->transaction_unconfirmed_meth != NULL);
11563         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
11564         CHECK(calls->best_block_updated_meth != NULL);
11565         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
11566         CHECK(calls->get_relevant_txids_meth != NULL);
11567
11568         LDKConfirm ret = {
11569                 .this_arg = (void*) calls,
11570                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
11571                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
11572                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
11573                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
11574                 .free = LDKConfirm_JCalls_free,
11575         };
11576         return ret;
11577 }
11578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
11579         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
11580         *res_ptr = LDKConfirm_init(env, clz, o);
11581         return tag_ptr(res_ptr, true);
11582 }
11583 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) {
11584         void* this_arg_ptr = untag_ptr(this_arg);
11585         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11586         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11587         unsigned char header_arr[80];
11588         CHECK((*env)->GetArrayLength(env, header) == 80);
11589         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11590         unsigned char (*header_ref)[80] = &header_arr;
11591         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11592         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
11593         if (txdata_constr.datalen > 0)
11594                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11595         else
11596                 txdata_constr.data = NULL;
11597         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
11598         for (size_t c = 0; c < txdata_constr.datalen; c++) {
11599                 int64_t txdata_conv_28 = txdata_vals[c];
11600                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
11601                 CHECK_ACCESS(txdata_conv_28_ptr);
11602                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
11603                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
11604                 txdata_constr.data[c] = txdata_conv_28_conv;
11605         }
11606         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
11607         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
11608 }
11609
11610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
11611         void* this_arg_ptr = untag_ptr(this_arg);
11612         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11613         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11614         unsigned char txid_arr[32];
11615         CHECK((*env)->GetArrayLength(env, txid) == 32);
11616         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
11617         unsigned char (*txid_ref)[32] = &txid_arr;
11618         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
11619 }
11620
11621 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) {
11622         void* this_arg_ptr = untag_ptr(this_arg);
11623         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11624         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11625         unsigned char header_arr[80];
11626         CHECK((*env)->GetArrayLength(env, header) == 80);
11627         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11628         unsigned char (*header_ref)[80] = &header_arr;
11629         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
11630 }
11631
11632 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
11633         void* this_arg_ptr = untag_ptr(this_arg);
11634         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11635         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11636         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
11637         jobjectArray ret_arr = NULL;
11638         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
11639         ;
11640         for (size_t i = 0; i < ret_var.datalen; i++) {
11641                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
11642                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
11643                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
11644         }
11645         
11646         FREE(ret_var.data);
11647         return ret_arr;
11648 }
11649
11650 typedef struct LDKPersist_JCalls {
11651         atomic_size_t refcnt;
11652         JavaVM *vm;
11653         jweak o;
11654         jmethodID persist_new_channel_meth;
11655         jmethodID update_persisted_channel_meth;
11656 } LDKPersist_JCalls;
11657 static void LDKPersist_JCalls_free(void* this_arg) {
11658         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11659         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11660                 JNIEnv *env;
11661                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11662                 if (get_jenv_res == JNI_EDETACHED) {
11663                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11664                 } else {
11665                         DO_ASSERT(get_jenv_res == JNI_OK);
11666                 }
11667                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11668                 if (get_jenv_res == JNI_EDETACHED) {
11669                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11670                 }
11671                 FREE(j_calls);
11672         }
11673 }
11674 LDKChannelMonitorUpdateStatus persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
11675         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11676         JNIEnv *env;
11677         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11678         if (get_jenv_res == JNI_EDETACHED) {
11679                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11680         } else {
11681                 DO_ASSERT(get_jenv_res == JNI_OK);
11682         }
11683         LDKOutPoint channel_id_var = channel_id;
11684         int64_t channel_id_ref = 0;
11685         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
11686         channel_id_ref = tag_ptr(channel_id_var.inner, channel_id_var.is_owned);
11687         LDKChannelMonitor data_var = *data;
11688         int64_t data_ref = 0;
11689         data_var = ChannelMonitor_clone(&data_var);
11690         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
11691         data_ref = tag_ptr(data_var.inner, data_var.is_owned);
11692         LDKMonitorUpdateId update_id_var = update_id;
11693         int64_t update_id_ref = 0;
11694         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
11695         update_id_ref = tag_ptr(update_id_var.inner, update_id_var.is_owned);
11696         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11697         CHECK(obj != NULL);
11698         jclass ret = (*env)->CallObjectMethod(env, obj, j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
11699         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11700                 (*env)->ExceptionDescribe(env);
11701                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
11702         }
11703         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_java(env, ret);
11704         if (get_jenv_res == JNI_EDETACHED) {
11705                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11706         }
11707         return ret_conv;
11708 }
11709 LDKChannelMonitorUpdateStatus update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
11710         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11711         JNIEnv *env;
11712         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11713         if (get_jenv_res == JNI_EDETACHED) {
11714                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11715         } else {
11716                 DO_ASSERT(get_jenv_res == JNI_OK);
11717         }
11718         LDKOutPoint channel_id_var = channel_id;
11719         int64_t channel_id_ref = 0;
11720         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
11721         channel_id_ref = tag_ptr(channel_id_var.inner, channel_id_var.is_owned);
11722         LDKChannelMonitorUpdate update_var = *update;
11723         int64_t update_ref = 0;
11724         update_var = ChannelMonitorUpdate_clone(&update_var);
11725         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
11726         update_ref = tag_ptr(update_var.inner, update_var.is_owned);
11727         LDKChannelMonitor data_var = *data;
11728         int64_t data_ref = 0;
11729         data_var = ChannelMonitor_clone(&data_var);
11730         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
11731         data_ref = tag_ptr(data_var.inner, data_var.is_owned);
11732         LDKMonitorUpdateId update_id_var = update_id;
11733         int64_t update_id_ref = 0;
11734         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
11735         update_id_ref = tag_ptr(update_id_var.inner, update_id_var.is_owned);
11736         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11737         CHECK(obj != NULL);
11738         jclass ret = (*env)->CallObjectMethod(env, obj, j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
11739         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11740                 (*env)->ExceptionDescribe(env);
11741                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
11742         }
11743         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_java(env, ret);
11744         if (get_jenv_res == JNI_EDETACHED) {
11745                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11746         }
11747         return ret_conv;
11748 }
11749 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
11750         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
11751         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11752 }
11753 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
11754         jclass c = (*env)->GetObjectClass(env, o);
11755         CHECK(c != NULL);
11756         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
11757         atomic_init(&calls->refcnt, 1);
11758         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11759         calls->o = (*env)->NewWeakGlobalRef(env, o);
11760         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJJ)Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
11761         CHECK(calls->persist_new_channel_meth != NULL);
11762         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJJ)Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
11763         CHECK(calls->update_persisted_channel_meth != NULL);
11764
11765         LDKPersist ret = {
11766                 .this_arg = (void*) calls,
11767                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
11768                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
11769                 .free = LDKPersist_JCalls_free,
11770         };
11771         return ret;
11772 }
11773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
11774         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
11775         *res_ptr = LDKPersist_init(env, clz, o);
11776         return tag_ptr(res_ptr, true);
11777 }
11778 JNIEXPORT jclass 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) {
11779         void* this_arg_ptr = untag_ptr(this_arg);
11780         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11781         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
11782         LDKOutPoint channel_id_conv;
11783         channel_id_conv.inner = untag_ptr(channel_id);
11784         channel_id_conv.is_owned = ptr_is_owned(channel_id);
11785         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
11786         channel_id_conv = OutPoint_clone(&channel_id_conv);
11787         LDKChannelMonitor data_conv;
11788         data_conv.inner = untag_ptr(data);
11789         data_conv.is_owned = ptr_is_owned(data);
11790         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
11791         data_conv.is_owned = false;
11792         LDKMonitorUpdateId update_id_conv;
11793         update_id_conv.inner = untag_ptr(update_id);
11794         update_id_conv.is_owned = ptr_is_owned(update_id);
11795         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
11796         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
11797         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv));
11798         return ret_conv;
11799 }
11800
11801 JNIEXPORT jclass 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) {
11802         void* this_arg_ptr = untag_ptr(this_arg);
11803         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11804         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
11805         LDKOutPoint channel_id_conv;
11806         channel_id_conv.inner = untag_ptr(channel_id);
11807         channel_id_conv.is_owned = ptr_is_owned(channel_id);
11808         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
11809         channel_id_conv = OutPoint_clone(&channel_id_conv);
11810         LDKChannelMonitorUpdate update_conv;
11811         update_conv.inner = untag_ptr(update);
11812         update_conv.is_owned = ptr_is_owned(update);
11813         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
11814         update_conv.is_owned = false;
11815         LDKChannelMonitor data_conv;
11816         data_conv.inner = untag_ptr(data);
11817         data_conv.is_owned = ptr_is_owned(data);
11818         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
11819         data_conv.is_owned = false;
11820         LDKMonitorUpdateId update_id_conv;
11821         update_id_conv.inner = untag_ptr(update_id);
11822         update_id_conv.is_owned = ptr_is_owned(update_id);
11823         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
11824         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
11825         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv));
11826         return ret_conv;
11827 }
11828
11829 typedef struct LDKChannelMessageHandler_JCalls {
11830         atomic_size_t refcnt;
11831         JavaVM *vm;
11832         jweak o;
11833         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
11834         jmethodID handle_open_channel_meth;
11835         jmethodID handle_accept_channel_meth;
11836         jmethodID handle_funding_created_meth;
11837         jmethodID handle_funding_signed_meth;
11838         jmethodID handle_channel_ready_meth;
11839         jmethodID handle_shutdown_meth;
11840         jmethodID handle_closing_signed_meth;
11841         jmethodID handle_update_add_htlc_meth;
11842         jmethodID handle_update_fulfill_htlc_meth;
11843         jmethodID handle_update_fail_htlc_meth;
11844         jmethodID handle_update_fail_malformed_htlc_meth;
11845         jmethodID handle_commitment_signed_meth;
11846         jmethodID handle_revoke_and_ack_meth;
11847         jmethodID handle_update_fee_meth;
11848         jmethodID handle_announcement_signatures_meth;
11849         jmethodID peer_disconnected_meth;
11850         jmethodID peer_connected_meth;
11851         jmethodID handle_channel_reestablish_meth;
11852         jmethodID handle_channel_update_meth;
11853         jmethodID handle_error_meth;
11854         jmethodID provided_node_features_meth;
11855         jmethodID provided_init_features_meth;
11856 } LDKChannelMessageHandler_JCalls;
11857 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
11858         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11859         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11860                 JNIEnv *env;
11861                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11862                 if (get_jenv_res == JNI_EDETACHED) {
11863                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11864                 } else {
11865                         DO_ASSERT(get_jenv_res == JNI_OK);
11866                 }
11867                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11868                 if (get_jenv_res == JNI_EDETACHED) {
11869                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11870                 }
11871                 FREE(j_calls);
11872         }
11873 }
11874 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
11875         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11876         JNIEnv *env;
11877         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11878         if (get_jenv_res == JNI_EDETACHED) {
11879                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11880         } else {
11881                 DO_ASSERT(get_jenv_res == JNI_OK);
11882         }
11883         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11884         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11885         LDKInitFeatures their_features_var = their_features;
11886         int64_t their_features_ref = 0;
11887         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
11888         their_features_ref = tag_ptr(their_features_var.inner, their_features_var.is_owned);
11889         LDKOpenChannel msg_var = *msg;
11890         int64_t msg_ref = 0;
11891         msg_var = OpenChannel_clone(&msg_var);
11892         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11893         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11894         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11895         CHECK(obj != NULL);
11896         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
11897         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11898                 (*env)->ExceptionDescribe(env);
11899                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
11900         }
11901         if (get_jenv_res == JNI_EDETACHED) {
11902                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11903         }
11904 }
11905 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
11906         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11907         JNIEnv *env;
11908         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11909         if (get_jenv_res == JNI_EDETACHED) {
11910                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11911         } else {
11912                 DO_ASSERT(get_jenv_res == JNI_OK);
11913         }
11914         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11915         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11916         LDKInitFeatures their_features_var = their_features;
11917         int64_t their_features_ref = 0;
11918         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
11919         their_features_ref = tag_ptr(their_features_var.inner, their_features_var.is_owned);
11920         LDKAcceptChannel msg_var = *msg;
11921         int64_t msg_ref = 0;
11922         msg_var = AcceptChannel_clone(&msg_var);
11923         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11924         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11925         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11926         CHECK(obj != NULL);
11927         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
11928         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11929                 (*env)->ExceptionDescribe(env);
11930                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
11931         }
11932         if (get_jenv_res == JNI_EDETACHED) {
11933                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11934         }
11935 }
11936 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
11937         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11938         JNIEnv *env;
11939         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11940         if (get_jenv_res == JNI_EDETACHED) {
11941                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11942         } else {
11943                 DO_ASSERT(get_jenv_res == JNI_OK);
11944         }
11945         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11946         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11947         LDKFundingCreated msg_var = *msg;
11948         int64_t msg_ref = 0;
11949         msg_var = FundingCreated_clone(&msg_var);
11950         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11951         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11952         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11953         CHECK(obj != NULL);
11954         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
11955         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11956                 (*env)->ExceptionDescribe(env);
11957                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
11958         }
11959         if (get_jenv_res == JNI_EDETACHED) {
11960                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11961         }
11962 }
11963 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
11964         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11965         JNIEnv *env;
11966         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11967         if (get_jenv_res == JNI_EDETACHED) {
11968                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11969         } else {
11970                 DO_ASSERT(get_jenv_res == JNI_OK);
11971         }
11972         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11973         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11974         LDKFundingSigned msg_var = *msg;
11975         int64_t msg_ref = 0;
11976         msg_var = FundingSigned_clone(&msg_var);
11977         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11978         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11979         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11980         CHECK(obj != NULL);
11981         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
11982         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11983                 (*env)->ExceptionDescribe(env);
11984                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
11985         }
11986         if (get_jenv_res == JNI_EDETACHED) {
11987                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11988         }
11989 }
11990 void handle_channel_ready_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReady * msg) {
11991         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11992         JNIEnv *env;
11993         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11994         if (get_jenv_res == JNI_EDETACHED) {
11995                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11996         } else {
11997                 DO_ASSERT(get_jenv_res == JNI_OK);
11998         }
11999         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12000         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12001         LDKChannelReady msg_var = *msg;
12002         int64_t msg_ref = 0;
12003         msg_var = ChannelReady_clone(&msg_var);
12004         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12005         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12006         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12007         CHECK(obj != NULL);
12008         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_ready_meth, their_node_id_arr, msg_ref);
12009         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12010                 (*env)->ExceptionDescribe(env);
12011                 (*env)->FatalError(env, "A call to handle_channel_ready in LDKChannelMessageHandler from rust threw an exception.");
12012         }
12013         if (get_jenv_res == JNI_EDETACHED) {
12014                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12015         }
12016 }
12017 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
12018         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12019         JNIEnv *env;
12020         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12021         if (get_jenv_res == JNI_EDETACHED) {
12022                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12023         } else {
12024                 DO_ASSERT(get_jenv_res == JNI_OK);
12025         }
12026         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12027         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12028         LDKInitFeatures their_features_var = *their_features;
12029         int64_t their_features_ref = 0;
12030         their_features_var = InitFeatures_clone(&their_features_var);
12031         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
12032         their_features_ref = tag_ptr(their_features_var.inner, their_features_var.is_owned);
12033         LDKShutdown msg_var = *msg;
12034         int64_t msg_ref = 0;
12035         msg_var = Shutdown_clone(&msg_var);
12036         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12037         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12038         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12039         CHECK(obj != NULL);
12040         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
12041         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12042                 (*env)->ExceptionDescribe(env);
12043                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
12044         }
12045         if (get_jenv_res == JNI_EDETACHED) {
12046                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12047         }
12048 }
12049 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
12050         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12051         JNIEnv *env;
12052         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12053         if (get_jenv_res == JNI_EDETACHED) {
12054                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12055         } else {
12056                 DO_ASSERT(get_jenv_res == JNI_OK);
12057         }
12058         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12059         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12060         LDKClosingSigned msg_var = *msg;
12061         int64_t msg_ref = 0;
12062         msg_var = ClosingSigned_clone(&msg_var);
12063         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12064         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12065         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12066         CHECK(obj != NULL);
12067         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
12068         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12069                 (*env)->ExceptionDescribe(env);
12070                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
12071         }
12072         if (get_jenv_res == JNI_EDETACHED) {
12073                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12074         }
12075 }
12076 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
12077         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12078         JNIEnv *env;
12079         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12080         if (get_jenv_res == JNI_EDETACHED) {
12081                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12082         } else {
12083                 DO_ASSERT(get_jenv_res == JNI_OK);
12084         }
12085         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12086         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12087         LDKUpdateAddHTLC msg_var = *msg;
12088         int64_t msg_ref = 0;
12089         msg_var = UpdateAddHTLC_clone(&msg_var);
12090         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12091         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12092         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12093         CHECK(obj != NULL);
12094         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
12095         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12096                 (*env)->ExceptionDescribe(env);
12097                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
12098         }
12099         if (get_jenv_res == JNI_EDETACHED) {
12100                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12101         }
12102 }
12103 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
12104         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12105         JNIEnv *env;
12106         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12107         if (get_jenv_res == JNI_EDETACHED) {
12108                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12109         } else {
12110                 DO_ASSERT(get_jenv_res == JNI_OK);
12111         }
12112         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12113         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12114         LDKUpdateFulfillHTLC msg_var = *msg;
12115         int64_t msg_ref = 0;
12116         msg_var = UpdateFulfillHTLC_clone(&msg_var);
12117         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12118         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12119         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12120         CHECK(obj != NULL);
12121         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
12122         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12123                 (*env)->ExceptionDescribe(env);
12124                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
12125         }
12126         if (get_jenv_res == JNI_EDETACHED) {
12127                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12128         }
12129 }
12130 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
12131         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12132         JNIEnv *env;
12133         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12134         if (get_jenv_res == JNI_EDETACHED) {
12135                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12136         } else {
12137                 DO_ASSERT(get_jenv_res == JNI_OK);
12138         }
12139         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12140         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12141         LDKUpdateFailHTLC msg_var = *msg;
12142         int64_t msg_ref = 0;
12143         msg_var = UpdateFailHTLC_clone(&msg_var);
12144         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12145         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12146         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12147         CHECK(obj != NULL);
12148         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
12149         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12150                 (*env)->ExceptionDescribe(env);
12151                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
12152         }
12153         if (get_jenv_res == JNI_EDETACHED) {
12154                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12155         }
12156 }
12157 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
12158         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12159         JNIEnv *env;
12160         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12161         if (get_jenv_res == JNI_EDETACHED) {
12162                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12163         } else {
12164                 DO_ASSERT(get_jenv_res == JNI_OK);
12165         }
12166         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12167         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12168         LDKUpdateFailMalformedHTLC msg_var = *msg;
12169         int64_t msg_ref = 0;
12170         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
12171         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12172         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12173         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12174         CHECK(obj != NULL);
12175         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
12176         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12177                 (*env)->ExceptionDescribe(env);
12178                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
12179         }
12180         if (get_jenv_res == JNI_EDETACHED) {
12181                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12182         }
12183 }
12184 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
12185         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12186         JNIEnv *env;
12187         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12188         if (get_jenv_res == JNI_EDETACHED) {
12189                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12190         } else {
12191                 DO_ASSERT(get_jenv_res == JNI_OK);
12192         }
12193         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12194         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12195         LDKCommitmentSigned msg_var = *msg;
12196         int64_t msg_ref = 0;
12197         msg_var = CommitmentSigned_clone(&msg_var);
12198         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12199         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12200         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12201         CHECK(obj != NULL);
12202         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
12203         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12204                 (*env)->ExceptionDescribe(env);
12205                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
12206         }
12207         if (get_jenv_res == JNI_EDETACHED) {
12208                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12209         }
12210 }
12211 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
12212         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12213         JNIEnv *env;
12214         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12215         if (get_jenv_res == JNI_EDETACHED) {
12216                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12217         } else {
12218                 DO_ASSERT(get_jenv_res == JNI_OK);
12219         }
12220         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12221         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12222         LDKRevokeAndACK msg_var = *msg;
12223         int64_t msg_ref = 0;
12224         msg_var = RevokeAndACK_clone(&msg_var);
12225         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12226         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12227         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12228         CHECK(obj != NULL);
12229         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
12230         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12231                 (*env)->ExceptionDescribe(env);
12232                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
12233         }
12234         if (get_jenv_res == JNI_EDETACHED) {
12235                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12236         }
12237 }
12238 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
12239         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12240         JNIEnv *env;
12241         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12242         if (get_jenv_res == JNI_EDETACHED) {
12243                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12244         } else {
12245                 DO_ASSERT(get_jenv_res == JNI_OK);
12246         }
12247         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12248         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12249         LDKUpdateFee msg_var = *msg;
12250         int64_t msg_ref = 0;
12251         msg_var = UpdateFee_clone(&msg_var);
12252         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12253         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12254         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12255         CHECK(obj != NULL);
12256         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
12257         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12258                 (*env)->ExceptionDescribe(env);
12259                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
12260         }
12261         if (get_jenv_res == JNI_EDETACHED) {
12262                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12263         }
12264 }
12265 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
12266         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12267         JNIEnv *env;
12268         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12269         if (get_jenv_res == JNI_EDETACHED) {
12270                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12271         } else {
12272                 DO_ASSERT(get_jenv_res == JNI_OK);
12273         }
12274         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12275         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12276         LDKAnnouncementSignatures msg_var = *msg;
12277         int64_t msg_ref = 0;
12278         msg_var = AnnouncementSignatures_clone(&msg_var);
12279         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12280         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12281         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12282         CHECK(obj != NULL);
12283         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
12284         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12285                 (*env)->ExceptionDescribe(env);
12286                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
12287         }
12288         if (get_jenv_res == JNI_EDETACHED) {
12289                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12290         }
12291 }
12292 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
12293         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12294         JNIEnv *env;
12295         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12296         if (get_jenv_res == JNI_EDETACHED) {
12297                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12298         } else {
12299                 DO_ASSERT(get_jenv_res == JNI_OK);
12300         }
12301         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12302         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12303         jboolean no_connection_possible_conv = no_connection_possible;
12304         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12305         CHECK(obj != NULL);
12306         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible_conv);
12307         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12308                 (*env)->ExceptionDescribe(env);
12309                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
12310         }
12311         if (get_jenv_res == JNI_EDETACHED) {
12312                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12313         }
12314 }
12315 LDKCResult_NoneNoneZ peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
12316         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12317         JNIEnv *env;
12318         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12319         if (get_jenv_res == JNI_EDETACHED) {
12320                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12321         } else {
12322                 DO_ASSERT(get_jenv_res == JNI_OK);
12323         }
12324         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12325         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12326         LDKInit msg_var = *msg;
12327         int64_t msg_ref = 0;
12328         msg_var = Init_clone(&msg_var);
12329         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12330         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12331         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12332         CHECK(obj != NULL);
12333         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
12334         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12335                 (*env)->ExceptionDescribe(env);
12336                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
12337         }
12338         void* ret_ptr = untag_ptr(ret);
12339         CHECK_ACCESS(ret_ptr);
12340         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
12341         FREE(untag_ptr(ret));
12342         if (get_jenv_res == JNI_EDETACHED) {
12343                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12344         }
12345         return ret_conv;
12346 }
12347 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
12348         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12349         JNIEnv *env;
12350         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12351         if (get_jenv_res == JNI_EDETACHED) {
12352                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12353         } else {
12354                 DO_ASSERT(get_jenv_res == JNI_OK);
12355         }
12356         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12357         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12358         LDKChannelReestablish msg_var = *msg;
12359         int64_t msg_ref = 0;
12360         msg_var = ChannelReestablish_clone(&msg_var);
12361         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12362         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12363         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12364         CHECK(obj != NULL);
12365         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
12366         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12367                 (*env)->ExceptionDescribe(env);
12368                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
12369         }
12370         if (get_jenv_res == JNI_EDETACHED) {
12371                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12372         }
12373 }
12374 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
12375         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12376         JNIEnv *env;
12377         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12378         if (get_jenv_res == JNI_EDETACHED) {
12379                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12380         } else {
12381                 DO_ASSERT(get_jenv_res == JNI_OK);
12382         }
12383         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12384         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12385         LDKChannelUpdate msg_var = *msg;
12386         int64_t msg_ref = 0;
12387         msg_var = ChannelUpdate_clone(&msg_var);
12388         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12389         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12390         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12391         CHECK(obj != NULL);
12392         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
12393         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12394                 (*env)->ExceptionDescribe(env);
12395                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
12396         }
12397         if (get_jenv_res == JNI_EDETACHED) {
12398                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12399         }
12400 }
12401 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
12402         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12403         JNIEnv *env;
12404         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12405         if (get_jenv_res == JNI_EDETACHED) {
12406                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12407         } else {
12408                 DO_ASSERT(get_jenv_res == JNI_OK);
12409         }
12410         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12411         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12412         LDKErrorMessage msg_var = *msg;
12413         int64_t msg_ref = 0;
12414         msg_var = ErrorMessage_clone(&msg_var);
12415         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12416         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12417         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12418         CHECK(obj != NULL);
12419         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
12420         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12421                 (*env)->ExceptionDescribe(env);
12422                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
12423         }
12424         if (get_jenv_res == JNI_EDETACHED) {
12425                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12426         }
12427 }
12428 LDKNodeFeatures provided_node_features_LDKChannelMessageHandler_jcall(const void* this_arg) {
12429         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12430         JNIEnv *env;
12431         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12432         if (get_jenv_res == JNI_EDETACHED) {
12433                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12434         } else {
12435                 DO_ASSERT(get_jenv_res == JNI_OK);
12436         }
12437         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12438         CHECK(obj != NULL);
12439         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_node_features_meth);
12440         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12441                 (*env)->ExceptionDescribe(env);
12442                 (*env)->FatalError(env, "A call to provided_node_features in LDKChannelMessageHandler from rust threw an exception.");
12443         }
12444         LDKNodeFeatures ret_conv;
12445         ret_conv.inner = untag_ptr(ret);
12446         ret_conv.is_owned = ptr_is_owned(ret);
12447         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
12448         if (get_jenv_res == JNI_EDETACHED) {
12449                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12450         }
12451         return ret_conv;
12452 }
12453 LDKInitFeatures provided_init_features_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
12454         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12455         JNIEnv *env;
12456         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12457         if (get_jenv_res == JNI_EDETACHED) {
12458                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12459         } else {
12460                 DO_ASSERT(get_jenv_res == JNI_OK);
12461         }
12462         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12463         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12464         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12465         CHECK(obj != NULL);
12466         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_init_features_meth, their_node_id_arr);
12467         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12468                 (*env)->ExceptionDescribe(env);
12469                 (*env)->FatalError(env, "A call to provided_init_features in LDKChannelMessageHandler from rust threw an exception.");
12470         }
12471         LDKInitFeatures ret_conv;
12472         ret_conv.inner = untag_ptr(ret);
12473         ret_conv.is_owned = ptr_is_owned(ret);
12474         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
12475         if (get_jenv_res == JNI_EDETACHED) {
12476                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12477         }
12478         return ret_conv;
12479 }
12480 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
12481         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
12482         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12483         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
12484 }
12485 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12486         jclass c = (*env)->GetObjectClass(env, o);
12487         CHECK(c != NULL);
12488         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
12489         atomic_init(&calls->refcnt, 1);
12490         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12491         calls->o = (*env)->NewWeakGlobalRef(env, o);
12492         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
12493         CHECK(calls->handle_open_channel_meth != NULL);
12494         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
12495         CHECK(calls->handle_accept_channel_meth != NULL);
12496         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
12497         CHECK(calls->handle_funding_created_meth != NULL);
12498         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
12499         CHECK(calls->handle_funding_signed_meth != NULL);
12500         calls->handle_channel_ready_meth = (*env)->GetMethodID(env, c, "handle_channel_ready", "([BJ)V");
12501         CHECK(calls->handle_channel_ready_meth != NULL);
12502         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
12503         CHECK(calls->handle_shutdown_meth != NULL);
12504         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
12505         CHECK(calls->handle_closing_signed_meth != NULL);
12506         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
12507         CHECK(calls->handle_update_add_htlc_meth != NULL);
12508         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
12509         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
12510         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
12511         CHECK(calls->handle_update_fail_htlc_meth != NULL);
12512         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
12513         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
12514         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
12515         CHECK(calls->handle_commitment_signed_meth != NULL);
12516         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
12517         CHECK(calls->handle_revoke_and_ack_meth != NULL);
12518         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
12519         CHECK(calls->handle_update_fee_meth != NULL);
12520         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
12521         CHECK(calls->handle_announcement_signatures_meth != NULL);
12522         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
12523         CHECK(calls->peer_disconnected_meth != NULL);
12524         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)J");
12525         CHECK(calls->peer_connected_meth != NULL);
12526         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
12527         CHECK(calls->handle_channel_reestablish_meth != NULL);
12528         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
12529         CHECK(calls->handle_channel_update_meth != NULL);
12530         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
12531         CHECK(calls->handle_error_meth != NULL);
12532         calls->provided_node_features_meth = (*env)->GetMethodID(env, c, "provided_node_features", "()J");
12533         CHECK(calls->provided_node_features_meth != NULL);
12534         calls->provided_init_features_meth = (*env)->GetMethodID(env, c, "provided_init_features", "([B)J");
12535         CHECK(calls->provided_init_features_meth != NULL);
12536
12537         LDKChannelMessageHandler ret = {
12538                 .this_arg = (void*) calls,
12539                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
12540                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
12541                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
12542                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
12543                 .handle_channel_ready = handle_channel_ready_LDKChannelMessageHandler_jcall,
12544                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
12545                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
12546                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
12547                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
12548                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
12549                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
12550                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
12551                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
12552                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
12553                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
12554                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
12555                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
12556                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
12557                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
12558                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
12559                 .provided_node_features = provided_node_features_LDKChannelMessageHandler_jcall,
12560                 .provided_init_features = provided_init_features_LDKChannelMessageHandler_jcall,
12561                 .free = LDKChannelMessageHandler_JCalls_free,
12562                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
12563         };
12564         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
12565         return ret;
12566 }
12567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12568         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
12569         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
12570         return tag_ptr(res_ptr, true);
12571 }
12572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
12573         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)untag_ptr(arg);
12574         return tag_ptr(&inp->MessageSendEventsProvider, false);
12575 }
12576 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) {
12577         void* this_arg_ptr = untag_ptr(this_arg);
12578         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12579         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12580         LDKPublicKey their_node_id_ref;
12581         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12582         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12583         LDKInitFeatures their_features_conv;
12584         their_features_conv.inner = untag_ptr(their_features);
12585         their_features_conv.is_owned = ptr_is_owned(their_features);
12586         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12587         their_features_conv = InitFeatures_clone(&their_features_conv);
12588         LDKOpenChannel msg_conv;
12589         msg_conv.inner = untag_ptr(msg);
12590         msg_conv.is_owned = ptr_is_owned(msg);
12591         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12592         msg_conv.is_owned = false;
12593         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
12594 }
12595
12596 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) {
12597         void* this_arg_ptr = untag_ptr(this_arg);
12598         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12599         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12600         LDKPublicKey their_node_id_ref;
12601         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12602         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12603         LDKInitFeatures their_features_conv;
12604         their_features_conv.inner = untag_ptr(their_features);
12605         their_features_conv.is_owned = ptr_is_owned(their_features);
12606         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12607         their_features_conv = InitFeatures_clone(&their_features_conv);
12608         LDKAcceptChannel msg_conv;
12609         msg_conv.inner = untag_ptr(msg);
12610         msg_conv.is_owned = ptr_is_owned(msg);
12611         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12612         msg_conv.is_owned = false;
12613         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
12614 }
12615
12616 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) {
12617         void* this_arg_ptr = untag_ptr(this_arg);
12618         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12619         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12620         LDKPublicKey their_node_id_ref;
12621         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12622         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12623         LDKFundingCreated msg_conv;
12624         msg_conv.inner = untag_ptr(msg);
12625         msg_conv.is_owned = ptr_is_owned(msg);
12626         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12627         msg_conv.is_owned = false;
12628         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12629 }
12630
12631 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) {
12632         void* this_arg_ptr = untag_ptr(this_arg);
12633         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12634         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12635         LDKPublicKey their_node_id_ref;
12636         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12637         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12638         LDKFundingSigned msg_conv;
12639         msg_conv.inner = untag_ptr(msg);
12640         msg_conv.is_owned = ptr_is_owned(msg);
12641         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12642         msg_conv.is_owned = false;
12643         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12644 }
12645
12646 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) {
12647         void* this_arg_ptr = untag_ptr(this_arg);
12648         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12649         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12650         LDKPublicKey their_node_id_ref;
12651         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12652         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12653         LDKChannelReady msg_conv;
12654         msg_conv.inner = untag_ptr(msg);
12655         msg_conv.is_owned = ptr_is_owned(msg);
12656         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12657         msg_conv.is_owned = false;
12658         (this_arg_conv->handle_channel_ready)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12659 }
12660
12661 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) {
12662         void* this_arg_ptr = untag_ptr(this_arg);
12663         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12664         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12665         LDKPublicKey their_node_id_ref;
12666         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12667         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12668         LDKInitFeatures their_features_conv;
12669         their_features_conv.inner = untag_ptr(their_features);
12670         their_features_conv.is_owned = ptr_is_owned(their_features);
12671         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12672         their_features_conv.is_owned = false;
12673         LDKShutdown msg_conv;
12674         msg_conv.inner = untag_ptr(msg);
12675         msg_conv.is_owned = ptr_is_owned(msg);
12676         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12677         msg_conv.is_owned = false;
12678         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
12679 }
12680
12681 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) {
12682         void* this_arg_ptr = untag_ptr(this_arg);
12683         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12684         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12685         LDKPublicKey their_node_id_ref;
12686         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12687         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12688         LDKClosingSigned msg_conv;
12689         msg_conv.inner = untag_ptr(msg);
12690         msg_conv.is_owned = ptr_is_owned(msg);
12691         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12692         msg_conv.is_owned = false;
12693         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12694 }
12695
12696 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) {
12697         void* this_arg_ptr = untag_ptr(this_arg);
12698         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12699         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12700         LDKPublicKey their_node_id_ref;
12701         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12702         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12703         LDKUpdateAddHTLC msg_conv;
12704         msg_conv.inner = untag_ptr(msg);
12705         msg_conv.is_owned = ptr_is_owned(msg);
12706         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12707         msg_conv.is_owned = false;
12708         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12709 }
12710
12711 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) {
12712         void* this_arg_ptr = untag_ptr(this_arg);
12713         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12714         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12715         LDKPublicKey their_node_id_ref;
12716         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12717         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12718         LDKUpdateFulfillHTLC msg_conv;
12719         msg_conv.inner = untag_ptr(msg);
12720         msg_conv.is_owned = ptr_is_owned(msg);
12721         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12722         msg_conv.is_owned = false;
12723         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12724 }
12725
12726 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) {
12727         void* this_arg_ptr = untag_ptr(this_arg);
12728         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12729         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12730         LDKPublicKey their_node_id_ref;
12731         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12732         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12733         LDKUpdateFailHTLC msg_conv;
12734         msg_conv.inner = untag_ptr(msg);
12735         msg_conv.is_owned = ptr_is_owned(msg);
12736         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12737         msg_conv.is_owned = false;
12738         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12739 }
12740
12741 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) {
12742         void* this_arg_ptr = untag_ptr(this_arg);
12743         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12744         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12745         LDKPublicKey their_node_id_ref;
12746         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12747         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12748         LDKUpdateFailMalformedHTLC msg_conv;
12749         msg_conv.inner = untag_ptr(msg);
12750         msg_conv.is_owned = ptr_is_owned(msg);
12751         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12752         msg_conv.is_owned = false;
12753         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12754 }
12755
12756 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) {
12757         void* this_arg_ptr = untag_ptr(this_arg);
12758         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12759         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12760         LDKPublicKey their_node_id_ref;
12761         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12762         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12763         LDKCommitmentSigned msg_conv;
12764         msg_conv.inner = untag_ptr(msg);
12765         msg_conv.is_owned = ptr_is_owned(msg);
12766         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12767         msg_conv.is_owned = false;
12768         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12769 }
12770
12771 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) {
12772         void* this_arg_ptr = untag_ptr(this_arg);
12773         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12774         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12775         LDKPublicKey their_node_id_ref;
12776         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12777         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12778         LDKRevokeAndACK msg_conv;
12779         msg_conv.inner = untag_ptr(msg);
12780         msg_conv.is_owned = ptr_is_owned(msg);
12781         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12782         msg_conv.is_owned = false;
12783         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12784 }
12785
12786 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) {
12787         void* this_arg_ptr = untag_ptr(this_arg);
12788         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12789         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12790         LDKPublicKey their_node_id_ref;
12791         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12792         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12793         LDKUpdateFee msg_conv;
12794         msg_conv.inner = untag_ptr(msg);
12795         msg_conv.is_owned = ptr_is_owned(msg);
12796         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12797         msg_conv.is_owned = false;
12798         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12799 }
12800
12801 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) {
12802         void* this_arg_ptr = untag_ptr(this_arg);
12803         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12804         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12805         LDKPublicKey their_node_id_ref;
12806         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12807         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12808         LDKAnnouncementSignatures msg_conv;
12809         msg_conv.inner = untag_ptr(msg);
12810         msg_conv.is_owned = ptr_is_owned(msg);
12811         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12812         msg_conv.is_owned = false;
12813         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12814 }
12815
12816 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) {
12817         void* this_arg_ptr = untag_ptr(this_arg);
12818         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12819         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12820         LDKPublicKey their_node_id_ref;
12821         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12822         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12823         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
12824 }
12825
12826 JNIEXPORT int64_t 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) {
12827         void* this_arg_ptr = untag_ptr(this_arg);
12828         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12829         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12830         LDKPublicKey their_node_id_ref;
12831         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12832         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12833         LDKInit msg_conv;
12834         msg_conv.inner = untag_ptr(msg);
12835         msg_conv.is_owned = ptr_is_owned(msg);
12836         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12837         msg_conv.is_owned = false;
12838         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
12839         *ret_conv = (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12840         return tag_ptr(ret_conv, true);
12841 }
12842
12843 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) {
12844         void* this_arg_ptr = untag_ptr(this_arg);
12845         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12846         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12847         LDKPublicKey their_node_id_ref;
12848         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12849         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12850         LDKChannelReestablish msg_conv;
12851         msg_conv.inner = untag_ptr(msg);
12852         msg_conv.is_owned = ptr_is_owned(msg);
12853         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12854         msg_conv.is_owned = false;
12855         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12856 }
12857
12858 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) {
12859         void* this_arg_ptr = untag_ptr(this_arg);
12860         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12861         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12862         LDKPublicKey their_node_id_ref;
12863         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12864         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12865         LDKChannelUpdate msg_conv;
12866         msg_conv.inner = untag_ptr(msg);
12867         msg_conv.is_owned = ptr_is_owned(msg);
12868         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12869         msg_conv.is_owned = false;
12870         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12871 }
12872
12873 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) {
12874         void* this_arg_ptr = untag_ptr(this_arg);
12875         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12876         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12877         LDKPublicKey their_node_id_ref;
12878         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12879         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12880         LDKErrorMessage msg_conv;
12881         msg_conv.inner = untag_ptr(msg);
12882         msg_conv.is_owned = ptr_is_owned(msg);
12883         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12884         msg_conv.is_owned = false;
12885         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12886 }
12887
12888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1provided_1node_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
12889         void* this_arg_ptr = untag_ptr(this_arg);
12890         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12891         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12892         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
12893         int64_t ret_ref = 0;
12894         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
12895         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
12896         return ret_ref;
12897 }
12898
12899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1provided_1init_1features(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id) {
12900         void* this_arg_ptr = untag_ptr(this_arg);
12901         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12902         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12903         LDKPublicKey their_node_id_ref;
12904         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12905         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12906         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
12907         int64_t ret_ref = 0;
12908         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
12909         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
12910         return ret_ref;
12911 }
12912
12913 typedef struct LDKRoutingMessageHandler_JCalls {
12914         atomic_size_t refcnt;
12915         JavaVM *vm;
12916         jweak o;
12917         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
12918         jmethodID handle_node_announcement_meth;
12919         jmethodID handle_channel_announcement_meth;
12920         jmethodID handle_channel_update_meth;
12921         jmethodID get_next_channel_announcement_meth;
12922         jmethodID get_next_node_announcement_meth;
12923         jmethodID peer_connected_meth;
12924         jmethodID handle_reply_channel_range_meth;
12925         jmethodID handle_reply_short_channel_ids_end_meth;
12926         jmethodID handle_query_channel_range_meth;
12927         jmethodID handle_query_short_channel_ids_meth;
12928         jmethodID provided_node_features_meth;
12929         jmethodID provided_init_features_meth;
12930 } LDKRoutingMessageHandler_JCalls;
12931 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
12932         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12933         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12934                 JNIEnv *env;
12935                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12936                 if (get_jenv_res == JNI_EDETACHED) {
12937                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12938                 } else {
12939                         DO_ASSERT(get_jenv_res == JNI_OK);
12940                 }
12941                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12942                 if (get_jenv_res == JNI_EDETACHED) {
12943                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12944                 }
12945                 FREE(j_calls);
12946         }
12947 }
12948 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
12949         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12950         JNIEnv *env;
12951         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12952         if (get_jenv_res == JNI_EDETACHED) {
12953                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12954         } else {
12955                 DO_ASSERT(get_jenv_res == JNI_OK);
12956         }
12957         LDKNodeAnnouncement msg_var = *msg;
12958         int64_t msg_ref = 0;
12959         msg_var = NodeAnnouncement_clone(&msg_var);
12960         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12961         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12962         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12963         CHECK(obj != NULL);
12964         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
12965         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12966                 (*env)->ExceptionDescribe(env);
12967                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
12968         }
12969         void* ret_ptr = untag_ptr(ret);
12970         CHECK_ACCESS(ret_ptr);
12971         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
12972         FREE(untag_ptr(ret));
12973         if (get_jenv_res == JNI_EDETACHED) {
12974                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12975         }
12976         return ret_conv;
12977 }
12978 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
12979         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12980         JNIEnv *env;
12981         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12982         if (get_jenv_res == JNI_EDETACHED) {
12983                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12984         } else {
12985                 DO_ASSERT(get_jenv_res == JNI_OK);
12986         }
12987         LDKChannelAnnouncement msg_var = *msg;
12988         int64_t msg_ref = 0;
12989         msg_var = ChannelAnnouncement_clone(&msg_var);
12990         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12991         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12992         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12993         CHECK(obj != NULL);
12994         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
12995         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12996                 (*env)->ExceptionDescribe(env);
12997                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
12998         }
12999         void* ret_ptr = untag_ptr(ret);
13000         CHECK_ACCESS(ret_ptr);
13001         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
13002         FREE(untag_ptr(ret));
13003         if (get_jenv_res == JNI_EDETACHED) {
13004                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13005         }
13006         return ret_conv;
13007 }
13008 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
13009         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13010         JNIEnv *env;
13011         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13012         if (get_jenv_res == JNI_EDETACHED) {
13013                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13014         } else {
13015                 DO_ASSERT(get_jenv_res == JNI_OK);
13016         }
13017         LDKChannelUpdate msg_var = *msg;
13018         int64_t msg_ref = 0;
13019         msg_var = ChannelUpdate_clone(&msg_var);
13020         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13021         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13022         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13023         CHECK(obj != NULL);
13024         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
13025         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13026                 (*env)->ExceptionDescribe(env);
13027                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
13028         }
13029         void* ret_ptr = untag_ptr(ret);
13030         CHECK_ACCESS(ret_ptr);
13031         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
13032         FREE(untag_ptr(ret));
13033         if (get_jenv_res == JNI_EDETACHED) {
13034                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13035         }
13036         return ret_conv;
13037 }
13038 LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point) {
13039         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13040         JNIEnv *env;
13041         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13042         if (get_jenv_res == JNI_EDETACHED) {
13043                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13044         } else {
13045                 DO_ASSERT(get_jenv_res == JNI_OK);
13046         }
13047         int64_t starting_point_conv = starting_point;
13048         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13049         CHECK(obj != NULL);
13050         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_next_channel_announcement_meth, starting_point_conv);
13051         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13052                 (*env)->ExceptionDescribe(env);
13053                 (*env)->FatalError(env, "A call to get_next_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
13054         }
13055         void* ret_ptr = untag_ptr(ret);
13056         CHECK_ACCESS(ret_ptr);
13057         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_conv = *(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)(ret_ptr);
13058         FREE(untag_ptr(ret));
13059         if (get_jenv_res == JNI_EDETACHED) {
13060                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13061         }
13062         return ret_conv;
13063 }
13064 LDKNodeAnnouncement get_next_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point) {
13065         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13066         JNIEnv *env;
13067         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13068         if (get_jenv_res == JNI_EDETACHED) {
13069                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13070         } else {
13071                 DO_ASSERT(get_jenv_res == JNI_OK);
13072         }
13073         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
13074         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
13075         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13076         CHECK(obj != NULL);
13077         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_next_node_announcement_meth, starting_point_arr);
13078         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13079                 (*env)->ExceptionDescribe(env);
13080                 (*env)->FatalError(env, "A call to get_next_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
13081         }
13082         LDKNodeAnnouncement ret_conv;
13083         ret_conv.inner = untag_ptr(ret);
13084         ret_conv.is_owned = ptr_is_owned(ret);
13085         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13086         if (get_jenv_res == JNI_EDETACHED) {
13087                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13088         }
13089         return ret_conv;
13090 }
13091 LDKCResult_NoneNoneZ peer_connected_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
13092         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13093         JNIEnv *env;
13094         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13095         if (get_jenv_res == JNI_EDETACHED) {
13096                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13097         } else {
13098                 DO_ASSERT(get_jenv_res == JNI_OK);
13099         }
13100         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13101         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13102         LDKInit init_var = *init;
13103         int64_t init_ref = 0;
13104         init_var = Init_clone(&init_var);
13105         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
13106         init_ref = tag_ptr(init_var.inner, init_var.is_owned);
13107         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13108         CHECK(obj != NULL);
13109         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, init_ref);
13110         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13111                 (*env)->ExceptionDescribe(env);
13112                 (*env)->FatalError(env, "A call to peer_connected in LDKRoutingMessageHandler from rust threw an exception.");
13113         }
13114         void* ret_ptr = untag_ptr(ret);
13115         CHECK_ACCESS(ret_ptr);
13116         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
13117         FREE(untag_ptr(ret));
13118         if (get_jenv_res == JNI_EDETACHED) {
13119                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13120         }
13121         return ret_conv;
13122 }
13123 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
13124         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13125         JNIEnv *env;
13126         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13127         if (get_jenv_res == JNI_EDETACHED) {
13128                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13129         } else {
13130                 DO_ASSERT(get_jenv_res == JNI_OK);
13131         }
13132         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13133         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13134         LDKReplyChannelRange msg_var = msg;
13135         int64_t msg_ref = 0;
13136         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13137         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13138         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13139         CHECK(obj != NULL);
13140         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
13141         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13142                 (*env)->ExceptionDescribe(env);
13143                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
13144         }
13145         void* ret_ptr = untag_ptr(ret);
13146         CHECK_ACCESS(ret_ptr);
13147         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13148         FREE(untag_ptr(ret));
13149         if (get_jenv_res == JNI_EDETACHED) {
13150                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13151         }
13152         return ret_conv;
13153 }
13154 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
13155         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13156         JNIEnv *env;
13157         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13158         if (get_jenv_res == JNI_EDETACHED) {
13159                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13160         } else {
13161                 DO_ASSERT(get_jenv_res == JNI_OK);
13162         }
13163         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13164         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13165         LDKReplyShortChannelIdsEnd msg_var = msg;
13166         int64_t msg_ref = 0;
13167         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13168         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13169         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13170         CHECK(obj != NULL);
13171         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
13172         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13173                 (*env)->ExceptionDescribe(env);
13174                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
13175         }
13176         void* ret_ptr = untag_ptr(ret);
13177         CHECK_ACCESS(ret_ptr);
13178         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13179         FREE(untag_ptr(ret));
13180         if (get_jenv_res == JNI_EDETACHED) {
13181                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13182         }
13183         return ret_conv;
13184 }
13185 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
13186         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13187         JNIEnv *env;
13188         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13189         if (get_jenv_res == JNI_EDETACHED) {
13190                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13191         } else {
13192                 DO_ASSERT(get_jenv_res == JNI_OK);
13193         }
13194         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13195         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13196         LDKQueryChannelRange msg_var = msg;
13197         int64_t msg_ref = 0;
13198         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13199         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13200         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13201         CHECK(obj != NULL);
13202         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
13203         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13204                 (*env)->ExceptionDescribe(env);
13205                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
13206         }
13207         void* ret_ptr = untag_ptr(ret);
13208         CHECK_ACCESS(ret_ptr);
13209         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13210         FREE(untag_ptr(ret));
13211         if (get_jenv_res == JNI_EDETACHED) {
13212                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13213         }
13214         return ret_conv;
13215 }
13216 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
13217         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13218         JNIEnv *env;
13219         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13220         if (get_jenv_res == JNI_EDETACHED) {
13221                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13222         } else {
13223                 DO_ASSERT(get_jenv_res == JNI_OK);
13224         }
13225         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13226         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13227         LDKQueryShortChannelIds msg_var = msg;
13228         int64_t msg_ref = 0;
13229         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13230         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13231         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13232         CHECK(obj != NULL);
13233         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
13234         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13235                 (*env)->ExceptionDescribe(env);
13236                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
13237         }
13238         void* ret_ptr = untag_ptr(ret);
13239         CHECK_ACCESS(ret_ptr);
13240         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13241         FREE(untag_ptr(ret));
13242         if (get_jenv_res == JNI_EDETACHED) {
13243                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13244         }
13245         return ret_conv;
13246 }
13247 LDKNodeFeatures provided_node_features_LDKRoutingMessageHandler_jcall(const void* this_arg) {
13248         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13249         JNIEnv *env;
13250         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13251         if (get_jenv_res == JNI_EDETACHED) {
13252                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13253         } else {
13254                 DO_ASSERT(get_jenv_res == JNI_OK);
13255         }
13256         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13257         CHECK(obj != NULL);
13258         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_node_features_meth);
13259         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13260                 (*env)->ExceptionDescribe(env);
13261                 (*env)->FatalError(env, "A call to provided_node_features in LDKRoutingMessageHandler from rust threw an exception.");
13262         }
13263         LDKNodeFeatures ret_conv;
13264         ret_conv.inner = untag_ptr(ret);
13265         ret_conv.is_owned = ptr_is_owned(ret);
13266         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13267         if (get_jenv_res == JNI_EDETACHED) {
13268                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13269         }
13270         return ret_conv;
13271 }
13272 LDKInitFeatures provided_init_features_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
13273         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13274         JNIEnv *env;
13275         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13276         if (get_jenv_res == JNI_EDETACHED) {
13277                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13278         } else {
13279                 DO_ASSERT(get_jenv_res == JNI_OK);
13280         }
13281         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13282         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13283         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13284         CHECK(obj != NULL);
13285         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_init_features_meth, their_node_id_arr);
13286         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13287                 (*env)->ExceptionDescribe(env);
13288                 (*env)->FatalError(env, "A call to provided_init_features in LDKRoutingMessageHandler from rust threw an exception.");
13289         }
13290         LDKInitFeatures ret_conv;
13291         ret_conv.inner = untag_ptr(ret);
13292         ret_conv.is_owned = ptr_is_owned(ret);
13293         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13294         if (get_jenv_res == JNI_EDETACHED) {
13295                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13296         }
13297         return ret_conv;
13298 }
13299 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
13300         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
13301         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13302         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
13303 }
13304 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
13305         jclass c = (*env)->GetObjectClass(env, o);
13306         CHECK(c != NULL);
13307         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
13308         atomic_init(&calls->refcnt, 1);
13309         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13310         calls->o = (*env)->NewWeakGlobalRef(env, o);
13311         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
13312         CHECK(calls->handle_node_announcement_meth != NULL);
13313         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
13314         CHECK(calls->handle_channel_announcement_meth != NULL);
13315         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
13316         CHECK(calls->handle_channel_update_meth != NULL);
13317         calls->get_next_channel_announcement_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcement", "(J)J");
13318         CHECK(calls->get_next_channel_announcement_meth != NULL);
13319         calls->get_next_node_announcement_meth = (*env)->GetMethodID(env, c, "get_next_node_announcement", "([B)J");
13320         CHECK(calls->get_next_node_announcement_meth != NULL);
13321         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)J");
13322         CHECK(calls->peer_connected_meth != NULL);
13323         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
13324         CHECK(calls->handle_reply_channel_range_meth != NULL);
13325         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
13326         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
13327         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
13328         CHECK(calls->handle_query_channel_range_meth != NULL);
13329         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
13330         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
13331         calls->provided_node_features_meth = (*env)->GetMethodID(env, c, "provided_node_features", "()J");
13332         CHECK(calls->provided_node_features_meth != NULL);
13333         calls->provided_init_features_meth = (*env)->GetMethodID(env, c, "provided_init_features", "([B)J");
13334         CHECK(calls->provided_init_features_meth != NULL);
13335
13336         LDKRoutingMessageHandler ret = {
13337                 .this_arg = (void*) calls,
13338                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
13339                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
13340                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
13341                 .get_next_channel_announcement = get_next_channel_announcement_LDKRoutingMessageHandler_jcall,
13342                 .get_next_node_announcement = get_next_node_announcement_LDKRoutingMessageHandler_jcall,
13343                 .peer_connected = peer_connected_LDKRoutingMessageHandler_jcall,
13344                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
13345                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
13346                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
13347                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
13348                 .provided_node_features = provided_node_features_LDKRoutingMessageHandler_jcall,
13349                 .provided_init_features = provided_init_features_LDKRoutingMessageHandler_jcall,
13350                 .free = LDKRoutingMessageHandler_JCalls_free,
13351                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
13352         };
13353         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
13354         return ret;
13355 }
13356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
13357         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
13358         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
13359         return tag_ptr(res_ptr, true);
13360 }
13361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
13362         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)untag_ptr(arg);
13363         return tag_ptr(&inp->MessageSendEventsProvider, false);
13364 }
13365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13366         void* this_arg_ptr = untag_ptr(this_arg);
13367         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13368         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13369         LDKNodeAnnouncement msg_conv;
13370         msg_conv.inner = untag_ptr(msg);
13371         msg_conv.is_owned = ptr_is_owned(msg);
13372         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13373         msg_conv.is_owned = false;
13374         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13375         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
13376         return tag_ptr(ret_conv, true);
13377 }
13378
13379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13380         void* this_arg_ptr = untag_ptr(this_arg);
13381         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13382         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13383         LDKChannelAnnouncement msg_conv;
13384         msg_conv.inner = untag_ptr(msg);
13385         msg_conv.is_owned = ptr_is_owned(msg);
13386         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13387         msg_conv.is_owned = false;
13388         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13389         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
13390         return tag_ptr(ret_conv, true);
13391 }
13392
13393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13394         void* this_arg_ptr = untag_ptr(this_arg);
13395         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13396         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13397         LDKChannelUpdate msg_conv;
13398         msg_conv.inner = untag_ptr(msg);
13399         msg_conv.is_owned = ptr_is_owned(msg);
13400         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13401         msg_conv.is_owned = false;
13402         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13403         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
13404         return tag_ptr(ret_conv, true);
13405 }
13406
13407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t starting_point) {
13408         void* this_arg_ptr = untag_ptr(this_arg);
13409         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13410         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13411         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
13412         *ret_copy = (this_arg_conv->get_next_channel_announcement)(this_arg_conv->this_arg, starting_point);
13413         int64_t ret_ref = tag_ptr(ret_copy, true);
13414         return ret_ref;
13415 }
13416
13417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray starting_point) {
13418         void* this_arg_ptr = untag_ptr(this_arg);
13419         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13420         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13421         LDKPublicKey starting_point_ref;
13422         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
13423         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
13424         LDKNodeAnnouncement ret_var = (this_arg_conv->get_next_node_announcement)(this_arg_conv->this_arg, starting_point_ref);
13425         int64_t ret_ref = 0;
13426         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
13427         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
13428         return ret_ref;
13429 }
13430
13431 JNIEXPORT int64_t 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) {
13432         void* this_arg_ptr = untag_ptr(this_arg);
13433         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13434         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13435         LDKPublicKey their_node_id_ref;
13436         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13437         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13438         LDKInit init_conv;
13439         init_conv.inner = untag_ptr(init);
13440         init_conv.is_owned = ptr_is_owned(init);
13441         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
13442         init_conv.is_owned = false;
13443         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13444         *ret_conv = (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
13445         return tag_ptr(ret_conv, true);
13446 }
13447
13448 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) {
13449         void* this_arg_ptr = untag_ptr(this_arg);
13450         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13451         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13452         LDKPublicKey their_node_id_ref;
13453         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13454         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13455         LDKReplyChannelRange msg_conv;
13456         msg_conv.inner = untag_ptr(msg);
13457         msg_conv.is_owned = ptr_is_owned(msg);
13458         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13459         msg_conv = ReplyChannelRange_clone(&msg_conv);
13460         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13461         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13462         return tag_ptr(ret_conv, true);
13463 }
13464
13465 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) {
13466         void* this_arg_ptr = untag_ptr(this_arg);
13467         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13468         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13469         LDKPublicKey their_node_id_ref;
13470         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13471         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13472         LDKReplyShortChannelIdsEnd msg_conv;
13473         msg_conv.inner = untag_ptr(msg);
13474         msg_conv.is_owned = ptr_is_owned(msg);
13475         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13476         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
13477         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13478         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13479         return tag_ptr(ret_conv, true);
13480 }
13481
13482 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) {
13483         void* this_arg_ptr = untag_ptr(this_arg);
13484         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13485         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13486         LDKPublicKey their_node_id_ref;
13487         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13488         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13489         LDKQueryChannelRange msg_conv;
13490         msg_conv.inner = untag_ptr(msg);
13491         msg_conv.is_owned = ptr_is_owned(msg);
13492         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13493         msg_conv = QueryChannelRange_clone(&msg_conv);
13494         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13495         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13496         return tag_ptr(ret_conv, true);
13497 }
13498
13499 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) {
13500         void* this_arg_ptr = untag_ptr(this_arg);
13501         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13502         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13503         LDKPublicKey their_node_id_ref;
13504         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13505         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13506         LDKQueryShortChannelIds msg_conv;
13507         msg_conv.inner = untag_ptr(msg);
13508         msg_conv.is_owned = ptr_is_owned(msg);
13509         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13510         msg_conv = QueryShortChannelIds_clone(&msg_conv);
13511         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13512         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13513         return tag_ptr(ret_conv, true);
13514 }
13515
13516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1provided_1node_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
13517         void* this_arg_ptr = untag_ptr(this_arg);
13518         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13519         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13520         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
13521         int64_t ret_ref = 0;
13522         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
13523         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
13524         return ret_ref;
13525 }
13526
13527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1provided_1init_1features(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id) {
13528         void* this_arg_ptr = untag_ptr(this_arg);
13529         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13530         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13531         LDKPublicKey their_node_id_ref;
13532         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13533         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13534         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
13535         int64_t ret_ref = 0;
13536         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
13537         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
13538         return ret_ref;
13539 }
13540
13541 typedef struct LDKOnionMessageHandler_JCalls {
13542         atomic_size_t refcnt;
13543         JavaVM *vm;
13544         jweak o;
13545         LDKOnionMessageProvider_JCalls* OnionMessageProvider;
13546         jmethodID handle_onion_message_meth;
13547         jmethodID peer_connected_meth;
13548         jmethodID peer_disconnected_meth;
13549         jmethodID provided_node_features_meth;
13550         jmethodID provided_init_features_meth;
13551 } LDKOnionMessageHandler_JCalls;
13552 static void LDKOnionMessageHandler_JCalls_free(void* this_arg) {
13553         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
13554         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13555                 JNIEnv *env;
13556                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13557                 if (get_jenv_res == JNI_EDETACHED) {
13558                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13559                 } else {
13560                         DO_ASSERT(get_jenv_res == JNI_OK);
13561                 }
13562                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13563                 if (get_jenv_res == JNI_EDETACHED) {
13564                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13565                 }
13566                 FREE(j_calls);
13567         }
13568 }
13569 void handle_onion_message_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey peer_node_id, const LDKOnionMessage * msg) {
13570         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
13571         JNIEnv *env;
13572         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13573         if (get_jenv_res == JNI_EDETACHED) {
13574                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13575         } else {
13576                 DO_ASSERT(get_jenv_res == JNI_OK);
13577         }
13578         int8_tArray peer_node_id_arr = (*env)->NewByteArray(env, 33);
13579         (*env)->SetByteArrayRegion(env, peer_node_id_arr, 0, 33, peer_node_id.compressed_form);
13580         LDKOnionMessage msg_var = *msg;
13581         int64_t msg_ref = 0;
13582         msg_var = OnionMessage_clone(&msg_var);
13583         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13584         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13585         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13586         CHECK(obj != NULL);
13587         (*env)->CallVoidMethod(env, obj, j_calls->handle_onion_message_meth, peer_node_id_arr, msg_ref);
13588         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13589                 (*env)->ExceptionDescribe(env);
13590                 (*env)->FatalError(env, "A call to handle_onion_message in LDKOnionMessageHandler from rust threw an exception.");
13591         }
13592         if (get_jenv_res == JNI_EDETACHED) {
13593                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13594         }
13595 }
13596 LDKCResult_NoneNoneZ peer_connected_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
13597         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
13598         JNIEnv *env;
13599         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13600         if (get_jenv_res == JNI_EDETACHED) {
13601                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13602         } else {
13603                 DO_ASSERT(get_jenv_res == JNI_OK);
13604         }
13605         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13606         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13607         LDKInit init_var = *init;
13608         int64_t init_ref = 0;
13609         init_var = Init_clone(&init_var);
13610         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
13611         init_ref = tag_ptr(init_var.inner, init_var.is_owned);
13612         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13613         CHECK(obj != NULL);
13614         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, init_ref);
13615         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13616                 (*env)->ExceptionDescribe(env);
13617                 (*env)->FatalError(env, "A call to peer_connected in LDKOnionMessageHandler from rust threw an exception.");
13618         }
13619         void* ret_ptr = untag_ptr(ret);
13620         CHECK_ACCESS(ret_ptr);
13621         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
13622         FREE(untag_ptr(ret));
13623         if (get_jenv_res == JNI_EDETACHED) {
13624                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13625         }
13626         return ret_conv;
13627 }
13628 void peer_disconnected_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
13629         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
13630         JNIEnv *env;
13631         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13632         if (get_jenv_res == JNI_EDETACHED) {
13633                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13634         } else {
13635                 DO_ASSERT(get_jenv_res == JNI_OK);
13636         }
13637         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13638         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13639         jboolean no_connection_possible_conv = no_connection_possible;
13640         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13641         CHECK(obj != NULL);
13642         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible_conv);
13643         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13644                 (*env)->ExceptionDescribe(env);
13645                 (*env)->FatalError(env, "A call to peer_disconnected in LDKOnionMessageHandler from rust threw an exception.");
13646         }
13647         if (get_jenv_res == JNI_EDETACHED) {
13648                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13649         }
13650 }
13651 LDKNodeFeatures provided_node_features_LDKOnionMessageHandler_jcall(const void* this_arg) {
13652         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
13653         JNIEnv *env;
13654         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13655         if (get_jenv_res == JNI_EDETACHED) {
13656                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13657         } else {
13658                 DO_ASSERT(get_jenv_res == JNI_OK);
13659         }
13660         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13661         CHECK(obj != NULL);
13662         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_node_features_meth);
13663         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13664                 (*env)->ExceptionDescribe(env);
13665                 (*env)->FatalError(env, "A call to provided_node_features in LDKOnionMessageHandler from rust threw an exception.");
13666         }
13667         LDKNodeFeatures ret_conv;
13668         ret_conv.inner = untag_ptr(ret);
13669         ret_conv.is_owned = ptr_is_owned(ret);
13670         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13671         if (get_jenv_res == JNI_EDETACHED) {
13672                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13673         }
13674         return ret_conv;
13675 }
13676 LDKInitFeatures provided_init_features_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
13677         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
13678         JNIEnv *env;
13679         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13680         if (get_jenv_res == JNI_EDETACHED) {
13681                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13682         } else {
13683                 DO_ASSERT(get_jenv_res == JNI_OK);
13684         }
13685         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13686         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13687         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13688         CHECK(obj != NULL);
13689         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_init_features_meth, their_node_id_arr);
13690         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13691                 (*env)->ExceptionDescribe(env);
13692                 (*env)->FatalError(env, "A call to provided_init_features in LDKOnionMessageHandler from rust threw an exception.");
13693         }
13694         LDKInitFeatures ret_conv;
13695         ret_conv.inner = untag_ptr(ret);
13696         ret_conv.is_owned = ptr_is_owned(ret);
13697         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13698         if (get_jenv_res == JNI_EDETACHED) {
13699                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13700         }
13701         return ret_conv;
13702 }
13703 static void LDKOnionMessageHandler_JCalls_cloned(LDKOnionMessageHandler* new_obj) {
13704         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) new_obj->this_arg;
13705         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13706         atomic_fetch_add_explicit(&j_calls->OnionMessageProvider->refcnt, 1, memory_order_release);
13707 }
13708 static inline LDKOnionMessageHandler LDKOnionMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject OnionMessageProvider) {
13709         jclass c = (*env)->GetObjectClass(env, o);
13710         CHECK(c != NULL);
13711         LDKOnionMessageHandler_JCalls *calls = MALLOC(sizeof(LDKOnionMessageHandler_JCalls), "LDKOnionMessageHandler_JCalls");
13712         atomic_init(&calls->refcnt, 1);
13713         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13714         calls->o = (*env)->NewWeakGlobalRef(env, o);
13715         calls->handle_onion_message_meth = (*env)->GetMethodID(env, c, "handle_onion_message", "([BJ)V");
13716         CHECK(calls->handle_onion_message_meth != NULL);
13717         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)J");
13718         CHECK(calls->peer_connected_meth != NULL);
13719         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
13720         CHECK(calls->peer_disconnected_meth != NULL);
13721         calls->provided_node_features_meth = (*env)->GetMethodID(env, c, "provided_node_features", "()J");
13722         CHECK(calls->provided_node_features_meth != NULL);
13723         calls->provided_init_features_meth = (*env)->GetMethodID(env, c, "provided_init_features", "([B)J");
13724         CHECK(calls->provided_init_features_meth != NULL);
13725
13726         LDKOnionMessageHandler ret = {
13727                 .this_arg = (void*) calls,
13728                 .handle_onion_message = handle_onion_message_LDKOnionMessageHandler_jcall,
13729                 .peer_connected = peer_connected_LDKOnionMessageHandler_jcall,
13730                 .peer_disconnected = peer_disconnected_LDKOnionMessageHandler_jcall,
13731                 .provided_node_features = provided_node_features_LDKOnionMessageHandler_jcall,
13732                 .provided_init_features = provided_init_features_LDKOnionMessageHandler_jcall,
13733                 .free = LDKOnionMessageHandler_JCalls_free,
13734                 .OnionMessageProvider = LDKOnionMessageProvider_init(env, clz, OnionMessageProvider),
13735         };
13736         calls->OnionMessageProvider = ret.OnionMessageProvider.this_arg;
13737         return ret;
13738 }
13739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKOnionMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject OnionMessageProvider) {
13740         LDKOnionMessageHandler *res_ptr = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
13741         *res_ptr = LDKOnionMessageHandler_init(env, clz, o, OnionMessageProvider);
13742         return tag_ptr(res_ptr, true);
13743 }
13744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKOnionMessageHandler_1get_1OnionMessageProvider(JNIEnv *env, jclass clz, int64_t arg) {
13745         LDKOnionMessageHandler *inp = (LDKOnionMessageHandler *)untag_ptr(arg);
13746         return tag_ptr(&inp->OnionMessageProvider, false);
13747 }
13748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1handle_1onion_1message(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray peer_node_id, int64_t msg) {
13749         void* this_arg_ptr = untag_ptr(this_arg);
13750         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13751         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
13752         LDKPublicKey peer_node_id_ref;
13753         CHECK((*env)->GetArrayLength(env, peer_node_id) == 33);
13754         (*env)->GetByteArrayRegion(env, peer_node_id, 0, 33, peer_node_id_ref.compressed_form);
13755         LDKOnionMessage msg_conv;
13756         msg_conv.inner = untag_ptr(msg);
13757         msg_conv.is_owned = ptr_is_owned(msg);
13758         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13759         msg_conv.is_owned = false;
13760         (this_arg_conv->handle_onion_message)(this_arg_conv->this_arg, peer_node_id_ref, &msg_conv);
13761 }
13762
13763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1peer_1connected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t init) {
13764         void* this_arg_ptr = untag_ptr(this_arg);
13765         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13766         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
13767         LDKPublicKey their_node_id_ref;
13768         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13769         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13770         LDKInit init_conv;
13771         init_conv.inner = untag_ptr(init);
13772         init_conv.is_owned = ptr_is_owned(init);
13773         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
13774         init_conv.is_owned = false;
13775         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13776         *ret_conv = (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
13777         return tag_ptr(ret_conv, true);
13778 }
13779
13780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1peer_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
13781         void* this_arg_ptr = untag_ptr(this_arg);
13782         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13783         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
13784         LDKPublicKey their_node_id_ref;
13785         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13786         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13787         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
13788 }
13789
13790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1provided_1node_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
13791         void* this_arg_ptr = untag_ptr(this_arg);
13792         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13793         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
13794         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
13795         int64_t ret_ref = 0;
13796         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
13797         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
13798         return ret_ref;
13799 }
13800
13801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1provided_1init_1features(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id) {
13802         void* this_arg_ptr = untag_ptr(this_arg);
13803         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13804         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
13805         LDKPublicKey their_node_id_ref;
13806         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13807         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13808         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
13809         int64_t ret_ref = 0;
13810         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
13811         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
13812         return ret_ref;
13813 }
13814
13815 typedef struct LDKCustomMessageReader_JCalls {
13816         atomic_size_t refcnt;
13817         JavaVM *vm;
13818         jweak o;
13819         jmethodID read_meth;
13820 } LDKCustomMessageReader_JCalls;
13821 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
13822         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
13823         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13824                 JNIEnv *env;
13825                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13826                 if (get_jenv_res == JNI_EDETACHED) {
13827                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13828                 } else {
13829                         DO_ASSERT(get_jenv_res == JNI_OK);
13830                 }
13831                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13832                 if (get_jenv_res == JNI_EDETACHED) {
13833                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13834                 }
13835                 FREE(j_calls);
13836         }
13837 }
13838 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
13839         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
13840         JNIEnv *env;
13841         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13842         if (get_jenv_res == JNI_EDETACHED) {
13843                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13844         } else {
13845                 DO_ASSERT(get_jenv_res == JNI_OK);
13846         }
13847         int16_t message_type_conv = message_type;
13848         LDKu8slice buffer_var = buffer;
13849         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
13850         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
13851         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13852         CHECK(obj != NULL);
13853         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_meth, message_type_conv, buffer_arr);
13854         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13855                 (*env)->ExceptionDescribe(env);
13856                 (*env)->FatalError(env, "A call to read in LDKCustomMessageReader from rust threw an exception.");
13857         }
13858         void* ret_ptr = untag_ptr(ret);
13859         CHECK_ACCESS(ret_ptr);
13860         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
13861         FREE(untag_ptr(ret));
13862         if (get_jenv_res == JNI_EDETACHED) {
13863                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13864         }
13865         return ret_conv;
13866 }
13867 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
13868         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
13869         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13870 }
13871 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JNIEnv *env, jclass clz, jobject o) {
13872         jclass c = (*env)->GetObjectClass(env, o);
13873         CHECK(c != NULL);
13874         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
13875         atomic_init(&calls->refcnt, 1);
13876         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13877         calls->o = (*env)->NewWeakGlobalRef(env, o);
13878         calls->read_meth = (*env)->GetMethodID(env, c, "read", "(S[B)J");
13879         CHECK(calls->read_meth != NULL);
13880
13881         LDKCustomMessageReader ret = {
13882                 .this_arg = (void*) calls,
13883                 .read = read_LDKCustomMessageReader_jcall,
13884                 .free = LDKCustomMessageReader_JCalls_free,
13885         };
13886         return ret;
13887 }
13888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new(JNIEnv *env, jclass clz, jobject o) {
13889         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
13890         *res_ptr = LDKCustomMessageReader_init(env, clz, o);
13891         return tag_ptr(res_ptr, true);
13892 }
13893 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) {
13894         void* this_arg_ptr = untag_ptr(this_arg);
13895         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13896         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
13897         LDKu8slice buffer_ref;
13898         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
13899         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
13900         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
13901         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
13902         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
13903         return tag_ptr(ret_conv, true);
13904 }
13905
13906 typedef struct LDKCustomMessageHandler_JCalls {
13907         atomic_size_t refcnt;
13908         JavaVM *vm;
13909         jweak o;
13910         LDKCustomMessageReader_JCalls* CustomMessageReader;
13911         jmethodID handle_custom_message_meth;
13912         jmethodID get_and_clear_pending_msg_meth;
13913 } LDKCustomMessageHandler_JCalls;
13914 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
13915         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
13916         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13917                 JNIEnv *env;
13918                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13919                 if (get_jenv_res == JNI_EDETACHED) {
13920                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13921                 } else {
13922                         DO_ASSERT(get_jenv_res == JNI_OK);
13923                 }
13924                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13925                 if (get_jenv_res == JNI_EDETACHED) {
13926                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13927                 }
13928                 FREE(j_calls);
13929         }
13930 }
13931 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
13932         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
13933         JNIEnv *env;
13934         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13935         if (get_jenv_res == JNI_EDETACHED) {
13936                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13937         } else {
13938                 DO_ASSERT(get_jenv_res == JNI_OK);
13939         }
13940         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
13941         *msg_ret = msg;
13942         int8_tArray sender_node_id_arr = (*env)->NewByteArray(env, 33);
13943         (*env)->SetByteArrayRegion(env, sender_node_id_arr, 0, 33, sender_node_id.compressed_form);
13944         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13945         CHECK(obj != NULL);
13946         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_custom_message_meth, tag_ptr(msg_ret, true), sender_node_id_arr);
13947         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13948                 (*env)->ExceptionDescribe(env);
13949                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomMessageHandler from rust threw an exception.");
13950         }
13951         void* ret_ptr = untag_ptr(ret);
13952         CHECK_ACCESS(ret_ptr);
13953         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13954         FREE(untag_ptr(ret));
13955         if (get_jenv_res == JNI_EDETACHED) {
13956                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13957         }
13958         return ret_conv;
13959 }
13960 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
13961         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
13962         JNIEnv *env;
13963         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13964         if (get_jenv_res == JNI_EDETACHED) {
13965                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13966         } else {
13967                 DO_ASSERT(get_jenv_res == JNI_OK);
13968         }
13969         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13970         CHECK(obj != NULL);
13971         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_meth);
13972         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13973                 (*env)->ExceptionDescribe(env);
13974                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg in LDKCustomMessageHandler from rust threw an exception.");
13975         }
13976         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
13977         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
13978         if (ret_constr.datalen > 0)
13979                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
13980         else
13981                 ret_constr.data = NULL;
13982         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
13983         for (size_t z = 0; z < ret_constr.datalen; z++) {
13984                 int64_t ret_conv_25 = ret_vals[z];
13985                 void* ret_conv_25_ptr = untag_ptr(ret_conv_25);
13986                 CHECK_ACCESS(ret_conv_25_ptr);
13987                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
13988                 FREE(untag_ptr(ret_conv_25));
13989                 ret_constr.data[z] = ret_conv_25_conv;
13990         }
13991         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
13992         if (get_jenv_res == JNI_EDETACHED) {
13993                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13994         }
13995         return ret_constr;
13996 }
13997 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
13998         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
13999         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14000         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
14001 }
14002 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
14003         jclass c = (*env)->GetObjectClass(env, o);
14004         CHECK(c != NULL);
14005         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
14006         atomic_init(&calls->refcnt, 1);
14007         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14008         calls->o = (*env)->NewWeakGlobalRef(env, o);
14009         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J[B)J");
14010         CHECK(calls->handle_custom_message_meth != NULL);
14011         calls->get_and_clear_pending_msg_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg", "()[J");
14012         CHECK(calls->get_and_clear_pending_msg_meth != NULL);
14013
14014         LDKCustomMessageHandler ret = {
14015                 .this_arg = (void*) calls,
14016                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
14017                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
14018                 .free = LDKCustomMessageHandler_JCalls_free,
14019                 .CustomMessageReader = LDKCustomMessageReader_init(env, clz, CustomMessageReader),
14020         };
14021         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
14022         return ret;
14023 }
14024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
14025         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
14026         *res_ptr = LDKCustomMessageHandler_init(env, clz, o, CustomMessageReader);
14027         return tag_ptr(res_ptr, true);
14028 }
14029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t arg) {
14030         LDKCustomMessageHandler *inp = (LDKCustomMessageHandler *)untag_ptr(arg);
14031         return tag_ptr(&inp->CustomMessageReader, false);
14032 }
14033 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) {
14034         void* this_arg_ptr = untag_ptr(this_arg);
14035         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14036         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
14037         void* msg_ptr = untag_ptr(msg);
14038         CHECK_ACCESS(msg_ptr);
14039         LDKType msg_conv = *(LDKType*)(msg_ptr);
14040         if (msg_conv.free == LDKType_JCalls_free) {
14041                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14042                 LDKType_JCalls_cloned(&msg_conv);
14043         }
14044         LDKPublicKey sender_node_id_ref;
14045         CHECK((*env)->GetArrayLength(env, sender_node_id) == 33);
14046         (*env)->GetByteArrayRegion(env, sender_node_id, 0, 33, sender_node_id_ref.compressed_form);
14047         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14048         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
14049         return tag_ptr(ret_conv, true);
14050 }
14051
14052 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg(JNIEnv *env, jclass clz, int64_t this_arg) {
14053         void* this_arg_ptr = untag_ptr(this_arg);
14054         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14055         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
14056         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
14057         int64_tArray ret_arr = NULL;
14058         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14059         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14060         for (size_t z = 0; z < ret_var.datalen; z++) {
14061                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
14062                 *ret_conv_25_conv = ret_var.data[z];
14063                 ret_arr_ptr[z] = tag_ptr(ret_conv_25_conv, true);
14064         }
14065         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14066         FREE(ret_var.data);
14067         return ret_arr;
14068 }
14069
14070 typedef struct LDKCustomOnionMessageHandler_JCalls {
14071         atomic_size_t refcnt;
14072         JavaVM *vm;
14073         jweak o;
14074         jmethodID handle_custom_message_meth;
14075         jmethodID read_custom_message_meth;
14076 } LDKCustomOnionMessageHandler_JCalls;
14077 static void LDKCustomOnionMessageHandler_JCalls_free(void* this_arg) {
14078         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) this_arg;
14079         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14080                 JNIEnv *env;
14081                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14082                 if (get_jenv_res == JNI_EDETACHED) {
14083                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14084                 } else {
14085                         DO_ASSERT(get_jenv_res == JNI_OK);
14086                 }
14087                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14088                 if (get_jenv_res == JNI_EDETACHED) {
14089                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14090                 }
14091                 FREE(j_calls);
14092         }
14093 }
14094 void handle_custom_message_LDKCustomOnionMessageHandler_jcall(const void* this_arg, LDKCustomOnionMessageContents msg) {
14095         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) this_arg;
14096         JNIEnv *env;
14097         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14098         if (get_jenv_res == JNI_EDETACHED) {
14099                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14100         } else {
14101                 DO_ASSERT(get_jenv_res == JNI_OK);
14102         }
14103         LDKCustomOnionMessageContents* msg_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
14104         *msg_ret = msg;
14105         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14106         CHECK(obj != NULL);
14107         (*env)->CallVoidMethod(env, obj, j_calls->handle_custom_message_meth, tag_ptr(msg_ret, true));
14108         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14109                 (*env)->ExceptionDescribe(env);
14110                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomOnionMessageHandler from rust threw an exception.");
14111         }
14112         if (get_jenv_res == JNI_EDETACHED) {
14113                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14114         }
14115 }
14116 LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ read_custom_message_LDKCustomOnionMessageHandler_jcall(const void* this_arg, uint64_t message_type, LDKu8slice buffer) {
14117         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) this_arg;
14118         JNIEnv *env;
14119         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14120         if (get_jenv_res == JNI_EDETACHED) {
14121                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14122         } else {
14123                 DO_ASSERT(get_jenv_res == JNI_OK);
14124         }
14125         int64_t message_type_conv = message_type;
14126         LDKu8slice buffer_var = buffer;
14127         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
14128         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
14129         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14130         CHECK(obj != NULL);
14131         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_custom_message_meth, message_type_conv, buffer_arr);
14132         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14133                 (*env)->ExceptionDescribe(env);
14134                 (*env)->FatalError(env, "A call to read_custom_message in LDKCustomOnionMessageHandler from rust threw an exception.");
14135         }
14136         void* ret_ptr = untag_ptr(ret);
14137         CHECK_ACCESS(ret_ptr);
14138         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ ret_conv = *(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)(ret_ptr);
14139         FREE(untag_ptr(ret));
14140         if (get_jenv_res == JNI_EDETACHED) {
14141                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14142         }
14143         return ret_conv;
14144 }
14145 static void LDKCustomOnionMessageHandler_JCalls_cloned(LDKCustomOnionMessageHandler* new_obj) {
14146         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) new_obj->this_arg;
14147         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14148 }
14149 static inline LDKCustomOnionMessageHandler LDKCustomOnionMessageHandler_init (JNIEnv *env, jclass clz, jobject o) {
14150         jclass c = (*env)->GetObjectClass(env, o);
14151         CHECK(c != NULL);
14152         LDKCustomOnionMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomOnionMessageHandler_JCalls), "LDKCustomOnionMessageHandler_JCalls");
14153         atomic_init(&calls->refcnt, 1);
14154         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14155         calls->o = (*env)->NewWeakGlobalRef(env, o);
14156         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J)V");
14157         CHECK(calls->handle_custom_message_meth != NULL);
14158         calls->read_custom_message_meth = (*env)->GetMethodID(env, c, "read_custom_message", "(J[B)J");
14159         CHECK(calls->read_custom_message_meth != NULL);
14160
14161         LDKCustomOnionMessageHandler ret = {
14162                 .this_arg = (void*) calls,
14163                 .handle_custom_message = handle_custom_message_LDKCustomOnionMessageHandler_jcall,
14164                 .read_custom_message = read_custom_message_LDKCustomOnionMessageHandler_jcall,
14165                 .free = LDKCustomOnionMessageHandler_JCalls_free,
14166         };
14167         return ret;
14168 }
14169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomOnionMessageHandler_1new(JNIEnv *env, jclass clz, jobject o) {
14170         LDKCustomOnionMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomOnionMessageHandler), "LDKCustomOnionMessageHandler");
14171         *res_ptr = LDKCustomOnionMessageHandler_init(env, clz, o);
14172         return tag_ptr(res_ptr, true);
14173 }
14174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageHandler_1handle_1custom_1message(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
14175         void* this_arg_ptr = untag_ptr(this_arg);
14176         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14177         LDKCustomOnionMessageHandler* this_arg_conv = (LDKCustomOnionMessageHandler*)this_arg_ptr;
14178         void* msg_ptr = untag_ptr(msg);
14179         CHECK_ACCESS(msg_ptr);
14180         LDKCustomOnionMessageContents msg_conv = *(LDKCustomOnionMessageContents*)(msg_ptr);
14181         if (msg_conv.free == LDKCustomOnionMessageContents_JCalls_free) {
14182                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14183                 LDKCustomOnionMessageContents_JCalls_cloned(&msg_conv);
14184         }
14185         (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv);
14186 }
14187
14188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageHandler_1read_1custom_1message(JNIEnv *env, jclass clz, int64_t this_arg, int64_t message_type, int8_tArray buffer) {
14189         void* this_arg_ptr = untag_ptr(this_arg);
14190         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14191         LDKCustomOnionMessageHandler* this_arg_conv = (LDKCustomOnionMessageHandler*)this_arg_ptr;
14192         LDKu8slice buffer_ref;
14193         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
14194         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
14195         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
14196         *ret_conv = (this_arg_conv->read_custom_message)(this_arg_conv->this_arg, message_type, buffer_ref);
14197         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
14198         return tag_ptr(ret_conv, true);
14199 }
14200
14201 typedef struct LDKSocketDescriptor_JCalls {
14202         atomic_size_t refcnt;
14203         JavaVM *vm;
14204         jweak o;
14205         jmethodID send_data_meth;
14206         jmethodID disconnect_socket_meth;
14207         jmethodID eq_meth;
14208         jmethodID hash_meth;
14209 } LDKSocketDescriptor_JCalls;
14210 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
14211         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
14212         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14213                 JNIEnv *env;
14214                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14215                 if (get_jenv_res == JNI_EDETACHED) {
14216                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14217                 } else {
14218                         DO_ASSERT(get_jenv_res == JNI_OK);
14219                 }
14220                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14221                 if (get_jenv_res == JNI_EDETACHED) {
14222                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14223                 }
14224                 FREE(j_calls);
14225         }
14226 }
14227 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
14228         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
14229         JNIEnv *env;
14230         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14231         if (get_jenv_res == JNI_EDETACHED) {
14232                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14233         } else {
14234                 DO_ASSERT(get_jenv_res == JNI_OK);
14235         }
14236         LDKu8slice data_var = data;
14237         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
14238         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
14239         jboolean resume_read_conv = resume_read;
14240         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14241         CHECK(obj != NULL);
14242         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read_conv);
14243         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14244                 (*env)->ExceptionDescribe(env);
14245                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
14246         }
14247         if (get_jenv_res == JNI_EDETACHED) {
14248                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14249         }
14250         return ret;
14251 }
14252 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
14253         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
14254         JNIEnv *env;
14255         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14256         if (get_jenv_res == JNI_EDETACHED) {
14257                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14258         } else {
14259                 DO_ASSERT(get_jenv_res == JNI_OK);
14260         }
14261         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14262         CHECK(obj != NULL);
14263         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
14264         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14265                 (*env)->ExceptionDescribe(env);
14266                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
14267         }
14268         if (get_jenv_res == JNI_EDETACHED) {
14269                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14270         }
14271 }
14272 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
14273         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
14274         JNIEnv *env;
14275         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14276         if (get_jenv_res == JNI_EDETACHED) {
14277                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14278         } else {
14279                 DO_ASSERT(get_jenv_res == JNI_OK);
14280         }
14281         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
14282         *other_arg_clone = SocketDescriptor_clone(other_arg);
14283         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14284         CHECK(obj != NULL);
14285         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, tag_ptr(other_arg_clone, true));
14286         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14287                 (*env)->ExceptionDescribe(env);
14288                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
14289         }
14290         if (get_jenv_res == JNI_EDETACHED) {
14291                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14292         }
14293         return ret;
14294 }
14295 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
14296         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
14297         JNIEnv *env;
14298         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14299         if (get_jenv_res == JNI_EDETACHED) {
14300                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14301         } else {
14302                 DO_ASSERT(get_jenv_res == JNI_OK);
14303         }
14304         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14305         CHECK(obj != NULL);
14306         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
14307         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14308                 (*env)->ExceptionDescribe(env);
14309                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
14310         }
14311         if (get_jenv_res == JNI_EDETACHED) {
14312                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14313         }
14314         return ret;
14315 }
14316 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
14317         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
14318         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14319 }
14320 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
14321         jclass c = (*env)->GetObjectClass(env, o);
14322         CHECK(c != NULL);
14323         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
14324         atomic_init(&calls->refcnt, 1);
14325         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14326         calls->o = (*env)->NewWeakGlobalRef(env, o);
14327         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
14328         CHECK(calls->send_data_meth != NULL);
14329         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
14330         CHECK(calls->disconnect_socket_meth != NULL);
14331         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
14332         CHECK(calls->eq_meth != NULL);
14333         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
14334         CHECK(calls->hash_meth != NULL);
14335
14336         LDKSocketDescriptor ret = {
14337                 .this_arg = (void*) calls,
14338                 .send_data = send_data_LDKSocketDescriptor_jcall,
14339                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
14340                 .eq = eq_LDKSocketDescriptor_jcall,
14341                 .hash = hash_LDKSocketDescriptor_jcall,
14342                 .cloned = LDKSocketDescriptor_JCalls_cloned,
14343                 .free = LDKSocketDescriptor_JCalls_free,
14344         };
14345         return ret;
14346 }
14347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
14348         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
14349         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
14350         return tag_ptr(res_ptr, true);
14351 }
14352 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) {
14353         void* this_arg_ptr = untag_ptr(this_arg);
14354         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14355         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
14356         LDKu8slice data_ref;
14357         data_ref.datalen = (*env)->GetArrayLength(env, data);
14358         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
14359         int64_t ret_conv = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
14360         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
14361         return ret_conv;
14362 }
14363
14364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
14365         void* this_arg_ptr = untag_ptr(this_arg);
14366         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14367         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
14368         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
14369 }
14370
14371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
14372         void* this_arg_ptr = untag_ptr(this_arg);
14373         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14374         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
14375         int64_t ret_conv = (this_arg_conv->hash)(this_arg_conv->this_arg);
14376         return ret_conv;
14377 }
14378
14379 static jclass LDKEffectiveCapacity_ExactLiquidity_class = NULL;
14380 static jmethodID LDKEffectiveCapacity_ExactLiquidity_meth = NULL;
14381 static jclass LDKEffectiveCapacity_MaximumHTLC_class = NULL;
14382 static jmethodID LDKEffectiveCapacity_MaximumHTLC_meth = NULL;
14383 static jclass LDKEffectiveCapacity_Total_class = NULL;
14384 static jmethodID LDKEffectiveCapacity_Total_meth = NULL;
14385 static jclass LDKEffectiveCapacity_Infinite_class = NULL;
14386 static jmethodID LDKEffectiveCapacity_Infinite_meth = NULL;
14387 static jclass LDKEffectiveCapacity_Unknown_class = NULL;
14388 static jmethodID LDKEffectiveCapacity_Unknown_meth = NULL;
14389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEffectiveCapacity_init (JNIEnv *env, jclass clz) {
14390         LDKEffectiveCapacity_ExactLiquidity_class =
14391                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$ExactLiquidity"));
14392         CHECK(LDKEffectiveCapacity_ExactLiquidity_class != NULL);
14393         LDKEffectiveCapacity_ExactLiquidity_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_ExactLiquidity_class, "<init>", "(J)V");
14394         CHECK(LDKEffectiveCapacity_ExactLiquidity_meth != NULL);
14395         LDKEffectiveCapacity_MaximumHTLC_class =
14396                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$MaximumHTLC"));
14397         CHECK(LDKEffectiveCapacity_MaximumHTLC_class != NULL);
14398         LDKEffectiveCapacity_MaximumHTLC_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_MaximumHTLC_class, "<init>", "(J)V");
14399         CHECK(LDKEffectiveCapacity_MaximumHTLC_meth != NULL);
14400         LDKEffectiveCapacity_Total_class =
14401                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Total"));
14402         CHECK(LDKEffectiveCapacity_Total_class != NULL);
14403         LDKEffectiveCapacity_Total_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Total_class, "<init>", "(JJ)V");
14404         CHECK(LDKEffectiveCapacity_Total_meth != NULL);
14405         LDKEffectiveCapacity_Infinite_class =
14406                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Infinite"));
14407         CHECK(LDKEffectiveCapacity_Infinite_class != NULL);
14408         LDKEffectiveCapacity_Infinite_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Infinite_class, "<init>", "()V");
14409         CHECK(LDKEffectiveCapacity_Infinite_meth != NULL);
14410         LDKEffectiveCapacity_Unknown_class =
14411                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Unknown"));
14412         CHECK(LDKEffectiveCapacity_Unknown_class != NULL);
14413         LDKEffectiveCapacity_Unknown_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Unknown_class, "<init>", "()V");
14414         CHECK(LDKEffectiveCapacity_Unknown_meth != NULL);
14415 }
14416 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEffectiveCapacity_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
14417         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)untag_ptr(ptr);
14418         switch(obj->tag) {
14419                 case LDKEffectiveCapacity_ExactLiquidity: {
14420                         int64_t liquidity_msat_conv = obj->exact_liquidity.liquidity_msat;
14421                         return (*env)->NewObject(env, LDKEffectiveCapacity_ExactLiquidity_class, LDKEffectiveCapacity_ExactLiquidity_meth, liquidity_msat_conv);
14422                 }
14423                 case LDKEffectiveCapacity_MaximumHTLC: {
14424                         int64_t amount_msat_conv = obj->maximum_htlc.amount_msat;
14425                         return (*env)->NewObject(env, LDKEffectiveCapacity_MaximumHTLC_class, LDKEffectiveCapacity_MaximumHTLC_meth, amount_msat_conv);
14426                 }
14427                 case LDKEffectiveCapacity_Total: {
14428                         int64_t capacity_msat_conv = obj->total.capacity_msat;
14429                         int64_t htlc_maximum_msat_ref = tag_ptr(&obj->total.htlc_maximum_msat, false);
14430                         return (*env)->NewObject(env, LDKEffectiveCapacity_Total_class, LDKEffectiveCapacity_Total_meth, capacity_msat_conv, htlc_maximum_msat_ref);
14431                 }
14432                 case LDKEffectiveCapacity_Infinite: {
14433                         return (*env)->NewObject(env, LDKEffectiveCapacity_Infinite_class, LDKEffectiveCapacity_Infinite_meth);
14434                 }
14435                 case LDKEffectiveCapacity_Unknown: {
14436                         return (*env)->NewObject(env, LDKEffectiveCapacity_Unknown_class, LDKEffectiveCapacity_Unknown_meth);
14437                 }
14438                 default: abort();
14439         }
14440 }
14441 static jclass LDKDestination_Node_class = NULL;
14442 static jmethodID LDKDestination_Node_meth = NULL;
14443 static jclass LDKDestination_BlindedRoute_class = NULL;
14444 static jmethodID LDKDestination_BlindedRoute_meth = NULL;
14445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKDestination_init (JNIEnv *env, jclass clz) {
14446         LDKDestination_Node_class =
14447                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDestination$Node"));
14448         CHECK(LDKDestination_Node_class != NULL);
14449         LDKDestination_Node_meth = (*env)->GetMethodID(env, LDKDestination_Node_class, "<init>", "([B)V");
14450         CHECK(LDKDestination_Node_meth != NULL);
14451         LDKDestination_BlindedRoute_class =
14452                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDestination$BlindedRoute"));
14453         CHECK(LDKDestination_BlindedRoute_class != NULL);
14454         LDKDestination_BlindedRoute_meth = (*env)->GetMethodID(env, LDKDestination_BlindedRoute_class, "<init>", "(J)V");
14455         CHECK(LDKDestination_BlindedRoute_meth != NULL);
14456 }
14457 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKDestination_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
14458         LDKDestination *obj = (LDKDestination*)untag_ptr(ptr);
14459         switch(obj->tag) {
14460                 case LDKDestination_Node: {
14461                         int8_tArray node_arr = (*env)->NewByteArray(env, 33);
14462                         (*env)->SetByteArrayRegion(env, node_arr, 0, 33, obj->node.compressed_form);
14463                         return (*env)->NewObject(env, LDKDestination_Node_class, LDKDestination_Node_meth, node_arr);
14464                 }
14465                 case LDKDestination_BlindedRoute: {
14466                         LDKBlindedRoute blinded_route_var = obj->blinded_route;
14467                         int64_t blinded_route_ref = 0;
14468                         CHECK_INNER_FIELD_ACCESS_OR_NULL(blinded_route_var);
14469                         blinded_route_ref = tag_ptr(blinded_route_var.inner, false);
14470                         return (*env)->NewObject(env, LDKDestination_BlindedRoute_class, LDKDestination_BlindedRoute_meth, blinded_route_ref);
14471                 }
14472                 default: abort();
14473         }
14474 }
14475 static jclass LDKGossipSync_P2P_class = NULL;
14476 static jmethodID LDKGossipSync_P2P_meth = NULL;
14477 static jclass LDKGossipSync_Rapid_class = NULL;
14478 static jmethodID LDKGossipSync_Rapid_meth = NULL;
14479 static jclass LDKGossipSync_None_class = NULL;
14480 static jmethodID LDKGossipSync_None_meth = NULL;
14481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKGossipSync_init (JNIEnv *env, jclass clz) {
14482         LDKGossipSync_P2P_class =
14483                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$P2P"));
14484         CHECK(LDKGossipSync_P2P_class != NULL);
14485         LDKGossipSync_P2P_meth = (*env)->GetMethodID(env, LDKGossipSync_P2P_class, "<init>", "(J)V");
14486         CHECK(LDKGossipSync_P2P_meth != NULL);
14487         LDKGossipSync_Rapid_class =
14488                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$Rapid"));
14489         CHECK(LDKGossipSync_Rapid_class != NULL);
14490         LDKGossipSync_Rapid_meth = (*env)->GetMethodID(env, LDKGossipSync_Rapid_class, "<init>", "(J)V");
14491         CHECK(LDKGossipSync_Rapid_meth != NULL);
14492         LDKGossipSync_None_class =
14493                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$None"));
14494         CHECK(LDKGossipSync_None_class != NULL);
14495         LDKGossipSync_None_meth = (*env)->GetMethodID(env, LDKGossipSync_None_class, "<init>", "()V");
14496         CHECK(LDKGossipSync_None_meth != NULL);
14497 }
14498 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKGossipSync_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
14499         LDKGossipSync *obj = (LDKGossipSync*)untag_ptr(ptr);
14500         switch(obj->tag) {
14501                 case LDKGossipSync_P2P: {
14502                         LDKP2PGossipSync p2p_var = obj->p2p;
14503                         int64_t p2p_ref = 0;
14504                         CHECK_INNER_FIELD_ACCESS_OR_NULL(p2p_var);
14505                         p2p_ref = tag_ptr(p2p_var.inner, false);
14506                         return (*env)->NewObject(env, LDKGossipSync_P2P_class, LDKGossipSync_P2P_meth, p2p_ref);
14507                 }
14508                 case LDKGossipSync_Rapid: {
14509                         LDKRapidGossipSync rapid_var = obj->rapid;
14510                         int64_t rapid_ref = 0;
14511                         CHECK_INNER_FIELD_ACCESS_OR_NULL(rapid_var);
14512                         rapid_ref = tag_ptr(rapid_var.inner, false);
14513                         return (*env)->NewObject(env, LDKGossipSync_Rapid_class, LDKGossipSync_Rapid_meth, rapid_ref);
14514                 }
14515                 case LDKGossipSync_None: {
14516                         return (*env)->NewObject(env, LDKGossipSync_None_class, LDKGossipSync_None_meth);
14517                 }
14518                 default: abort();
14519         }
14520 }
14521 static jclass LDKFallback_SegWitProgram_class = NULL;
14522 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
14523 static jclass LDKFallback_PubKeyHash_class = NULL;
14524 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
14525 static jclass LDKFallback_ScriptHash_class = NULL;
14526 static jmethodID LDKFallback_ScriptHash_meth = NULL;
14527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
14528         LDKFallback_SegWitProgram_class =
14529                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$SegWitProgram"));
14530         CHECK(LDKFallback_SegWitProgram_class != NULL);
14531         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
14532         CHECK(LDKFallback_SegWitProgram_meth != NULL);
14533         LDKFallback_PubKeyHash_class =
14534                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$PubKeyHash"));
14535         CHECK(LDKFallback_PubKeyHash_class != NULL);
14536         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
14537         CHECK(LDKFallback_PubKeyHash_meth != NULL);
14538         LDKFallback_ScriptHash_class =
14539                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$ScriptHash"));
14540         CHECK(LDKFallback_ScriptHash_class != NULL);
14541         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
14542         CHECK(LDKFallback_ScriptHash_meth != NULL);
14543 }
14544 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
14545         LDKFallback *obj = (LDKFallback*)untag_ptr(ptr);
14546         switch(obj->tag) {
14547                 case LDKFallback_SegWitProgram: {
14548                         uint8_t version_val = obj->seg_wit_program.version._0;
14549                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
14550                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
14551                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
14552                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
14553                 }
14554                 case LDKFallback_PubKeyHash: {
14555                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
14556                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
14557                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
14558                 }
14559                 case LDKFallback_ScriptHash: {
14560                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
14561                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
14562                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
14563                 }
14564                 default: abort();
14565         }
14566 }
14567 typedef struct LDKPayer_JCalls {
14568         atomic_size_t refcnt;
14569         JavaVM *vm;
14570         jweak o;
14571         jmethodID node_id_meth;
14572         jmethodID first_hops_meth;
14573         jmethodID send_payment_meth;
14574         jmethodID send_spontaneous_payment_meth;
14575         jmethodID retry_payment_meth;
14576         jmethodID abandon_payment_meth;
14577 } LDKPayer_JCalls;
14578 static void LDKPayer_JCalls_free(void* this_arg) {
14579         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14580         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14581                 JNIEnv *env;
14582                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14583                 if (get_jenv_res == JNI_EDETACHED) {
14584                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14585                 } else {
14586                         DO_ASSERT(get_jenv_res == JNI_OK);
14587                 }
14588                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14589                 if (get_jenv_res == JNI_EDETACHED) {
14590                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14591                 }
14592                 FREE(j_calls);
14593         }
14594 }
14595 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
14596         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14597         JNIEnv *env;
14598         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14599         if (get_jenv_res == JNI_EDETACHED) {
14600                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14601         } else {
14602                 DO_ASSERT(get_jenv_res == JNI_OK);
14603         }
14604         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14605         CHECK(obj != NULL);
14606         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->node_id_meth);
14607         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14608                 (*env)->ExceptionDescribe(env);
14609                 (*env)->FatalError(env, "A call to node_id in LDKPayer from rust threw an exception.");
14610         }
14611         LDKPublicKey ret_ref;
14612         CHECK((*env)->GetArrayLength(env, ret) == 33);
14613         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
14614         if (get_jenv_res == JNI_EDETACHED) {
14615                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14616         }
14617         return ret_ref;
14618 }
14619 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
14620         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14621         JNIEnv *env;
14622         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14623         if (get_jenv_res == JNI_EDETACHED) {
14624                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14625         } else {
14626                 DO_ASSERT(get_jenv_res == JNI_OK);
14627         }
14628         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14629         CHECK(obj != NULL);
14630         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->first_hops_meth);
14631         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14632                 (*env)->ExceptionDescribe(env);
14633                 (*env)->FatalError(env, "A call to first_hops in LDKPayer from rust threw an exception.");
14634         }
14635         LDKCVec_ChannelDetailsZ ret_constr;
14636         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
14637         if (ret_constr.datalen > 0)
14638                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
14639         else
14640                 ret_constr.data = NULL;
14641         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
14642         for (size_t q = 0; q < ret_constr.datalen; q++) {
14643                 int64_t ret_conv_16 = ret_vals[q];
14644                 LDKChannelDetails ret_conv_16_conv;
14645                 ret_conv_16_conv.inner = untag_ptr(ret_conv_16);
14646                 ret_conv_16_conv.is_owned = ptr_is_owned(ret_conv_16);
14647                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
14648                 ret_constr.data[q] = ret_conv_16_conv;
14649         }
14650         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
14651         if (get_jenv_res == JNI_EDETACHED) {
14652                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14653         }
14654         return ret_constr;
14655 }
14656 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
14657         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14658         JNIEnv *env;
14659         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14660         if (get_jenv_res == JNI_EDETACHED) {
14661                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14662         } else {
14663                 DO_ASSERT(get_jenv_res == JNI_OK);
14664         }
14665         LDKRoute route_var = *route;
14666         int64_t route_ref = 0;
14667         route_var = Route_clone(&route_var);
14668         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
14669         route_ref = tag_ptr(route_var.inner, route_var.is_owned);
14670         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
14671         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, payment_hash.data);
14672         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
14673         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, payment_secret.data);
14674         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14675         CHECK(obj != NULL);
14676         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_payment_meth, route_ref, payment_hash_arr, payment_secret_arr);
14677         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14678                 (*env)->ExceptionDescribe(env);
14679                 (*env)->FatalError(env, "A call to send_payment in LDKPayer from rust threw an exception.");
14680         }
14681         void* ret_ptr = untag_ptr(ret);
14682         CHECK_ACCESS(ret_ptr);
14683         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
14684         FREE(untag_ptr(ret));
14685         if (get_jenv_res == JNI_EDETACHED) {
14686                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14687         }
14688         return ret_conv;
14689 }
14690 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
14691         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14692         JNIEnv *env;
14693         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14694         if (get_jenv_res == JNI_EDETACHED) {
14695                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14696         } else {
14697                 DO_ASSERT(get_jenv_res == JNI_OK);
14698         }
14699         LDKRoute route_var = *route;
14700         int64_t route_ref = 0;
14701         route_var = Route_clone(&route_var);
14702         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
14703         route_ref = tag_ptr(route_var.inner, route_var.is_owned);
14704         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
14705         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, payment_preimage.data);
14706         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14707         CHECK(obj != NULL);
14708         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_spontaneous_payment_meth, route_ref, payment_preimage_arr);
14709         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14710                 (*env)->ExceptionDescribe(env);
14711                 (*env)->FatalError(env, "A call to send_spontaneous_payment in LDKPayer from rust threw an exception.");
14712         }
14713         void* ret_ptr = untag_ptr(ret);
14714         CHECK_ACCESS(ret_ptr);
14715         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
14716         FREE(untag_ptr(ret));
14717         if (get_jenv_res == JNI_EDETACHED) {
14718                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14719         }
14720         return ret_conv;
14721 }
14722 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
14723         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14724         JNIEnv *env;
14725         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14726         if (get_jenv_res == JNI_EDETACHED) {
14727                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14728         } else {
14729                 DO_ASSERT(get_jenv_res == JNI_OK);
14730         }
14731         LDKRoute route_var = *route;
14732         int64_t route_ref = 0;
14733         route_var = Route_clone(&route_var);
14734         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
14735         route_ref = tag_ptr(route_var.inner, route_var.is_owned);
14736         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
14737         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
14738         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14739         CHECK(obj != NULL);
14740         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->retry_payment_meth, route_ref, payment_id_arr);
14741         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14742                 (*env)->ExceptionDescribe(env);
14743                 (*env)->FatalError(env, "A call to retry_payment in LDKPayer from rust threw an exception.");
14744         }
14745         void* ret_ptr = untag_ptr(ret);
14746         CHECK_ACCESS(ret_ptr);
14747         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
14748         FREE(untag_ptr(ret));
14749         if (get_jenv_res == JNI_EDETACHED) {
14750                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14751         }
14752         return ret_conv;
14753 }
14754 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
14755         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14756         JNIEnv *env;
14757         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14758         if (get_jenv_res == JNI_EDETACHED) {
14759                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14760         } else {
14761                 DO_ASSERT(get_jenv_res == JNI_OK);
14762         }
14763         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
14764         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
14765         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14766         CHECK(obj != NULL);
14767         (*env)->CallVoidMethod(env, obj, j_calls->abandon_payment_meth, payment_id_arr);
14768         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14769                 (*env)->ExceptionDescribe(env);
14770                 (*env)->FatalError(env, "A call to abandon_payment in LDKPayer from rust threw an exception.");
14771         }
14772         if (get_jenv_res == JNI_EDETACHED) {
14773                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14774         }
14775 }
14776 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
14777         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
14778         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14779 }
14780 static inline LDKPayer LDKPayer_init (JNIEnv *env, jclass clz, jobject o) {
14781         jclass c = (*env)->GetObjectClass(env, o);
14782         CHECK(c != NULL);
14783         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
14784         atomic_init(&calls->refcnt, 1);
14785         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14786         calls->o = (*env)->NewWeakGlobalRef(env, o);
14787         calls->node_id_meth = (*env)->GetMethodID(env, c, "node_id", "()[B");
14788         CHECK(calls->node_id_meth != NULL);
14789         calls->first_hops_meth = (*env)->GetMethodID(env, c, "first_hops", "()[J");
14790         CHECK(calls->first_hops_meth != NULL);
14791         calls->send_payment_meth = (*env)->GetMethodID(env, c, "send_payment", "(J[B[B)J");
14792         CHECK(calls->send_payment_meth != NULL);
14793         calls->send_spontaneous_payment_meth = (*env)->GetMethodID(env, c, "send_spontaneous_payment", "(J[B)J");
14794         CHECK(calls->send_spontaneous_payment_meth != NULL);
14795         calls->retry_payment_meth = (*env)->GetMethodID(env, c, "retry_payment", "(J[B)J");
14796         CHECK(calls->retry_payment_meth != NULL);
14797         calls->abandon_payment_meth = (*env)->GetMethodID(env, c, "abandon_payment", "([B)V");
14798         CHECK(calls->abandon_payment_meth != NULL);
14799
14800         LDKPayer ret = {
14801                 .this_arg = (void*) calls,
14802                 .node_id = node_id_LDKPayer_jcall,
14803                 .first_hops = first_hops_LDKPayer_jcall,
14804                 .send_payment = send_payment_LDKPayer_jcall,
14805                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
14806                 .retry_payment = retry_payment_LDKPayer_jcall,
14807                 .abandon_payment = abandon_payment_LDKPayer_jcall,
14808                 .free = LDKPayer_JCalls_free,
14809         };
14810         return ret;
14811 }
14812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPayer_1new(JNIEnv *env, jclass clz, jobject o) {
14813         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
14814         *res_ptr = LDKPayer_init(env, clz, o);
14815         return tag_ptr(res_ptr, true);
14816 }
14817 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
14818         void* this_arg_ptr = untag_ptr(this_arg);
14819         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14820         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14821         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14822         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form);
14823         return ret_arr;
14824 }
14825
14826 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1first_1hops(JNIEnv *env, jclass clz, int64_t this_arg) {
14827         void* this_arg_ptr = untag_ptr(this_arg);
14828         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14829         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14830         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
14831         int64_tArray ret_arr = NULL;
14832         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14833         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14834         for (size_t q = 0; q < ret_var.datalen; q++) {
14835                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
14836                 int64_t ret_conv_16_ref = 0;
14837                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
14838                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
14839                 ret_arr_ptr[q] = ret_conv_16_ref;
14840         }
14841         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14842         FREE(ret_var.data);
14843         return ret_arr;
14844 }
14845
14846 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) {
14847         void* this_arg_ptr = untag_ptr(this_arg);
14848         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14849         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14850         LDKRoute route_conv;
14851         route_conv.inner = untag_ptr(route);
14852         route_conv.is_owned = ptr_is_owned(route);
14853         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
14854         route_conv.is_owned = false;
14855         LDKThirtyTwoBytes payment_hash_ref;
14856         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
14857         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
14858         LDKThirtyTwoBytes payment_secret_ref;
14859         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
14860         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
14861         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14862         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
14863         return tag_ptr(ret_conv, true);
14864 }
14865
14866 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) {
14867         void* this_arg_ptr = untag_ptr(this_arg);
14868         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14869         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14870         LDKRoute route_conv;
14871         route_conv.inner = untag_ptr(route);
14872         route_conv.is_owned = ptr_is_owned(route);
14873         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
14874         route_conv.is_owned = false;
14875         LDKThirtyTwoBytes payment_preimage_ref;
14876         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
14877         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
14878         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14879         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
14880         return tag_ptr(ret_conv, true);
14881 }
14882
14883 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) {
14884         void* this_arg_ptr = untag_ptr(this_arg);
14885         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14886         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14887         LDKRoute route_conv;
14888         route_conv.inner = untag_ptr(route);
14889         route_conv.is_owned = ptr_is_owned(route);
14890         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
14891         route_conv.is_owned = false;
14892         LDKThirtyTwoBytes payment_id_ref;
14893         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
14894         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
14895         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14896         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
14897         return tag_ptr(ret_conv, true);
14898 }
14899
14900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
14901         void* this_arg_ptr = untag_ptr(this_arg);
14902         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14903         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14904         LDKThirtyTwoBytes payment_id_ref;
14905         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
14906         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
14907         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
14908 }
14909
14910 typedef struct LDKRouter_JCalls {
14911         atomic_size_t refcnt;
14912         JavaVM *vm;
14913         jweak o;
14914         jmethodID find_route_meth;
14915         jmethodID notify_payment_path_failed_meth;
14916         jmethodID notify_payment_path_successful_meth;
14917         jmethodID notify_payment_probe_successful_meth;
14918         jmethodID notify_payment_probe_failed_meth;
14919 } LDKRouter_JCalls;
14920 static void LDKRouter_JCalls_free(void* this_arg) {
14921         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14922         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14923                 JNIEnv *env;
14924                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14925                 if (get_jenv_res == JNI_EDETACHED) {
14926                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14927                 } else {
14928                         DO_ASSERT(get_jenv_res == JNI_OK);
14929                 }
14930                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14931                 if (get_jenv_res == JNI_EDETACHED) {
14932                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14933                 }
14934                 FREE(j_calls);
14935         }
14936 }
14937 LDKCResult_RouteLightningErrorZ find_route_LDKRouter_jcall(const void* this_arg, LDKPublicKey payer, const LDKRouteParameters * route_params, const uint8_t (* payment_hash)[32], LDKCVec_ChannelDetailsZ * first_hops, LDKInFlightHtlcs inflight_htlcs) {
14938         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14939         JNIEnv *env;
14940         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14941         if (get_jenv_res == JNI_EDETACHED) {
14942                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14943         } else {
14944                 DO_ASSERT(get_jenv_res == JNI_OK);
14945         }
14946         int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
14947         (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
14948         LDKRouteParameters route_params_var = *route_params;
14949         int64_t route_params_ref = 0;
14950         route_params_var = RouteParameters_clone(&route_params_var);
14951         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
14952         route_params_ref = tag_ptr(route_params_var.inner, route_params_var.is_owned);
14953         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
14954         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, *payment_hash);
14955         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
14956         int64_tArray first_hops_arr = NULL;
14957         if (first_hops != NULL) {
14958                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
14959                 first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
14960                 int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
14961                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
14962                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
14963                         int64_t first_hops_conv_16_ref = 0;
14964                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
14965                         first_hops_conv_16_ref = tag_ptr(first_hops_conv_16_var.inner, first_hops_conv_16_var.is_owned);
14966                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
14967                 }
14968                 (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
14969         }
14970         LDKInFlightHtlcs inflight_htlcs_var = inflight_htlcs;
14971         int64_t inflight_htlcs_ref = 0;
14972         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_var);
14973         inflight_htlcs_ref = tag_ptr(inflight_htlcs_var.inner, inflight_htlcs_var.is_owned);
14974         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14975         CHECK(obj != NULL);
14976         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->find_route_meth, payer_arr, route_params_ref, payment_hash_arr, first_hops_arr, inflight_htlcs_ref);
14977         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14978                 (*env)->ExceptionDescribe(env);
14979                 (*env)->FatalError(env, "A call to find_route in LDKRouter from rust threw an exception.");
14980         }
14981         void* ret_ptr = untag_ptr(ret);
14982         CHECK_ACCESS(ret_ptr);
14983         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
14984         FREE(untag_ptr(ret));
14985         if (get_jenv_res == JNI_EDETACHED) {
14986                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14987         }
14988         return ret_conv;
14989 }
14990 void notify_payment_path_failed_LDKRouter_jcall(const void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
14991         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14992         JNIEnv *env;
14993         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14994         if (get_jenv_res == JNI_EDETACHED) {
14995                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14996         } else {
14997                 DO_ASSERT(get_jenv_res == JNI_OK);
14998         }
14999         LDKCVec_RouteHopZ path_var = path;
15000         int64_tArray path_arr = NULL;
15001         path_arr = (*env)->NewLongArray(env, path_var.datalen);
15002         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
15003         for (size_t k = 0; k < path_var.datalen; k++) {
15004                 LDKRouteHop path_conv_10_var = path_var.data[k];
15005                 int64_t path_conv_10_ref = 0;
15006                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
15007                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
15008                 path_arr_ptr[k] = path_conv_10_ref;
15009         }
15010         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
15011         FREE(path_var.data);
15012         int64_t short_channel_id_conv = short_channel_id;
15013         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15014         CHECK(obj != NULL);
15015         (*env)->CallVoidMethod(env, obj, j_calls->notify_payment_path_failed_meth, path_arr, short_channel_id_conv);
15016         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15017                 (*env)->ExceptionDescribe(env);
15018                 (*env)->FatalError(env, "A call to notify_payment_path_failed in LDKRouter from rust threw an exception.");
15019         }
15020         if (get_jenv_res == JNI_EDETACHED) {
15021                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15022         }
15023 }
15024 void notify_payment_path_successful_LDKRouter_jcall(const void* this_arg, LDKCVec_RouteHopZ path) {
15025         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
15026         JNIEnv *env;
15027         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15028         if (get_jenv_res == JNI_EDETACHED) {
15029                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15030         } else {
15031                 DO_ASSERT(get_jenv_res == JNI_OK);
15032         }
15033         LDKCVec_RouteHopZ path_var = path;
15034         int64_tArray path_arr = NULL;
15035         path_arr = (*env)->NewLongArray(env, path_var.datalen);
15036         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
15037         for (size_t k = 0; k < path_var.datalen; k++) {
15038                 LDKRouteHop path_conv_10_var = path_var.data[k];
15039                 int64_t path_conv_10_ref = 0;
15040                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
15041                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
15042                 path_arr_ptr[k] = path_conv_10_ref;
15043         }
15044         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
15045         FREE(path_var.data);
15046         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15047         CHECK(obj != NULL);
15048         (*env)->CallVoidMethod(env, obj, j_calls->notify_payment_path_successful_meth, path_arr);
15049         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15050                 (*env)->ExceptionDescribe(env);
15051                 (*env)->FatalError(env, "A call to notify_payment_path_successful in LDKRouter from rust threw an exception.");
15052         }
15053         if (get_jenv_res == JNI_EDETACHED) {
15054                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15055         }
15056 }
15057 void notify_payment_probe_successful_LDKRouter_jcall(const void* this_arg, LDKCVec_RouteHopZ path) {
15058         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
15059         JNIEnv *env;
15060         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15061         if (get_jenv_res == JNI_EDETACHED) {
15062                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15063         } else {
15064                 DO_ASSERT(get_jenv_res == JNI_OK);
15065         }
15066         LDKCVec_RouteHopZ path_var = path;
15067         int64_tArray path_arr = NULL;
15068         path_arr = (*env)->NewLongArray(env, path_var.datalen);
15069         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
15070         for (size_t k = 0; k < path_var.datalen; k++) {
15071                 LDKRouteHop path_conv_10_var = path_var.data[k];
15072                 int64_t path_conv_10_ref = 0;
15073                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
15074                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
15075                 path_arr_ptr[k] = path_conv_10_ref;
15076         }
15077         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
15078         FREE(path_var.data);
15079         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15080         CHECK(obj != NULL);
15081         (*env)->CallVoidMethod(env, obj, j_calls->notify_payment_probe_successful_meth, path_arr);
15082         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15083                 (*env)->ExceptionDescribe(env);
15084                 (*env)->FatalError(env, "A call to notify_payment_probe_successful in LDKRouter from rust threw an exception.");
15085         }
15086         if (get_jenv_res == JNI_EDETACHED) {
15087                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15088         }
15089 }
15090 void notify_payment_probe_failed_LDKRouter_jcall(const void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
15091         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
15092         JNIEnv *env;
15093         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15094         if (get_jenv_res == JNI_EDETACHED) {
15095                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15096         } else {
15097                 DO_ASSERT(get_jenv_res == JNI_OK);
15098         }
15099         LDKCVec_RouteHopZ path_var = path;
15100         int64_tArray path_arr = NULL;
15101         path_arr = (*env)->NewLongArray(env, path_var.datalen);
15102         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
15103         for (size_t k = 0; k < path_var.datalen; k++) {
15104                 LDKRouteHop path_conv_10_var = path_var.data[k];
15105                 int64_t path_conv_10_ref = 0;
15106                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
15107                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
15108                 path_arr_ptr[k] = path_conv_10_ref;
15109         }
15110         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
15111         FREE(path_var.data);
15112         int64_t short_channel_id_conv = short_channel_id;
15113         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15114         CHECK(obj != NULL);
15115         (*env)->CallVoidMethod(env, obj, j_calls->notify_payment_probe_failed_meth, path_arr, short_channel_id_conv);
15116         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15117                 (*env)->ExceptionDescribe(env);
15118                 (*env)->FatalError(env, "A call to notify_payment_probe_failed in LDKRouter from rust threw an exception.");
15119         }
15120         if (get_jenv_res == JNI_EDETACHED) {
15121                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15122         }
15123 }
15124 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
15125         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
15126         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
15127 }
15128 static inline LDKRouter LDKRouter_init (JNIEnv *env, jclass clz, jobject o) {
15129         jclass c = (*env)->GetObjectClass(env, o);
15130         CHECK(c != NULL);
15131         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
15132         atomic_init(&calls->refcnt, 1);
15133         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
15134         calls->o = (*env)->NewWeakGlobalRef(env, o);
15135         calls->find_route_meth = (*env)->GetMethodID(env, c, "find_route", "([BJ[B[JJ)J");
15136         CHECK(calls->find_route_meth != NULL);
15137         calls->notify_payment_path_failed_meth = (*env)->GetMethodID(env, c, "notify_payment_path_failed", "([JJ)V");
15138         CHECK(calls->notify_payment_path_failed_meth != NULL);
15139         calls->notify_payment_path_successful_meth = (*env)->GetMethodID(env, c, "notify_payment_path_successful", "([J)V");
15140         CHECK(calls->notify_payment_path_successful_meth != NULL);
15141         calls->notify_payment_probe_successful_meth = (*env)->GetMethodID(env, c, "notify_payment_probe_successful", "([J)V");
15142         CHECK(calls->notify_payment_probe_successful_meth != NULL);
15143         calls->notify_payment_probe_failed_meth = (*env)->GetMethodID(env, c, "notify_payment_probe_failed", "([JJ)V");
15144         CHECK(calls->notify_payment_probe_failed_meth != NULL);
15145
15146         LDKRouter ret = {
15147                 .this_arg = (void*) calls,
15148                 .find_route = find_route_LDKRouter_jcall,
15149                 .notify_payment_path_failed = notify_payment_path_failed_LDKRouter_jcall,
15150                 .notify_payment_path_successful = notify_payment_path_successful_LDKRouter_jcall,
15151                 .notify_payment_probe_successful = notify_payment_probe_successful_LDKRouter_jcall,
15152                 .notify_payment_probe_failed = notify_payment_probe_failed_LDKRouter_jcall,
15153                 .free = LDKRouter_JCalls_free,
15154         };
15155         return ret;
15156 }
15157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRouter_1new(JNIEnv *env, jclass clz, jobject o) {
15158         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
15159         *res_ptr = LDKRouter_init(env, clz, o);
15160         return tag_ptr(res_ptr, true);
15161 }
15162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Router_1find_1route(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payer, int64_t route_params, int8_tArray payment_hash, int64_tArray first_hops, int64_t inflight_htlcs) {
15163         void* this_arg_ptr = untag_ptr(this_arg);
15164         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15165         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
15166         LDKPublicKey payer_ref;
15167         CHECK((*env)->GetArrayLength(env, payer) == 33);
15168         (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
15169         LDKRouteParameters route_params_conv;
15170         route_params_conv.inner = untag_ptr(route_params);
15171         route_params_conv.is_owned = ptr_is_owned(route_params);
15172         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
15173         route_params_conv.is_owned = false;
15174         unsigned char payment_hash_arr[32];
15175         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
15176         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
15177         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
15178         LDKCVec_ChannelDetailsZ first_hops_constr;
15179         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
15180         if (first_hops != NULL) {
15181                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
15182                 if (first_hops_constr.datalen > 0)
15183                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
15184                 else
15185                         first_hops_constr.data = NULL;
15186                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
15187                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
15188                         int64_t first_hops_conv_16 = first_hops_vals[q];
15189                         LDKChannelDetails first_hops_conv_16_conv;
15190                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
15191                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
15192                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
15193                         first_hops_conv_16_conv.is_owned = false;
15194                         first_hops_constr.data[q] = first_hops_conv_16_conv;
15195                 }
15196                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
15197                 first_hops_ptr = &first_hops_constr;
15198         }
15199         LDKInFlightHtlcs inflight_htlcs_conv;
15200         inflight_htlcs_conv.inner = untag_ptr(inflight_htlcs);
15201         inflight_htlcs_conv.is_owned = ptr_is_owned(inflight_htlcs);
15202         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_conv);
15203         // WARNING: we need a move here but no clone is available for LDKInFlightHtlcs
15204         
15205         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
15206         *ret_conv = (this_arg_conv->find_route)(this_arg_conv->this_arg, payer_ref, &route_params_conv, payment_hash_ref, first_hops_ptr, inflight_htlcs_conv);
15207         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
15208         return tag_ptr(ret_conv, true);
15209 }
15210
15211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1notify_1payment_1path_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path, int64_t short_channel_id) {
15212         void* this_arg_ptr = untag_ptr(this_arg);
15213         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15214         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
15215         LDKCVec_RouteHopZ path_constr;
15216         path_constr.datalen = (*env)->GetArrayLength(env, path);
15217         if (path_constr.datalen > 0)
15218                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
15219         else
15220                 path_constr.data = NULL;
15221         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
15222         for (size_t k = 0; k < path_constr.datalen; k++) {
15223                 int64_t path_conv_10 = path_vals[k];
15224                 LDKRouteHop path_conv_10_conv;
15225                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
15226                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
15227                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
15228                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
15229                 path_constr.data[k] = path_conv_10_conv;
15230         }
15231         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
15232         (this_arg_conv->notify_payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
15233 }
15234
15235 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1notify_1payment_1path_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
15236         void* this_arg_ptr = untag_ptr(this_arg);
15237         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15238         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
15239         LDKCVec_RouteHopZ path_constr;
15240         path_constr.datalen = (*env)->GetArrayLength(env, path);
15241         if (path_constr.datalen > 0)
15242                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
15243         else
15244                 path_constr.data = NULL;
15245         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
15246         for (size_t k = 0; k < path_constr.datalen; k++) {
15247                 int64_t path_conv_10 = path_vals[k];
15248                 LDKRouteHop path_conv_10_conv;
15249                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
15250                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
15251                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
15252                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
15253                 path_constr.data[k] = path_conv_10_conv;
15254         }
15255         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
15256         (this_arg_conv->notify_payment_path_successful)(this_arg_conv->this_arg, path_constr);
15257 }
15258
15259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1notify_1payment_1probe_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
15260         void* this_arg_ptr = untag_ptr(this_arg);
15261         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15262         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
15263         LDKCVec_RouteHopZ path_constr;
15264         path_constr.datalen = (*env)->GetArrayLength(env, path);
15265         if (path_constr.datalen > 0)
15266                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
15267         else
15268                 path_constr.data = NULL;
15269         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
15270         for (size_t k = 0; k < path_constr.datalen; k++) {
15271                 int64_t path_conv_10 = path_vals[k];
15272                 LDKRouteHop path_conv_10_conv;
15273                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
15274                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
15275                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
15276                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
15277                 path_constr.data[k] = path_conv_10_conv;
15278         }
15279         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
15280         (this_arg_conv->notify_payment_probe_successful)(this_arg_conv->this_arg, path_constr);
15281 }
15282
15283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1notify_1payment_1probe_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path, int64_t short_channel_id) {
15284         void* this_arg_ptr = untag_ptr(this_arg);
15285         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15286         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
15287         LDKCVec_RouteHopZ path_constr;
15288         path_constr.datalen = (*env)->GetArrayLength(env, path);
15289         if (path_constr.datalen > 0)
15290                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
15291         else
15292                 path_constr.data = NULL;
15293         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
15294         for (size_t k = 0; k < path_constr.datalen; k++) {
15295                 int64_t path_conv_10 = path_vals[k];
15296                 LDKRouteHop path_conv_10_conv;
15297                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
15298                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
15299                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
15300                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
15301                 path_constr.data[k] = path_conv_10_conv;
15302         }
15303         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
15304         (this_arg_conv->notify_payment_probe_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
15305 }
15306
15307 static jclass LDKRetry_Attempts_class = NULL;
15308 static jmethodID LDKRetry_Attempts_meth = NULL;
15309 static jclass LDKRetry_Timeout_class = NULL;
15310 static jmethodID LDKRetry_Timeout_meth = NULL;
15311 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKRetry_init (JNIEnv *env, jclass clz) {
15312         LDKRetry_Attempts_class =
15313                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRetry$Attempts"));
15314         CHECK(LDKRetry_Attempts_class != NULL);
15315         LDKRetry_Attempts_meth = (*env)->GetMethodID(env, LDKRetry_Attempts_class, "<init>", "(J)V");
15316         CHECK(LDKRetry_Attempts_meth != NULL);
15317         LDKRetry_Timeout_class =
15318                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRetry$Timeout"));
15319         CHECK(LDKRetry_Timeout_class != NULL);
15320         LDKRetry_Timeout_meth = (*env)->GetMethodID(env, LDKRetry_Timeout_class, "<init>", "(J)V");
15321         CHECK(LDKRetry_Timeout_meth != NULL);
15322 }
15323 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKRetry_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
15324         LDKRetry *obj = (LDKRetry*)untag_ptr(ptr);
15325         switch(obj->tag) {
15326                 case LDKRetry_Attempts: {
15327                         int64_t attempts_conv = obj->attempts;
15328                         return (*env)->NewObject(env, LDKRetry_Attempts_class, LDKRetry_Attempts_meth, attempts_conv);
15329                 }
15330                 case LDKRetry_Timeout: {
15331                         int64_t timeout_conv = obj->timeout;
15332                         return (*env)->NewObject(env, LDKRetry_Timeout_class, LDKRetry_Timeout_meth, timeout_conv);
15333                 }
15334                 default: abort();
15335         }
15336 }
15337 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
15338         LDKStr ret_str = _ldk_get_compiled_version();
15339         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
15340         Str_free(ret_str);
15341         return ret_conv;
15342 }
15343
15344 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
15345         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
15346         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
15347         Str_free(ret_str);
15348         return ret_conv;
15349 }
15350
15351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigEndianScalar_1new(JNIEnv *env, jclass clz, int8_tArray big_endian_bytes) {
15352         LDKThirtyTwoBytes big_endian_bytes_ref;
15353         CHECK((*env)->GetArrayLength(env, big_endian_bytes) == 32);
15354         (*env)->GetByteArrayRegion(env, big_endian_bytes, 0, 32, big_endian_bytes_ref.data);
15355         LDKBigEndianScalar* ret_ref = MALLOC(sizeof(LDKBigEndianScalar), "LDKBigEndianScalar");
15356         *ret_ref = BigEndianScalar_new(big_endian_bytes_ref);
15357         return tag_ptr(ret_ref, true);
15358 }
15359
15360 static inline uint64_t Bech32Error_clone_ptr(LDKBech32Error *NONNULL_PTR arg) {
15361         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
15362         *ret_copy = Bech32Error_clone(arg);
15363         int64_t ret_ref = tag_ptr(ret_copy, true);
15364         return ret_ref;
15365 }
15366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15367         LDKBech32Error* arg_conv = (LDKBech32Error*)untag_ptr(arg);
15368         int64_t ret_conv = Bech32Error_clone_ptr(arg_conv);
15369         return ret_conv;
15370 }
15371
15372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15373         LDKBech32Error* orig_conv = (LDKBech32Error*)untag_ptr(orig);
15374         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
15375         *ret_copy = Bech32Error_clone(orig_conv);
15376         int64_t ret_ref = tag_ptr(ret_copy, true);
15377         return ret_ref;
15378 }
15379
15380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bech32Error_1free(JNIEnv *env, jclass clz, int64_t o) {
15381         if (!ptr_is_owned(o)) return;
15382         void* o_ptr = untag_ptr(o);
15383         CHECK_ACCESS(o_ptr);
15384         LDKBech32Error o_conv = *(LDKBech32Error*)(o_ptr);
15385         FREE(untag_ptr(o));
15386         Bech32Error_free(o_conv);
15387 }
15388
15389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
15390         LDKTransaction _res_ref;
15391         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
15392         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
15393         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
15394         _res_ref.data_is_owned = true;
15395         Transaction_free(_res_ref);
15396 }
15397
15398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
15399         LDKCVec_u8Z script_pubkey_ref;
15400         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
15401         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
15402         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
15403         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
15404         *ret_ref = TxOut_new(script_pubkey_ref, value);
15405         return tag_ptr(ret_ref, true);
15406 }
15407
15408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
15409         if (!ptr_is_owned(_res)) return;
15410         void* _res_ptr = untag_ptr(_res);
15411         CHECK_ACCESS(_res_ptr);
15412         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
15413         FREE(untag_ptr(_res));
15414         TxOut_free(_res_conv);
15415 }
15416
15417 static inline uint64_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
15418         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
15419         *ret_ref = TxOut_clone(arg);
15420         return tag_ptr(ret_ref, true);
15421 }
15422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15423         LDKTxOut* arg_conv = (LDKTxOut*)untag_ptr(arg);
15424         int64_t ret_conv = TxOut_clone_ptr(arg_conv);
15425         return ret_conv;
15426 }
15427
15428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15429         LDKTxOut* orig_conv = (LDKTxOut*)untag_ptr(orig);
15430         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
15431         *ret_ref = TxOut_clone(orig_conv);
15432         return tag_ptr(ret_ref, true);
15433 }
15434
15435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
15436         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
15437         Str_free(dummy);
15438 }
15439
15440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
15441         LDKCVec_PublicKeyZ _res_constr;
15442         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15443         if (_res_constr.datalen > 0)
15444                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
15445         else
15446                 _res_constr.data = NULL;
15447         for (size_t i = 0; i < _res_constr.datalen; i++) {
15448                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
15449                 LDKPublicKey _res_conv_8_ref;
15450                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
15451                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
15452                 _res_constr.data[i] = _res_conv_8_ref;
15453         }
15454         CVec_PublicKeyZ_free(_res_constr);
15455 }
15456
15457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15458         LDKBlindedRoute o_conv;
15459         o_conv.inner = untag_ptr(o);
15460         o_conv.is_owned = ptr_is_owned(o);
15461         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15462         // WARNING: we need a move here but no clone is available for LDKBlindedRoute
15463         
15464         LDKCResult_BlindedRouteNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedRouteNoneZ), "LDKCResult_BlindedRouteNoneZ");
15465         *ret_conv = CResult_BlindedRouteNoneZ_ok(o_conv);
15466         return tag_ptr(ret_conv, true);
15467 }
15468
15469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteNoneZ_1err(JNIEnv *env, jclass clz) {
15470         LDKCResult_BlindedRouteNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedRouteNoneZ), "LDKCResult_BlindedRouteNoneZ");
15471         *ret_conv = CResult_BlindedRouteNoneZ_err();
15472         return tag_ptr(ret_conv, true);
15473 }
15474
15475 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15476         LDKCResult_BlindedRouteNoneZ* o_conv = (LDKCResult_BlindedRouteNoneZ*)untag_ptr(o);
15477         jboolean ret_conv = CResult_BlindedRouteNoneZ_is_ok(o_conv);
15478         return ret_conv;
15479 }
15480
15481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15482         if (!ptr_is_owned(_res)) return;
15483         void* _res_ptr = untag_ptr(_res);
15484         CHECK_ACCESS(_res_ptr);
15485         LDKCResult_BlindedRouteNoneZ _res_conv = *(LDKCResult_BlindedRouteNoneZ*)(_res_ptr);
15486         FREE(untag_ptr(_res));
15487         CResult_BlindedRouteNoneZ_free(_res_conv);
15488 }
15489
15490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15491         LDKBlindedRoute o_conv;
15492         o_conv.inner = untag_ptr(o);
15493         o_conv.is_owned = ptr_is_owned(o);
15494         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15495         // WARNING: we need a move here but no clone is available for LDKBlindedRoute
15496         
15497         LDKCResult_BlindedRouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedRouteDecodeErrorZ), "LDKCResult_BlindedRouteDecodeErrorZ");
15498         *ret_conv = CResult_BlindedRouteDecodeErrorZ_ok(o_conv);
15499         return tag_ptr(ret_conv, true);
15500 }
15501
15502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15503         void* e_ptr = untag_ptr(e);
15504         CHECK_ACCESS(e_ptr);
15505         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
15506         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
15507         LDKCResult_BlindedRouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedRouteDecodeErrorZ), "LDKCResult_BlindedRouteDecodeErrorZ");
15508         *ret_conv = CResult_BlindedRouteDecodeErrorZ_err(e_conv);
15509         return tag_ptr(ret_conv, true);
15510 }
15511
15512 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15513         LDKCResult_BlindedRouteDecodeErrorZ* o_conv = (LDKCResult_BlindedRouteDecodeErrorZ*)untag_ptr(o);
15514         jboolean ret_conv = CResult_BlindedRouteDecodeErrorZ_is_ok(o_conv);
15515         return ret_conv;
15516 }
15517
15518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15519         if (!ptr_is_owned(_res)) return;
15520         void* _res_ptr = untag_ptr(_res);
15521         CHECK_ACCESS(_res_ptr);
15522         LDKCResult_BlindedRouteDecodeErrorZ _res_conv = *(LDKCResult_BlindedRouteDecodeErrorZ*)(_res_ptr);
15523         FREE(untag_ptr(_res));
15524         CResult_BlindedRouteDecodeErrorZ_free(_res_conv);
15525 }
15526
15527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15528         LDKBlindedHop o_conv;
15529         o_conv.inner = untag_ptr(o);
15530         o_conv.is_owned = ptr_is_owned(o);
15531         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15532         // WARNING: we need a move here but no clone is available for LDKBlindedHop
15533         
15534         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
15535         *ret_conv = CResult_BlindedHopDecodeErrorZ_ok(o_conv);
15536         return tag_ptr(ret_conv, true);
15537 }
15538
15539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15540         void* e_ptr = untag_ptr(e);
15541         CHECK_ACCESS(e_ptr);
15542         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
15543         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
15544         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
15545         *ret_conv = CResult_BlindedHopDecodeErrorZ_err(e_conv);
15546         return tag_ptr(ret_conv, true);
15547 }
15548
15549 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15550         LDKCResult_BlindedHopDecodeErrorZ* o_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(o);
15551         jboolean ret_conv = CResult_BlindedHopDecodeErrorZ_is_ok(o_conv);
15552         return ret_conv;
15553 }
15554
15555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15556         if (!ptr_is_owned(_res)) return;
15557         void* _res_ptr = untag_ptr(_res);
15558         CHECK_ACCESS(_res_ptr);
15559         LDKCResult_BlindedHopDecodeErrorZ _res_conv = *(LDKCResult_BlindedHopDecodeErrorZ*)(_res_ptr);
15560         FREE(untag_ptr(_res));
15561         CResult_BlindedHopDecodeErrorZ_free(_res_conv);
15562 }
15563
15564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1ok(JNIEnv *env, jclass clz) {
15565         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
15566         *ret_conv = CResult_NoneNoneZ_ok();
15567         return tag_ptr(ret_conv, true);
15568 }
15569
15570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNIEnv *env, jclass clz) {
15571         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
15572         *ret_conv = CResult_NoneNoneZ_err();
15573         return tag_ptr(ret_conv, true);
15574 }
15575
15576 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15577         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)untag_ptr(o);
15578         jboolean ret_conv = CResult_NoneNoneZ_is_ok(o_conv);
15579         return ret_conv;
15580 }
15581
15582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15583         if (!ptr_is_owned(_res)) return;
15584         void* _res_ptr = untag_ptr(_res);
15585         CHECK_ACCESS(_res_ptr);
15586         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
15587         FREE(untag_ptr(_res));
15588         CResult_NoneNoneZ_free(_res_conv);
15589 }
15590
15591 static inline uint64_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
15592         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
15593         *ret_conv = CResult_NoneNoneZ_clone(arg);
15594         return tag_ptr(ret_conv, true);
15595 }
15596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15597         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)untag_ptr(arg);
15598         int64_t ret_conv = CResult_NoneNoneZ_clone_ptr(arg_conv);
15599         return ret_conv;
15600 }
15601
15602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15603         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)untag_ptr(orig);
15604         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
15605         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
15606         return tag_ptr(ret_conv, true);
15607 }
15608
15609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15610         LDKCounterpartyCommitmentSecrets o_conv;
15611         o_conv.inner = untag_ptr(o);
15612         o_conv.is_owned = ptr_is_owned(o);
15613         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15614         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
15615         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
15616         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
15617         return tag_ptr(ret_conv, true);
15618 }
15619
15620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15621         void* e_ptr = untag_ptr(e);
15622         CHECK_ACCESS(e_ptr);
15623         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
15624         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
15625         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
15626         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
15627         return tag_ptr(ret_conv, true);
15628 }
15629
15630 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15631         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(o);
15632         jboolean ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
15633         return ret_conv;
15634 }
15635
15636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15637         if (!ptr_is_owned(_res)) return;
15638         void* _res_ptr = untag_ptr(_res);
15639         CHECK_ACCESS(_res_ptr);
15640         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
15641         FREE(untag_ptr(_res));
15642         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
15643 }
15644
15645 static inline uint64_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
15646         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
15647         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
15648         return tag_ptr(ret_conv, true);
15649 }
15650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15651         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(arg);
15652         int64_t ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
15653         return ret_conv;
15654 }
15655
15656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15657         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(orig);
15658         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
15659         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
15660         return tag_ptr(ret_conv, true);
15661 }
15662
15663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
15664         LDKSecretKey o_ref;
15665         CHECK((*env)->GetArrayLength(env, o) == 32);
15666         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
15667         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
15668         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
15669         return tag_ptr(ret_conv, true);
15670 }
15671
15672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15673         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
15674         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
15675         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
15676         return tag_ptr(ret_conv, true);
15677 }
15678
15679 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15680         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)untag_ptr(o);
15681         jboolean ret_conv = CResult_SecretKeyErrorZ_is_ok(o_conv);
15682         return ret_conv;
15683 }
15684
15685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15686         if (!ptr_is_owned(_res)) return;
15687         void* _res_ptr = untag_ptr(_res);
15688         CHECK_ACCESS(_res_ptr);
15689         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
15690         FREE(untag_ptr(_res));
15691         CResult_SecretKeyErrorZ_free(_res_conv);
15692 }
15693
15694 static inline uint64_t CResult_SecretKeyErrorZ_clone_ptr(LDKCResult_SecretKeyErrorZ *NONNULL_PTR arg) {
15695         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
15696         *ret_conv = CResult_SecretKeyErrorZ_clone(arg);
15697         return tag_ptr(ret_conv, true);
15698 }
15699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15700         LDKCResult_SecretKeyErrorZ* arg_conv = (LDKCResult_SecretKeyErrorZ*)untag_ptr(arg);
15701         int64_t ret_conv = CResult_SecretKeyErrorZ_clone_ptr(arg_conv);
15702         return ret_conv;
15703 }
15704
15705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15706         LDKCResult_SecretKeyErrorZ* orig_conv = (LDKCResult_SecretKeyErrorZ*)untag_ptr(orig);
15707         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
15708         *ret_conv = CResult_SecretKeyErrorZ_clone(orig_conv);
15709         return tag_ptr(ret_conv, true);
15710 }
15711
15712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
15713         LDKPublicKey o_ref;
15714         CHECK((*env)->GetArrayLength(env, o) == 33);
15715         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
15716         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
15717         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
15718         return tag_ptr(ret_conv, true);
15719 }
15720
15721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15722         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
15723         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
15724         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
15725         return tag_ptr(ret_conv, true);
15726 }
15727
15728 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15729         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(o);
15730         jboolean ret_conv = CResult_PublicKeyErrorZ_is_ok(o_conv);
15731         return ret_conv;
15732 }
15733
15734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15735         if (!ptr_is_owned(_res)) return;
15736         void* _res_ptr = untag_ptr(_res);
15737         CHECK_ACCESS(_res_ptr);
15738         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
15739         FREE(untag_ptr(_res));
15740         CResult_PublicKeyErrorZ_free(_res_conv);
15741 }
15742
15743 static inline uint64_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
15744         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
15745         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
15746         return tag_ptr(ret_conv, true);
15747 }
15748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15749         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(arg);
15750         int64_t ret_conv = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
15751         return ret_conv;
15752 }
15753
15754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15755         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(orig);
15756         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
15757         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
15758         return tag_ptr(ret_conv, true);
15759 }
15760
15761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15762         LDKTxCreationKeys o_conv;
15763         o_conv.inner = untag_ptr(o);
15764         o_conv.is_owned = ptr_is_owned(o);
15765         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15766         o_conv = TxCreationKeys_clone(&o_conv);
15767         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
15768         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
15769         return tag_ptr(ret_conv, true);
15770 }
15771
15772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15773         void* e_ptr = untag_ptr(e);
15774         CHECK_ACCESS(e_ptr);
15775         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
15776         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
15777         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
15778         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
15779         return tag_ptr(ret_conv, true);
15780 }
15781
15782 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15783         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(o);
15784         jboolean ret_conv = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
15785         return ret_conv;
15786 }
15787
15788 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15789         if (!ptr_is_owned(_res)) return;
15790         void* _res_ptr = untag_ptr(_res);
15791         CHECK_ACCESS(_res_ptr);
15792         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
15793         FREE(untag_ptr(_res));
15794         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
15795 }
15796
15797 static inline uint64_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
15798         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
15799         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
15800         return tag_ptr(ret_conv, true);
15801 }
15802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15803         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(arg);
15804         int64_t ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
15805         return ret_conv;
15806 }
15807
15808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15809         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(orig);
15810         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
15811         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
15812         return tag_ptr(ret_conv, true);
15813 }
15814
15815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15816         LDKChannelPublicKeys o_conv;
15817         o_conv.inner = untag_ptr(o);
15818         o_conv.is_owned = ptr_is_owned(o);
15819         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15820         o_conv = ChannelPublicKeys_clone(&o_conv);
15821         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
15822         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
15823         return tag_ptr(ret_conv, true);
15824 }
15825
15826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15827         void* e_ptr = untag_ptr(e);
15828         CHECK_ACCESS(e_ptr);
15829         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
15830         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
15831         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
15832         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
15833         return tag_ptr(ret_conv, true);
15834 }
15835
15836 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15837         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(o);
15838         jboolean ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
15839         return ret_conv;
15840 }
15841
15842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15843         if (!ptr_is_owned(_res)) return;
15844         void* _res_ptr = untag_ptr(_res);
15845         CHECK_ACCESS(_res_ptr);
15846         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
15847         FREE(untag_ptr(_res));
15848         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
15849 }
15850
15851 static inline uint64_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
15852         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
15853         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
15854         return tag_ptr(ret_conv, true);
15855 }
15856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15857         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(arg);
15858         int64_t ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
15859         return ret_conv;
15860 }
15861
15862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15863         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(orig);
15864         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
15865         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
15866         return tag_ptr(ret_conv, true);
15867 }
15868
15869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15870         LDKTxCreationKeys o_conv;
15871         o_conv.inner = untag_ptr(o);
15872         o_conv.is_owned = ptr_is_owned(o);
15873         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15874         o_conv = TxCreationKeys_clone(&o_conv);
15875         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
15876         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
15877         return tag_ptr(ret_conv, true);
15878 }
15879
15880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15881         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
15882         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
15883         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
15884         return tag_ptr(ret_conv, true);
15885 }
15886
15887 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15888         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)untag_ptr(o);
15889         jboolean ret_conv = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
15890         return ret_conv;
15891 }
15892
15893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15894         if (!ptr_is_owned(_res)) return;
15895         void* _res_ptr = untag_ptr(_res);
15896         CHECK_ACCESS(_res_ptr);
15897         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
15898         FREE(untag_ptr(_res));
15899         CResult_TxCreationKeysErrorZ_free(_res_conv);
15900 }
15901
15902 static inline uint64_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
15903         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
15904         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
15905         return tag_ptr(ret_conv, true);
15906 }
15907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15908         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)untag_ptr(arg);
15909         int64_t ret_conv = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
15910         return ret_conv;
15911 }
15912
15913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15914         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)untag_ptr(orig);
15915         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
15916         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
15917         return tag_ptr(ret_conv, true);
15918 }
15919
15920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
15921         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
15922         *ret_copy = COption_u32Z_some(o);
15923         int64_t ret_ref = tag_ptr(ret_copy, true);
15924         return ret_ref;
15925 }
15926
15927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
15928         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
15929         *ret_copy = COption_u32Z_none();
15930         int64_t ret_ref = tag_ptr(ret_copy, true);
15931         return ret_ref;
15932 }
15933
15934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
15935         if (!ptr_is_owned(_res)) return;
15936         void* _res_ptr = untag_ptr(_res);
15937         CHECK_ACCESS(_res_ptr);
15938         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
15939         FREE(untag_ptr(_res));
15940         COption_u32Z_free(_res_conv);
15941 }
15942
15943 static inline uint64_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
15944         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
15945         *ret_copy = COption_u32Z_clone(arg);
15946         int64_t ret_ref = tag_ptr(ret_copy, true);
15947         return ret_ref;
15948 }
15949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15950         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)untag_ptr(arg);
15951         int64_t ret_conv = COption_u32Z_clone_ptr(arg_conv);
15952         return ret_conv;
15953 }
15954
15955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15956         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)untag_ptr(orig);
15957         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
15958         *ret_copy = COption_u32Z_clone(orig_conv);
15959         int64_t ret_ref = tag_ptr(ret_copy, true);
15960         return ret_ref;
15961 }
15962
15963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15964         LDKHTLCOutputInCommitment o_conv;
15965         o_conv.inner = untag_ptr(o);
15966         o_conv.is_owned = ptr_is_owned(o);
15967         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15968         o_conv = HTLCOutputInCommitment_clone(&o_conv);
15969         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
15970         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
15971         return tag_ptr(ret_conv, true);
15972 }
15973
15974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15975         void* e_ptr = untag_ptr(e);
15976         CHECK_ACCESS(e_ptr);
15977         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
15978         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
15979         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
15980         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
15981         return tag_ptr(ret_conv, true);
15982 }
15983
15984 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15985         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(o);
15986         jboolean ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
15987         return ret_conv;
15988 }
15989
15990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15991         if (!ptr_is_owned(_res)) return;
15992         void* _res_ptr = untag_ptr(_res);
15993         CHECK_ACCESS(_res_ptr);
15994         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
15995         FREE(untag_ptr(_res));
15996         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
15997 }
15998
15999 static inline uint64_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
16000         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
16001         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
16002         return tag_ptr(ret_conv, true);
16003 }
16004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16005         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(arg);
16006         int64_t ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
16007         return ret_conv;
16008 }
16009
16010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16011         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(orig);
16012         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
16013         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
16014         return tag_ptr(ret_conv, true);
16015 }
16016
16017 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1some(JNIEnv *env, jclass clz) {
16018         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_some());
16019         return ret_conv;
16020 }
16021
16022 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1none(JNIEnv *env, jclass clz) {
16023         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_none());
16024         return ret_conv;
16025 }
16026
16027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1free(JNIEnv *env, jclass clz, jclass _res) {
16028         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_java(env, _res);
16029         COption_NoneZ_free(_res_conv);
16030 }
16031
16032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16033         LDKCounterpartyChannelTransactionParameters o_conv;
16034         o_conv.inner = untag_ptr(o);
16035         o_conv.is_owned = ptr_is_owned(o);
16036         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16037         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
16038         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
16039         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
16040         return tag_ptr(ret_conv, true);
16041 }
16042
16043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16044         void* e_ptr = untag_ptr(e);
16045         CHECK_ACCESS(e_ptr);
16046         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16047         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16048         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
16049         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
16050         return tag_ptr(ret_conv, true);
16051 }
16052
16053 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16054         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(o);
16055         jboolean ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
16056         return ret_conv;
16057 }
16058
16059 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16060         if (!ptr_is_owned(_res)) return;
16061         void* _res_ptr = untag_ptr(_res);
16062         CHECK_ACCESS(_res_ptr);
16063         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
16064         FREE(untag_ptr(_res));
16065         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
16066 }
16067
16068 static inline uint64_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
16069         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
16070         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
16071         return tag_ptr(ret_conv, true);
16072 }
16073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16074         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(arg);
16075         int64_t ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
16076         return ret_conv;
16077 }
16078
16079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16080         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(orig);
16081         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
16082         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
16083         return tag_ptr(ret_conv, true);
16084 }
16085
16086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16087         LDKChannelTransactionParameters o_conv;
16088         o_conv.inner = untag_ptr(o);
16089         o_conv.is_owned = ptr_is_owned(o);
16090         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16091         o_conv = ChannelTransactionParameters_clone(&o_conv);
16092         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
16093         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
16094         return tag_ptr(ret_conv, true);
16095 }
16096
16097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16098         void* e_ptr = untag_ptr(e);
16099         CHECK_ACCESS(e_ptr);
16100         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16101         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16102         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
16103         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
16104         return tag_ptr(ret_conv, true);
16105 }
16106
16107 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16108         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(o);
16109         jboolean ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
16110         return ret_conv;
16111 }
16112
16113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16114         if (!ptr_is_owned(_res)) return;
16115         void* _res_ptr = untag_ptr(_res);
16116         CHECK_ACCESS(_res_ptr);
16117         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
16118         FREE(untag_ptr(_res));
16119         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
16120 }
16121
16122 static inline uint64_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
16123         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
16124         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
16125         return tag_ptr(ret_conv, true);
16126 }
16127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16128         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(arg);
16129         int64_t ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
16130         return ret_conv;
16131 }
16132
16133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16134         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(orig);
16135         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
16136         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
16137         return tag_ptr(ret_conv, true);
16138 }
16139
16140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16141         LDKCVec_SignatureZ _res_constr;
16142         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16143         if (_res_constr.datalen > 0)
16144                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
16145         else
16146                 _res_constr.data = NULL;
16147         for (size_t i = 0; i < _res_constr.datalen; i++) {
16148                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
16149                 LDKSignature _res_conv_8_ref;
16150                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
16151                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
16152                 _res_constr.data[i] = _res_conv_8_ref;
16153         }
16154         CVec_SignatureZ_free(_res_constr);
16155 }
16156
16157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16158         LDKHolderCommitmentTransaction o_conv;
16159         o_conv.inner = untag_ptr(o);
16160         o_conv.is_owned = ptr_is_owned(o);
16161         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16162         o_conv = HolderCommitmentTransaction_clone(&o_conv);
16163         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
16164         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
16165         return tag_ptr(ret_conv, true);
16166 }
16167
16168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16169         void* e_ptr = untag_ptr(e);
16170         CHECK_ACCESS(e_ptr);
16171         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16172         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16173         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
16174         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
16175         return tag_ptr(ret_conv, true);
16176 }
16177
16178 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16179         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(o);
16180         jboolean ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
16181         return ret_conv;
16182 }
16183
16184 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16185         if (!ptr_is_owned(_res)) return;
16186         void* _res_ptr = untag_ptr(_res);
16187         CHECK_ACCESS(_res_ptr);
16188         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
16189         FREE(untag_ptr(_res));
16190         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
16191 }
16192
16193 static inline uint64_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
16194         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
16195         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
16196         return tag_ptr(ret_conv, true);
16197 }
16198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16199         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
16200         int64_t ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
16201         return ret_conv;
16202 }
16203
16204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16205         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
16206         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
16207         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
16208         return tag_ptr(ret_conv, true);
16209 }
16210
16211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16212         LDKBuiltCommitmentTransaction o_conv;
16213         o_conv.inner = untag_ptr(o);
16214         o_conv.is_owned = ptr_is_owned(o);
16215         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16216         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
16217         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
16218         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
16219         return tag_ptr(ret_conv, true);
16220 }
16221
16222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16223         void* e_ptr = untag_ptr(e);
16224         CHECK_ACCESS(e_ptr);
16225         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16226         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16227         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
16228         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
16229         return tag_ptr(ret_conv, true);
16230 }
16231
16232 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16233         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(o);
16234         jboolean ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
16235         return ret_conv;
16236 }
16237
16238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16239         if (!ptr_is_owned(_res)) return;
16240         void* _res_ptr = untag_ptr(_res);
16241         CHECK_ACCESS(_res_ptr);
16242         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
16243         FREE(untag_ptr(_res));
16244         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
16245 }
16246
16247 static inline uint64_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
16248         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
16249         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
16250         return tag_ptr(ret_conv, true);
16251 }
16252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16253         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
16254         int64_t ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
16255         return ret_conv;
16256 }
16257
16258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16259         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
16260         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
16261         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
16262         return tag_ptr(ret_conv, true);
16263 }
16264
16265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16266         LDKTrustedClosingTransaction o_conv;
16267         o_conv.inner = untag_ptr(o);
16268         o_conv.is_owned = ptr_is_owned(o);
16269         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16270         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
16271         
16272         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
16273         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
16274         return tag_ptr(ret_conv, true);
16275 }
16276
16277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
16278         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
16279         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
16280         return tag_ptr(ret_conv, true);
16281 }
16282
16283 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16284         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(o);
16285         jboolean ret_conv = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
16286         return ret_conv;
16287 }
16288
16289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16290         if (!ptr_is_owned(_res)) return;
16291         void* _res_ptr = untag_ptr(_res);
16292         CHECK_ACCESS(_res_ptr);
16293         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
16294         FREE(untag_ptr(_res));
16295         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
16296 }
16297
16298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16299         LDKCommitmentTransaction o_conv;
16300         o_conv.inner = untag_ptr(o);
16301         o_conv.is_owned = ptr_is_owned(o);
16302         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16303         o_conv = CommitmentTransaction_clone(&o_conv);
16304         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
16305         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
16306         return tag_ptr(ret_conv, true);
16307 }
16308
16309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16310         void* e_ptr = untag_ptr(e);
16311         CHECK_ACCESS(e_ptr);
16312         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16313         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16314         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
16315         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
16316         return tag_ptr(ret_conv, true);
16317 }
16318
16319 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16320         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(o);
16321         jboolean ret_conv = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
16322         return ret_conv;
16323 }
16324
16325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16326         if (!ptr_is_owned(_res)) return;
16327         void* _res_ptr = untag_ptr(_res);
16328         CHECK_ACCESS(_res_ptr);
16329         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
16330         FREE(untag_ptr(_res));
16331         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
16332 }
16333
16334 static inline uint64_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
16335         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
16336         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
16337         return tag_ptr(ret_conv, true);
16338 }
16339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16340         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
16341         int64_t ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
16342         return ret_conv;
16343 }
16344
16345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16346         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
16347         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
16348         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
16349         return tag_ptr(ret_conv, true);
16350 }
16351
16352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16353         LDKTrustedCommitmentTransaction o_conv;
16354         o_conv.inner = untag_ptr(o);
16355         o_conv.is_owned = ptr_is_owned(o);
16356         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16357         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
16358         
16359         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
16360         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
16361         return tag_ptr(ret_conv, true);
16362 }
16363
16364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
16365         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
16366         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
16367         return tag_ptr(ret_conv, true);
16368 }
16369
16370 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16371         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(o);
16372         jboolean ret_conv = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
16373         return ret_conv;
16374 }
16375
16376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16377         if (!ptr_is_owned(_res)) return;
16378         void* _res_ptr = untag_ptr(_res);
16379         CHECK_ACCESS(_res_ptr);
16380         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
16381         FREE(untag_ptr(_res));
16382         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
16383 }
16384
16385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
16386         LDKCVec_SignatureZ o_constr;
16387         o_constr.datalen = (*env)->GetArrayLength(env, o);
16388         if (o_constr.datalen > 0)
16389                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
16390         else
16391                 o_constr.data = NULL;
16392         for (size_t i = 0; i < o_constr.datalen; i++) {
16393                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
16394                 LDKSignature o_conv_8_ref;
16395                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
16396                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
16397                 o_constr.data[i] = o_conv_8_ref;
16398         }
16399         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
16400         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
16401         return tag_ptr(ret_conv, true);
16402 }
16403
16404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
16405         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
16406         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
16407         return tag_ptr(ret_conv, true);
16408 }
16409
16410 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16411         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(o);
16412         jboolean ret_conv = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
16413         return ret_conv;
16414 }
16415
16416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16417         if (!ptr_is_owned(_res)) return;
16418         void* _res_ptr = untag_ptr(_res);
16419         CHECK_ACCESS(_res_ptr);
16420         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
16421         FREE(untag_ptr(_res));
16422         CResult_CVec_SignatureZNoneZ_free(_res_conv);
16423 }
16424
16425 static inline uint64_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
16426         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
16427         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
16428         return tag_ptr(ret_conv, true);
16429 }
16430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16431         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(arg);
16432         int64_t ret_conv = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
16433         return ret_conv;
16434 }
16435
16436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16437         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(orig);
16438         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
16439         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
16440         return tag_ptr(ret_conv, true);
16441 }
16442
16443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16444         LDKShutdownScript o_conv;
16445         o_conv.inner = untag_ptr(o);
16446         o_conv.is_owned = ptr_is_owned(o);
16447         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16448         o_conv = ShutdownScript_clone(&o_conv);
16449         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
16450         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
16451         return tag_ptr(ret_conv, true);
16452 }
16453
16454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16455         void* e_ptr = untag_ptr(e);
16456         CHECK_ACCESS(e_ptr);
16457         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16458         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16459         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
16460         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
16461         return tag_ptr(ret_conv, true);
16462 }
16463
16464 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16465         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(o);
16466         jboolean ret_conv = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
16467         return ret_conv;
16468 }
16469
16470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16471         if (!ptr_is_owned(_res)) return;
16472         void* _res_ptr = untag_ptr(_res);
16473         CHECK_ACCESS(_res_ptr);
16474         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
16475         FREE(untag_ptr(_res));
16476         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
16477 }
16478
16479 static inline uint64_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
16480         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
16481         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
16482         return tag_ptr(ret_conv, true);
16483 }
16484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16485         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(arg);
16486         int64_t ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
16487         return ret_conv;
16488 }
16489
16490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16491         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(orig);
16492         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
16493         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
16494         return tag_ptr(ret_conv, true);
16495 }
16496
16497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16498         LDKShutdownScript o_conv;
16499         o_conv.inner = untag_ptr(o);
16500         o_conv.is_owned = ptr_is_owned(o);
16501         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16502         o_conv = ShutdownScript_clone(&o_conv);
16503         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
16504         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
16505         return tag_ptr(ret_conv, true);
16506 }
16507
16508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16509         LDKInvalidShutdownScript e_conv;
16510         e_conv.inner = untag_ptr(e);
16511         e_conv.is_owned = ptr_is_owned(e);
16512         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16513         e_conv = InvalidShutdownScript_clone(&e_conv);
16514         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
16515         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
16516         return tag_ptr(ret_conv, true);
16517 }
16518
16519 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16520         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(o);
16521         jboolean ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
16522         return ret_conv;
16523 }
16524
16525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16526         if (!ptr_is_owned(_res)) return;
16527         void* _res_ptr = untag_ptr(_res);
16528         CHECK_ACCESS(_res_ptr);
16529         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
16530         FREE(untag_ptr(_res));
16531         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
16532 }
16533
16534 static inline uint64_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
16535         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
16536         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
16537         return tag_ptr(ret_conv, true);
16538 }
16539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16540         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(arg);
16541         int64_t ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
16542         return ret_conv;
16543 }
16544
16545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16546         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(orig);
16547         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
16548         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
16549         return tag_ptr(ret_conv, true);
16550 }
16551
16552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1WriteableScoreZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16553         void* o_ptr = untag_ptr(o);
16554         CHECK_ACCESS(o_ptr);
16555         LDKWriteableScore o_conv = *(LDKWriteableScore*)(o_ptr);
16556         if (o_conv.free == LDKWriteableScore_JCalls_free) {
16557                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16558                 LDKWriteableScore_JCalls_cloned(&o_conv);
16559         }
16560         LDKCOption_WriteableScoreZ *ret_copy = MALLOC(sizeof(LDKCOption_WriteableScoreZ), "LDKCOption_WriteableScoreZ");
16561         *ret_copy = COption_WriteableScoreZ_some(o_conv);
16562         int64_t ret_ref = tag_ptr(ret_copy, true);
16563         return ret_ref;
16564 }
16565
16566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1WriteableScoreZ_1none(JNIEnv *env, jclass clz) {
16567         LDKCOption_WriteableScoreZ *ret_copy = MALLOC(sizeof(LDKCOption_WriteableScoreZ), "LDKCOption_WriteableScoreZ");
16568         *ret_copy = COption_WriteableScoreZ_none();
16569         int64_t ret_ref = tag_ptr(ret_copy, true);
16570         return ret_ref;
16571 }
16572
16573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1WriteableScoreZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16574         if (!ptr_is_owned(_res)) return;
16575         void* _res_ptr = untag_ptr(_res);
16576         CHECK_ACCESS(_res_ptr);
16577         LDKCOption_WriteableScoreZ _res_conv = *(LDKCOption_WriteableScoreZ*)(_res_ptr);
16578         FREE(untag_ptr(_res));
16579         COption_WriteableScoreZ_free(_res_conv);
16580 }
16581
16582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
16583         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
16584         *ret_conv = CResult_NoneErrorZ_ok();
16585         return tag_ptr(ret_conv, true);
16586 }
16587
16588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
16589         LDKIOError e_conv = LDKIOError_from_java(env, e);
16590         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
16591         *ret_conv = CResult_NoneErrorZ_err(e_conv);
16592         return tag_ptr(ret_conv, true);
16593 }
16594
16595 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16596         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)untag_ptr(o);
16597         jboolean ret_conv = CResult_NoneErrorZ_is_ok(o_conv);
16598         return ret_conv;
16599 }
16600
16601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16602         if (!ptr_is_owned(_res)) return;
16603         void* _res_ptr = untag_ptr(_res);
16604         CHECK_ACCESS(_res_ptr);
16605         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
16606         FREE(untag_ptr(_res));
16607         CResult_NoneErrorZ_free(_res_conv);
16608 }
16609
16610 static inline uint64_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
16611         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
16612         *ret_conv = CResult_NoneErrorZ_clone(arg);
16613         return tag_ptr(ret_conv, true);
16614 }
16615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16616         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)untag_ptr(arg);
16617         int64_t ret_conv = CResult_NoneErrorZ_clone_ptr(arg_conv);
16618         return ret_conv;
16619 }
16620
16621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16622         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)untag_ptr(orig);
16623         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
16624         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
16625         return tag_ptr(ret_conv, true);
16626 }
16627
16628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16629         LDKRouteHop o_conv;
16630         o_conv.inner = untag_ptr(o);
16631         o_conv.is_owned = ptr_is_owned(o);
16632         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16633         o_conv = RouteHop_clone(&o_conv);
16634         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
16635         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
16636         return tag_ptr(ret_conv, true);
16637 }
16638
16639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16640         void* e_ptr = untag_ptr(e);
16641         CHECK_ACCESS(e_ptr);
16642         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16643         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16644         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
16645         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
16646         return tag_ptr(ret_conv, true);
16647 }
16648
16649 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16650         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(o);
16651         jboolean ret_conv = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
16652         return ret_conv;
16653 }
16654
16655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16656         if (!ptr_is_owned(_res)) return;
16657         void* _res_ptr = untag_ptr(_res);
16658         CHECK_ACCESS(_res_ptr);
16659         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
16660         FREE(untag_ptr(_res));
16661         CResult_RouteHopDecodeErrorZ_free(_res_conv);
16662 }
16663
16664 static inline uint64_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
16665         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
16666         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
16667         return tag_ptr(ret_conv, true);
16668 }
16669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16670         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(arg);
16671         int64_t ret_conv = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
16672         return ret_conv;
16673 }
16674
16675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16676         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(orig);
16677         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
16678         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
16679         return tag_ptr(ret_conv, true);
16680 }
16681
16682 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16683         LDKCVec_RouteHopZ _res_constr;
16684         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16685         if (_res_constr.datalen > 0)
16686                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
16687         else
16688                 _res_constr.data = NULL;
16689         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16690         for (size_t k = 0; k < _res_constr.datalen; k++) {
16691                 int64_t _res_conv_10 = _res_vals[k];
16692                 LDKRouteHop _res_conv_10_conv;
16693                 _res_conv_10_conv.inner = untag_ptr(_res_conv_10);
16694                 _res_conv_10_conv.is_owned = ptr_is_owned(_res_conv_10);
16695                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
16696                 _res_constr.data[k] = _res_conv_10_conv;
16697         }
16698         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16699         CVec_RouteHopZ_free(_res_constr);
16700 }
16701
16702 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16703         LDKCVec_CVec_RouteHopZZ _res_constr;
16704         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16705         if (_res_constr.datalen > 0)
16706                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
16707         else
16708                 _res_constr.data = NULL;
16709         for (size_t m = 0; m < _res_constr.datalen; m++) {
16710                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
16711                 LDKCVec_RouteHopZ _res_conv_12_constr;
16712                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
16713                 if (_res_conv_12_constr.datalen > 0)
16714                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
16715                 else
16716                         _res_conv_12_constr.data = NULL;
16717                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
16718                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
16719                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
16720                         LDKRouteHop _res_conv_12_conv_10_conv;
16721                         _res_conv_12_conv_10_conv.inner = untag_ptr(_res_conv_12_conv_10);
16722                         _res_conv_12_conv_10_conv.is_owned = ptr_is_owned(_res_conv_12_conv_10);
16723                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
16724                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
16725                 }
16726                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
16727                 _res_constr.data[m] = _res_conv_12_constr;
16728         }
16729         CVec_CVec_RouteHopZZ_free(_res_constr);
16730 }
16731
16732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16733         LDKRoute o_conv;
16734         o_conv.inner = untag_ptr(o);
16735         o_conv.is_owned = ptr_is_owned(o);
16736         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16737         o_conv = Route_clone(&o_conv);
16738         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
16739         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
16740         return tag_ptr(ret_conv, true);
16741 }
16742
16743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16744         void* e_ptr = untag_ptr(e);
16745         CHECK_ACCESS(e_ptr);
16746         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16747         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16748         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
16749         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
16750         return tag_ptr(ret_conv, true);
16751 }
16752
16753 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16754         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(o);
16755         jboolean ret_conv = CResult_RouteDecodeErrorZ_is_ok(o_conv);
16756         return ret_conv;
16757 }
16758
16759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16760         if (!ptr_is_owned(_res)) return;
16761         void* _res_ptr = untag_ptr(_res);
16762         CHECK_ACCESS(_res_ptr);
16763         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
16764         FREE(untag_ptr(_res));
16765         CResult_RouteDecodeErrorZ_free(_res_conv);
16766 }
16767
16768 static inline uint64_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
16769         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
16770         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
16771         return tag_ptr(ret_conv, true);
16772 }
16773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16774         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(arg);
16775         int64_t ret_conv = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
16776         return ret_conv;
16777 }
16778
16779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16780         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(orig);
16781         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
16782         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
16783         return tag_ptr(ret_conv, true);
16784 }
16785
16786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16787         LDKRouteParameters o_conv;
16788         o_conv.inner = untag_ptr(o);
16789         o_conv.is_owned = ptr_is_owned(o);
16790         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16791         o_conv = RouteParameters_clone(&o_conv);
16792         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
16793         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
16794         return tag_ptr(ret_conv, true);
16795 }
16796
16797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16798         void* e_ptr = untag_ptr(e);
16799         CHECK_ACCESS(e_ptr);
16800         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16801         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16802         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
16803         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
16804         return tag_ptr(ret_conv, true);
16805 }
16806
16807 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16808         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(o);
16809         jboolean ret_conv = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
16810         return ret_conv;
16811 }
16812
16813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16814         if (!ptr_is_owned(_res)) return;
16815         void* _res_ptr = untag_ptr(_res);
16816         CHECK_ACCESS(_res_ptr);
16817         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
16818         FREE(untag_ptr(_res));
16819         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
16820 }
16821
16822 static inline uint64_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
16823         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
16824         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
16825         return tag_ptr(ret_conv, true);
16826 }
16827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16828         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(arg);
16829         int64_t ret_conv = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
16830         return ret_conv;
16831 }
16832
16833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16834         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(orig);
16835         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
16836         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
16837         return tag_ptr(ret_conv, true);
16838 }
16839
16840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16841         LDKCVec_RouteHintZ _res_constr;
16842         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16843         if (_res_constr.datalen > 0)
16844                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
16845         else
16846                 _res_constr.data = NULL;
16847         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16848         for (size_t l = 0; l < _res_constr.datalen; l++) {
16849                 int64_t _res_conv_11 = _res_vals[l];
16850                 LDKRouteHint _res_conv_11_conv;
16851                 _res_conv_11_conv.inner = untag_ptr(_res_conv_11);
16852                 _res_conv_11_conv.is_owned = ptr_is_owned(_res_conv_11);
16853                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
16854                 _res_constr.data[l] = _res_conv_11_conv;
16855         }
16856         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16857         CVec_RouteHintZ_free(_res_constr);
16858 }
16859
16860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
16861         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16862         *ret_copy = COption_u64Z_some(o);
16863         int64_t ret_ref = tag_ptr(ret_copy, true);
16864         return ret_ref;
16865 }
16866
16867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
16868         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16869         *ret_copy = COption_u64Z_none();
16870         int64_t ret_ref = tag_ptr(ret_copy, true);
16871         return ret_ref;
16872 }
16873
16874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
16875         if (!ptr_is_owned(_res)) return;
16876         void* _res_ptr = untag_ptr(_res);
16877         CHECK_ACCESS(_res_ptr);
16878         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
16879         FREE(untag_ptr(_res));
16880         COption_u64Z_free(_res_conv);
16881 }
16882
16883 static inline uint64_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
16884         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16885         *ret_copy = COption_u64Z_clone(arg);
16886         int64_t ret_ref = tag_ptr(ret_copy, true);
16887         return ret_ref;
16888 }
16889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16890         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)untag_ptr(arg);
16891         int64_t ret_conv = COption_u64Z_clone_ptr(arg_conv);
16892         return ret_conv;
16893 }
16894
16895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16896         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)untag_ptr(orig);
16897         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16898         *ret_copy = COption_u64Z_clone(orig_conv);
16899         int64_t ret_ref = tag_ptr(ret_copy, true);
16900         return ret_ref;
16901 }
16902
16903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16904         LDKCVec_u64Z _res_constr;
16905         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16906         if (_res_constr.datalen > 0)
16907                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16908         else
16909                 _res_constr.data = NULL;
16910         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16911         for (size_t g = 0; g < _res_constr.datalen; g++) {
16912                 int64_t _res_conv_6 = _res_vals[g];
16913                 _res_constr.data[g] = _res_conv_6;
16914         }
16915         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16916         CVec_u64Z_free(_res_constr);
16917 }
16918
16919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16920         LDKPaymentParameters o_conv;
16921         o_conv.inner = untag_ptr(o);
16922         o_conv.is_owned = ptr_is_owned(o);
16923         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16924         o_conv = PaymentParameters_clone(&o_conv);
16925         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
16926         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
16927         return tag_ptr(ret_conv, true);
16928 }
16929
16930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16931         void* e_ptr = untag_ptr(e);
16932         CHECK_ACCESS(e_ptr);
16933         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16934         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16935         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
16936         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
16937         return tag_ptr(ret_conv, true);
16938 }
16939
16940 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16941         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(o);
16942         jboolean ret_conv = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
16943         return ret_conv;
16944 }
16945
16946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16947         if (!ptr_is_owned(_res)) return;
16948         void* _res_ptr = untag_ptr(_res);
16949         CHECK_ACCESS(_res_ptr);
16950         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
16951         FREE(untag_ptr(_res));
16952         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
16953 }
16954
16955 static inline uint64_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
16956         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
16957         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
16958         return tag_ptr(ret_conv, true);
16959 }
16960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16961         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(arg);
16962         int64_t ret_conv = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
16963         return ret_conv;
16964 }
16965
16966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16967         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(orig);
16968         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
16969         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
16970         return tag_ptr(ret_conv, true);
16971 }
16972
16973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16974         LDKCVec_RouteHintHopZ _res_constr;
16975         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16976         if (_res_constr.datalen > 0)
16977                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
16978         else
16979                 _res_constr.data = NULL;
16980         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16981         for (size_t o = 0; o < _res_constr.datalen; o++) {
16982                 int64_t _res_conv_14 = _res_vals[o];
16983                 LDKRouteHintHop _res_conv_14_conv;
16984                 _res_conv_14_conv.inner = untag_ptr(_res_conv_14);
16985                 _res_conv_14_conv.is_owned = ptr_is_owned(_res_conv_14);
16986                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
16987                 _res_constr.data[o] = _res_conv_14_conv;
16988         }
16989         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16990         CVec_RouteHintHopZ_free(_res_constr);
16991 }
16992
16993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16994         LDKRouteHint o_conv;
16995         o_conv.inner = untag_ptr(o);
16996         o_conv.is_owned = ptr_is_owned(o);
16997         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16998         o_conv = RouteHint_clone(&o_conv);
16999         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
17000         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
17001         return tag_ptr(ret_conv, true);
17002 }
17003
17004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17005         void* e_ptr = untag_ptr(e);
17006         CHECK_ACCESS(e_ptr);
17007         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17008         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17009         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
17010         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
17011         return tag_ptr(ret_conv, true);
17012 }
17013
17014 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17015         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(o);
17016         jboolean ret_conv = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
17017         return ret_conv;
17018 }
17019
17020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17021         if (!ptr_is_owned(_res)) return;
17022         void* _res_ptr = untag_ptr(_res);
17023         CHECK_ACCESS(_res_ptr);
17024         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
17025         FREE(untag_ptr(_res));
17026         CResult_RouteHintDecodeErrorZ_free(_res_conv);
17027 }
17028
17029 static inline uint64_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
17030         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
17031         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
17032         return tag_ptr(ret_conv, true);
17033 }
17034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17035         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(arg);
17036         int64_t ret_conv = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
17037         return ret_conv;
17038 }
17039
17040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17041         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(orig);
17042         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
17043         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
17044         return tag_ptr(ret_conv, true);
17045 }
17046
17047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17048         LDKRouteHintHop o_conv;
17049         o_conv.inner = untag_ptr(o);
17050         o_conv.is_owned = ptr_is_owned(o);
17051         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17052         o_conv = RouteHintHop_clone(&o_conv);
17053         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
17054         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
17055         return tag_ptr(ret_conv, true);
17056 }
17057
17058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17059         void* e_ptr = untag_ptr(e);
17060         CHECK_ACCESS(e_ptr);
17061         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17062         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17063         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
17064         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
17065         return tag_ptr(ret_conv, true);
17066 }
17067
17068 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17069         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(o);
17070         jboolean ret_conv = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
17071         return ret_conv;
17072 }
17073
17074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17075         if (!ptr_is_owned(_res)) return;
17076         void* _res_ptr = untag_ptr(_res);
17077         CHECK_ACCESS(_res_ptr);
17078         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
17079         FREE(untag_ptr(_res));
17080         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
17081 }
17082
17083 static inline uint64_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
17084         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
17085         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
17086         return tag_ptr(ret_conv, true);
17087 }
17088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17089         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(arg);
17090         int64_t ret_conv = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
17091         return ret_conv;
17092 }
17093
17094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17095         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(orig);
17096         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
17097         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
17098         return tag_ptr(ret_conv, true);
17099 }
17100
17101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17102         LDKCVec_ChannelDetailsZ _res_constr;
17103         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17104         if (_res_constr.datalen > 0)
17105                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
17106         else
17107                 _res_constr.data = NULL;
17108         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17109         for (size_t q = 0; q < _res_constr.datalen; q++) {
17110                 int64_t _res_conv_16 = _res_vals[q];
17111                 LDKChannelDetails _res_conv_16_conv;
17112                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
17113                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
17114                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
17115                 _res_constr.data[q] = _res_conv_16_conv;
17116         }
17117         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17118         CVec_ChannelDetailsZ_free(_res_constr);
17119 }
17120
17121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17122         LDKRoute o_conv;
17123         o_conv.inner = untag_ptr(o);
17124         o_conv.is_owned = ptr_is_owned(o);
17125         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17126         o_conv = Route_clone(&o_conv);
17127         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17128         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
17129         return tag_ptr(ret_conv, true);
17130 }
17131
17132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17133         LDKLightningError e_conv;
17134         e_conv.inner = untag_ptr(e);
17135         e_conv.is_owned = ptr_is_owned(e);
17136         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17137         e_conv = LightningError_clone(&e_conv);
17138         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17139         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
17140         return tag_ptr(ret_conv, true);
17141 }
17142
17143 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17144         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(o);
17145         jboolean ret_conv = CResult_RouteLightningErrorZ_is_ok(o_conv);
17146         return ret_conv;
17147 }
17148
17149 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17150         if (!ptr_is_owned(_res)) return;
17151         void* _res_ptr = untag_ptr(_res);
17152         CHECK_ACCESS(_res_ptr);
17153         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
17154         FREE(untag_ptr(_res));
17155         CResult_RouteLightningErrorZ_free(_res_conv);
17156 }
17157
17158 static inline uint64_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
17159         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17160         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
17161         return tag_ptr(ret_conv, true);
17162 }
17163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17164         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(arg);
17165         int64_t ret_conv = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
17166         return ret_conv;
17167 }
17168
17169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17170         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(orig);
17171         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17172         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
17173         return tag_ptr(ret_conv, true);
17174 }
17175
17176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17177         void* o_ptr = untag_ptr(o);
17178         CHECK_ACCESS(o_ptr);
17179         LDKPaymentPurpose o_conv = *(LDKPaymentPurpose*)(o_ptr);
17180         o_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(o));
17181         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
17182         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_ok(o_conv);
17183         return tag_ptr(ret_conv, true);
17184 }
17185
17186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17187         void* e_ptr = untag_ptr(e);
17188         CHECK_ACCESS(e_ptr);
17189         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17190         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17191         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
17192         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_err(e_conv);
17193         return tag_ptr(ret_conv, true);
17194 }
17195
17196 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17197         LDKCResult_PaymentPurposeDecodeErrorZ* o_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(o);
17198         jboolean ret_conv = CResult_PaymentPurposeDecodeErrorZ_is_ok(o_conv);
17199         return ret_conv;
17200 }
17201
17202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17203         if (!ptr_is_owned(_res)) return;
17204         void* _res_ptr = untag_ptr(_res);
17205         CHECK_ACCESS(_res_ptr);
17206         LDKCResult_PaymentPurposeDecodeErrorZ _res_conv = *(LDKCResult_PaymentPurposeDecodeErrorZ*)(_res_ptr);
17207         FREE(untag_ptr(_res));
17208         CResult_PaymentPurposeDecodeErrorZ_free(_res_conv);
17209 }
17210
17211 static inline uint64_t CResult_PaymentPurposeDecodeErrorZ_clone_ptr(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR arg) {
17212         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
17213         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(arg);
17214         return tag_ptr(ret_conv, true);
17215 }
17216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17217         LDKCResult_PaymentPurposeDecodeErrorZ* arg_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(arg);
17218         int64_t ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone_ptr(arg_conv);
17219         return ret_conv;
17220 }
17221
17222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17223         LDKCResult_PaymentPurposeDecodeErrorZ* orig_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(orig);
17224         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
17225         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(orig_conv);
17226         return tag_ptr(ret_conv, true);
17227 }
17228
17229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17230         void* o_ptr = untag_ptr(o);
17231         CHECK_ACCESS(o_ptr);
17232         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
17233         o_conv = ClosureReason_clone((LDKClosureReason*)untag_ptr(o));
17234         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
17235         *ret_copy = COption_ClosureReasonZ_some(o_conv);
17236         int64_t ret_ref = tag_ptr(ret_copy, true);
17237         return ret_ref;
17238 }
17239
17240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1none(JNIEnv *env, jclass clz) {
17241         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
17242         *ret_copy = COption_ClosureReasonZ_none();
17243         int64_t ret_ref = tag_ptr(ret_copy, true);
17244         return ret_ref;
17245 }
17246
17247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17248         if (!ptr_is_owned(_res)) return;
17249         void* _res_ptr = untag_ptr(_res);
17250         CHECK_ACCESS(_res_ptr);
17251         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
17252         FREE(untag_ptr(_res));
17253         COption_ClosureReasonZ_free(_res_conv);
17254 }
17255
17256 static inline uint64_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
17257         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
17258         *ret_copy = COption_ClosureReasonZ_clone(arg);
17259         int64_t ret_ref = tag_ptr(ret_copy, true);
17260         return ret_ref;
17261 }
17262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17263         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)untag_ptr(arg);
17264         int64_t ret_conv = COption_ClosureReasonZ_clone_ptr(arg_conv);
17265         return ret_conv;
17266 }
17267
17268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17269         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)untag_ptr(orig);
17270         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
17271         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
17272         int64_t ret_ref = tag_ptr(ret_copy, true);
17273         return ret_ref;
17274 }
17275
17276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17277         void* o_ptr = untag_ptr(o);
17278         CHECK_ACCESS(o_ptr);
17279         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
17280         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)untag_ptr(o));
17281         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
17282         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
17283         return tag_ptr(ret_conv, true);
17284 }
17285
17286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17287         void* e_ptr = untag_ptr(e);
17288         CHECK_ACCESS(e_ptr);
17289         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17290         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17291         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
17292         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
17293         return tag_ptr(ret_conv, true);
17294 }
17295
17296 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17297         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(o);
17298         jboolean ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
17299         return ret_conv;
17300 }
17301
17302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17303         if (!ptr_is_owned(_res)) return;
17304         void* _res_ptr = untag_ptr(_res);
17305         CHECK_ACCESS(_res_ptr);
17306         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
17307         FREE(untag_ptr(_res));
17308         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
17309 }
17310
17311 static inline uint64_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
17312         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
17313         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
17314         return tag_ptr(ret_conv, true);
17315 }
17316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17317         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(arg);
17318         int64_t ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
17319         return ret_conv;
17320 }
17321
17322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17323         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(orig);
17324         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
17325         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
17326         return tag_ptr(ret_conv, true);
17327 }
17328
17329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17330         void* o_ptr = untag_ptr(o);
17331         CHECK_ACCESS(o_ptr);
17332         LDKHTLCDestination o_conv = *(LDKHTLCDestination*)(o_ptr);
17333         o_conv = HTLCDestination_clone((LDKHTLCDestination*)untag_ptr(o));
17334         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
17335         *ret_copy = COption_HTLCDestinationZ_some(o_conv);
17336         int64_t ret_ref = tag_ptr(ret_copy, true);
17337         return ret_ref;
17338 }
17339
17340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1none(JNIEnv *env, jclass clz) {
17341         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
17342         *ret_copy = COption_HTLCDestinationZ_none();
17343         int64_t ret_ref = tag_ptr(ret_copy, true);
17344         return ret_ref;
17345 }
17346
17347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17348         if (!ptr_is_owned(_res)) return;
17349         void* _res_ptr = untag_ptr(_res);
17350         CHECK_ACCESS(_res_ptr);
17351         LDKCOption_HTLCDestinationZ _res_conv = *(LDKCOption_HTLCDestinationZ*)(_res_ptr);
17352         FREE(untag_ptr(_res));
17353         COption_HTLCDestinationZ_free(_res_conv);
17354 }
17355
17356 static inline uint64_t COption_HTLCDestinationZ_clone_ptr(LDKCOption_HTLCDestinationZ *NONNULL_PTR arg) {
17357         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
17358         *ret_copy = COption_HTLCDestinationZ_clone(arg);
17359         int64_t ret_ref = tag_ptr(ret_copy, true);
17360         return ret_ref;
17361 }
17362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17363         LDKCOption_HTLCDestinationZ* arg_conv = (LDKCOption_HTLCDestinationZ*)untag_ptr(arg);
17364         int64_t ret_conv = COption_HTLCDestinationZ_clone_ptr(arg_conv);
17365         return ret_conv;
17366 }
17367
17368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17369         LDKCOption_HTLCDestinationZ* orig_conv = (LDKCOption_HTLCDestinationZ*)untag_ptr(orig);
17370         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
17371         *ret_copy = COption_HTLCDestinationZ_clone(orig_conv);
17372         int64_t ret_ref = tag_ptr(ret_copy, true);
17373         return ret_ref;
17374 }
17375
17376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17377         void* o_ptr = untag_ptr(o);
17378         CHECK_ACCESS(o_ptr);
17379         LDKCOption_HTLCDestinationZ o_conv = *(LDKCOption_HTLCDestinationZ*)(o_ptr);
17380         o_conv = COption_HTLCDestinationZ_clone((LDKCOption_HTLCDestinationZ*)untag_ptr(o));
17381         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
17382         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_ok(o_conv);
17383         return tag_ptr(ret_conv, true);
17384 }
17385
17386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17387         void* e_ptr = untag_ptr(e);
17388         CHECK_ACCESS(e_ptr);
17389         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17390         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17391         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
17392         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_err(e_conv);
17393         return tag_ptr(ret_conv, true);
17394 }
17395
17396 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17397         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* o_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(o);
17398         jboolean ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(o_conv);
17399         return ret_conv;
17400 }
17401
17402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17403         if (!ptr_is_owned(_res)) return;
17404         void* _res_ptr = untag_ptr(_res);
17405         CHECK_ACCESS(_res_ptr);
17406         LDKCResult_COption_HTLCDestinationZDecodeErrorZ _res_conv = *(LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(_res_ptr);
17407         FREE(untag_ptr(_res));
17408         CResult_COption_HTLCDestinationZDecodeErrorZ_free(_res_conv);
17409 }
17410
17411 static inline uint64_t CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR arg) {
17412         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
17413         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(arg);
17414         return tag_ptr(ret_conv, true);
17415 }
17416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17417         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* arg_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(arg);
17418         int64_t ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(arg_conv);
17419         return ret_conv;
17420 }
17421
17422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17423         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* orig_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(orig);
17424         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
17425         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(orig_conv);
17426         return tag_ptr(ret_conv, true);
17427 }
17428
17429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17430         void* o_ptr = untag_ptr(o);
17431         CHECK_ACCESS(o_ptr);
17432         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
17433         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)untag_ptr(o));
17434         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
17435         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
17436         int64_t ret_ref = tag_ptr(ret_copy, true);
17437         return ret_ref;
17438 }
17439
17440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1none(JNIEnv *env, jclass clz) {
17441         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
17442         *ret_copy = COption_NetworkUpdateZ_none();
17443         int64_t ret_ref = tag_ptr(ret_copy, true);
17444         return ret_ref;
17445 }
17446
17447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_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         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
17452         FREE(untag_ptr(_res));
17453         COption_NetworkUpdateZ_free(_res_conv);
17454 }
17455
17456 static inline uint64_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
17457         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
17458         *ret_copy = COption_NetworkUpdateZ_clone(arg);
17459         int64_t ret_ref = tag_ptr(ret_copy, true);
17460         return ret_ref;
17461 }
17462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17463         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)untag_ptr(arg);
17464         int64_t ret_conv = COption_NetworkUpdateZ_clone_ptr(arg_conv);
17465         return ret_conv;
17466 }
17467
17468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17469         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)untag_ptr(orig);
17470         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
17471         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
17472         int64_t ret_ref = tag_ptr(ret_copy, true);
17473         return ret_ref;
17474 }
17475
17476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17477         LDKCVec_SpendableOutputDescriptorZ _res_constr;
17478         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17479         if (_res_constr.datalen > 0)
17480                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
17481         else
17482                 _res_constr.data = NULL;
17483         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17484         for (size_t b = 0; b < _res_constr.datalen; b++) {
17485                 int64_t _res_conv_27 = _res_vals[b];
17486                 void* _res_conv_27_ptr = untag_ptr(_res_conv_27);
17487                 CHECK_ACCESS(_res_conv_27_ptr);
17488                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
17489                 FREE(untag_ptr(_res_conv_27));
17490                 _res_constr.data[b] = _res_conv_27_conv;
17491         }
17492         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17493         CVec_SpendableOutputDescriptorZ_free(_res_constr);
17494 }
17495
17496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17497         void* o_ptr = untag_ptr(o);
17498         CHECK_ACCESS(o_ptr);
17499         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
17500         o_conv = Event_clone((LDKEvent*)untag_ptr(o));
17501         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
17502         *ret_copy = COption_EventZ_some(o_conv);
17503         int64_t ret_ref = tag_ptr(ret_copy, true);
17504         return ret_ref;
17505 }
17506
17507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1none(JNIEnv *env, jclass clz) {
17508         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
17509         *ret_copy = COption_EventZ_none();
17510         int64_t ret_ref = tag_ptr(ret_copy, true);
17511         return ret_ref;
17512 }
17513
17514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17515         if (!ptr_is_owned(_res)) return;
17516         void* _res_ptr = untag_ptr(_res);
17517         CHECK_ACCESS(_res_ptr);
17518         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
17519         FREE(untag_ptr(_res));
17520         COption_EventZ_free(_res_conv);
17521 }
17522
17523 static inline uint64_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
17524         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
17525         *ret_copy = COption_EventZ_clone(arg);
17526         int64_t ret_ref = tag_ptr(ret_copy, true);
17527         return ret_ref;
17528 }
17529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17530         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)untag_ptr(arg);
17531         int64_t ret_conv = COption_EventZ_clone_ptr(arg_conv);
17532         return ret_conv;
17533 }
17534
17535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17536         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)untag_ptr(orig);
17537         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
17538         *ret_copy = COption_EventZ_clone(orig_conv);
17539         int64_t ret_ref = tag_ptr(ret_copy, true);
17540         return ret_ref;
17541 }
17542
17543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17544         void* o_ptr = untag_ptr(o);
17545         CHECK_ACCESS(o_ptr);
17546         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
17547         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)untag_ptr(o));
17548         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
17549         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
17550         return tag_ptr(ret_conv, true);
17551 }
17552
17553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17554         void* e_ptr = untag_ptr(e);
17555         CHECK_ACCESS(e_ptr);
17556         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17557         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17558         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
17559         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
17560         return tag_ptr(ret_conv, true);
17561 }
17562
17563 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17564         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(o);
17565         jboolean ret_conv = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
17566         return ret_conv;
17567 }
17568
17569 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17570         if (!ptr_is_owned(_res)) return;
17571         void* _res_ptr = untag_ptr(_res);
17572         CHECK_ACCESS(_res_ptr);
17573         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
17574         FREE(untag_ptr(_res));
17575         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
17576 }
17577
17578 static inline uint64_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
17579         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
17580         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
17581         return tag_ptr(ret_conv, true);
17582 }
17583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17584         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(arg);
17585         int64_t ret_conv = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
17586         return ret_conv;
17587 }
17588
17589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17590         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(orig);
17591         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
17592         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
17593         return tag_ptr(ret_conv, true);
17594 }
17595
17596 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17597         LDKCVec_MessageSendEventZ _res_constr;
17598         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17599         if (_res_constr.datalen > 0)
17600                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
17601         else
17602                 _res_constr.data = NULL;
17603         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17604         for (size_t s = 0; s < _res_constr.datalen; s++) {
17605                 int64_t _res_conv_18 = _res_vals[s];
17606                 void* _res_conv_18_ptr = untag_ptr(_res_conv_18);
17607                 CHECK_ACCESS(_res_conv_18_ptr);
17608                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
17609                 FREE(untag_ptr(_res_conv_18));
17610                 _res_constr.data[s] = _res_conv_18_conv;
17611         }
17612         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17613         CVec_MessageSendEventZ_free(_res_constr);
17614 }
17615
17616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17617         void* o_ptr = untag_ptr(o);
17618         CHECK_ACCESS(o_ptr);
17619         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
17620         o_conv = TxOut_clone((LDKTxOut*)untag_ptr(o));
17621         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
17622         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
17623         return tag_ptr(ret_conv, true);
17624 }
17625
17626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
17627         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
17628         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
17629         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
17630         return tag_ptr(ret_conv, true);
17631 }
17632
17633 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17634         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(o);
17635         jboolean ret_conv = CResult_TxOutAccessErrorZ_is_ok(o_conv);
17636         return ret_conv;
17637 }
17638
17639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17640         if (!ptr_is_owned(_res)) return;
17641         void* _res_ptr = untag_ptr(_res);
17642         CHECK_ACCESS(_res_ptr);
17643         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
17644         FREE(untag_ptr(_res));
17645         CResult_TxOutAccessErrorZ_free(_res_conv);
17646 }
17647
17648 static inline uint64_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
17649         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
17650         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
17651         return tag_ptr(ret_conv, true);
17652 }
17653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17654         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(arg);
17655         int64_t ret_conv = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
17656         return ret_conv;
17657 }
17658
17659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17660         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(orig);
17661         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
17662         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
17663         return tag_ptr(ret_conv, true);
17664 }
17665
17666 static inline uint64_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
17667         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
17668         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
17669         return tag_ptr(ret_conv, true);
17670 }
17671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17672         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(arg);
17673         int64_t ret_conv = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
17674         return ret_conv;
17675 }
17676
17677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17678         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(orig);
17679         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
17680         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
17681         return tag_ptr(ret_conv, true);
17682 }
17683
17684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
17685         LDKTransaction b_ref;
17686         b_ref.datalen = (*env)->GetArrayLength(env, b);
17687         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
17688         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
17689         b_ref.data_is_owned = true;
17690         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
17691         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
17692         return tag_ptr(ret_conv, true);
17693 }
17694
17695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17696         if (!ptr_is_owned(_res)) return;
17697         void* _res_ptr = untag_ptr(_res);
17698         CHECK_ACCESS(_res_ptr);
17699         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
17700         FREE(untag_ptr(_res));
17701         C2Tuple_usizeTransactionZ_free(_res_conv);
17702 }
17703
17704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17705         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
17706         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17707         if (_res_constr.datalen > 0)
17708                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
17709         else
17710                 _res_constr.data = NULL;
17711         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17712         for (size_t c = 0; c < _res_constr.datalen; c++) {
17713                 int64_t _res_conv_28 = _res_vals[c];
17714                 void* _res_conv_28_ptr = untag_ptr(_res_conv_28);
17715                 CHECK_ACCESS(_res_conv_28_ptr);
17716                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
17717                 FREE(untag_ptr(_res_conv_28));
17718                 _res_constr.data[c] = _res_conv_28_conv;
17719         }
17720         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17721         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
17722 }
17723
17724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
17725         LDKCVec_TxidZ _res_constr;
17726         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17727         if (_res_constr.datalen > 0)
17728                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
17729         else
17730                 _res_constr.data = NULL;
17731         for (size_t i = 0; i < _res_constr.datalen; i++) {
17732                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
17733                 LDKThirtyTwoBytes _res_conv_8_ref;
17734                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
17735                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
17736                 _res_constr.data[i] = _res_conv_8_ref;
17737         }
17738         CVec_TxidZ_free(_res_constr);
17739 }
17740
17741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17742         LDKCVec_MonitorEventZ _res_constr;
17743         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17744         if (_res_constr.datalen > 0)
17745                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
17746         else
17747                 _res_constr.data = NULL;
17748         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17749         for (size_t o = 0; o < _res_constr.datalen; o++) {
17750                 int64_t _res_conv_14 = _res_vals[o];
17751                 void* _res_conv_14_ptr = untag_ptr(_res_conv_14);
17752                 CHECK_ACCESS(_res_conv_14_ptr);
17753                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
17754                 FREE(untag_ptr(_res_conv_14));
17755                 _res_constr.data[o] = _res_conv_14_conv;
17756         }
17757         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17758         CVec_MonitorEventZ_free(_res_constr);
17759 }
17760
17761 static inline uint64_t C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR arg) {
17762         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
17763         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(arg);
17764         return tag_ptr(ret_conv, true);
17765 }
17766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17767         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* arg_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(arg);
17768         int64_t ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(arg_conv);
17769         return ret_conv;
17770 }
17771
17772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17773         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* orig_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(orig);
17774         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
17775         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(orig_conv);
17776         return tag_ptr(ret_conv, true);
17777 }
17778
17779 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) {
17780         LDKOutPoint a_conv;
17781         a_conv.inner = untag_ptr(a);
17782         a_conv.is_owned = ptr_is_owned(a);
17783         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
17784         a_conv = OutPoint_clone(&a_conv);
17785         LDKCVec_MonitorEventZ b_constr;
17786         b_constr.datalen = (*env)->GetArrayLength(env, b);
17787         if (b_constr.datalen > 0)
17788                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
17789         else
17790                 b_constr.data = NULL;
17791         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
17792         for (size_t o = 0; o < b_constr.datalen; o++) {
17793                 int64_t b_conv_14 = b_vals[o];
17794                 void* b_conv_14_ptr = untag_ptr(b_conv_14);
17795                 CHECK_ACCESS(b_conv_14_ptr);
17796                 LDKMonitorEvent b_conv_14_conv = *(LDKMonitorEvent*)(b_conv_14_ptr);
17797                 b_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)untag_ptr(b_conv_14));
17798                 b_constr.data[o] = b_conv_14_conv;
17799         }
17800         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
17801         LDKPublicKey c_ref;
17802         CHECK((*env)->GetArrayLength(env, c) == 33);
17803         (*env)->GetByteArrayRegion(env, c, 0, 33, c_ref.compressed_form);
17804         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
17805         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(a_conv, b_constr, c_ref);
17806         return tag_ptr(ret_conv, true);
17807 }
17808
17809 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17810         if (!ptr_is_owned(_res)) return;
17811         void* _res_ptr = untag_ptr(_res);
17812         CHECK_ACCESS(_res_ptr);
17813         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_ptr);
17814         FREE(untag_ptr(_res));
17815         C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(_res_conv);
17816 }
17817
17818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17819         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ _res_constr;
17820         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17821         if (_res_constr.datalen > 0)
17822                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
17823         else
17824                 _res_constr.data = NULL;
17825         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17826         for (size_t x = 0; x < _res_constr.datalen; x++) {
17827                 int64_t _res_conv_49 = _res_vals[x];
17828                 void* _res_conv_49_ptr = untag_ptr(_res_conv_49);
17829                 CHECK_ACCESS(_res_conv_49_ptr);
17830                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_conv_49_ptr);
17831                 FREE(untag_ptr(_res_conv_49));
17832                 _res_constr.data[x] = _res_conv_49_conv;
17833         }
17834         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17835         CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(_res_constr);
17836 }
17837
17838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17839         LDKFixedPenaltyScorer o_conv;
17840         o_conv.inner = untag_ptr(o);
17841         o_conv.is_owned = ptr_is_owned(o);
17842         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17843         o_conv = FixedPenaltyScorer_clone(&o_conv);
17844         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
17845         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
17846         return tag_ptr(ret_conv, true);
17847 }
17848
17849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17850         void* e_ptr = untag_ptr(e);
17851         CHECK_ACCESS(e_ptr);
17852         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17853         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17854         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
17855         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
17856         return tag_ptr(ret_conv, true);
17857 }
17858
17859 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17860         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(o);
17861         jboolean ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
17862         return ret_conv;
17863 }
17864
17865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17866         if (!ptr_is_owned(_res)) return;
17867         void* _res_ptr = untag_ptr(_res);
17868         CHECK_ACCESS(_res_ptr);
17869         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
17870         FREE(untag_ptr(_res));
17871         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
17872 }
17873
17874 static inline uint64_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
17875         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
17876         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
17877         return tag_ptr(ret_conv, true);
17878 }
17879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17880         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(arg);
17881         int64_t ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
17882         return ret_conv;
17883 }
17884
17885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17886         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(orig);
17887         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
17888         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
17889         return tag_ptr(ret_conv, true);
17890 }
17891
17892 static inline uint64_t C2Tuple_u64u64Z_clone_ptr(LDKC2Tuple_u64u64Z *NONNULL_PTR arg) {
17893         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
17894         *ret_conv = C2Tuple_u64u64Z_clone(arg);
17895         return tag_ptr(ret_conv, true);
17896 }
17897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17898         LDKC2Tuple_u64u64Z* arg_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(arg);
17899         int64_t ret_conv = C2Tuple_u64u64Z_clone_ptr(arg_conv);
17900         return ret_conv;
17901 }
17902
17903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17904         LDKC2Tuple_u64u64Z* orig_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(orig);
17905         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
17906         *ret_conv = C2Tuple_u64u64Z_clone(orig_conv);
17907         return tag_ptr(ret_conv, true);
17908 }
17909
17910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1new(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
17911         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
17912         *ret_conv = C2Tuple_u64u64Z_new(a, b);
17913         return tag_ptr(ret_conv, true);
17914 }
17915
17916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
17917         if (!ptr_is_owned(_res)) return;
17918         void* _res_ptr = untag_ptr(_res);
17919         CHECK_ACCESS(_res_ptr);
17920         LDKC2Tuple_u64u64Z _res_conv = *(LDKC2Tuple_u64u64Z*)(_res_ptr);
17921         FREE(untag_ptr(_res));
17922         C2Tuple_u64u64Z_free(_res_conv);
17923 }
17924
17925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17926         void* o_ptr = untag_ptr(o);
17927         CHECK_ACCESS(o_ptr);
17928         LDKC2Tuple_u64u64Z o_conv = *(LDKC2Tuple_u64u64Z*)(o_ptr);
17929         o_conv = C2Tuple_u64u64Z_clone((LDKC2Tuple_u64u64Z*)untag_ptr(o));
17930         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
17931         *ret_copy = COption_C2Tuple_u64u64ZZ_some(o_conv);
17932         int64_t ret_ref = tag_ptr(ret_copy, true);
17933         return ret_ref;
17934 }
17935
17936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1none(JNIEnv *env, jclass clz) {
17937         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
17938         *ret_copy = COption_C2Tuple_u64u64ZZ_none();
17939         int64_t ret_ref = tag_ptr(ret_copy, true);
17940         return ret_ref;
17941 }
17942
17943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17944         if (!ptr_is_owned(_res)) return;
17945         void* _res_ptr = untag_ptr(_res);
17946         CHECK_ACCESS(_res_ptr);
17947         LDKCOption_C2Tuple_u64u64ZZ _res_conv = *(LDKCOption_C2Tuple_u64u64ZZ*)(_res_ptr);
17948         FREE(untag_ptr(_res));
17949         COption_C2Tuple_u64u64ZZ_free(_res_conv);
17950 }
17951
17952 static inline uint64_t COption_C2Tuple_u64u64ZZ_clone_ptr(LDKCOption_C2Tuple_u64u64ZZ *NONNULL_PTR arg) {
17953         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
17954         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(arg);
17955         int64_t ret_ref = tag_ptr(ret_copy, true);
17956         return ret_ref;
17957 }
17958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17959         LDKCOption_C2Tuple_u64u64ZZ* arg_conv = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(arg);
17960         int64_t ret_conv = COption_C2Tuple_u64u64ZZ_clone_ptr(arg_conv);
17961         return ret_conv;
17962 }
17963
17964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17965         LDKCOption_C2Tuple_u64u64ZZ* orig_conv = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(orig);
17966         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
17967         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(orig_conv);
17968         int64_t ret_ref = tag_ptr(ret_copy, true);
17969         return ret_ref;
17970 }
17971
17972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeIdZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17973         LDKCVec_NodeIdZ _res_constr;
17974         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17975         if (_res_constr.datalen > 0)
17976                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
17977         else
17978                 _res_constr.data = NULL;
17979         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17980         for (size_t i = 0; i < _res_constr.datalen; i++) {
17981                 int64_t _res_conv_8 = _res_vals[i];
17982                 LDKNodeId _res_conv_8_conv;
17983                 _res_conv_8_conv.inner = untag_ptr(_res_conv_8);
17984                 _res_conv_8_conv.is_owned = ptr_is_owned(_res_conv_8);
17985                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_8_conv);
17986                 _res_constr.data[i] = _res_conv_8_conv;
17987         }
17988         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17989         CVec_NodeIdZ_free(_res_constr);
17990 }
17991
17992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17993         LDKProbabilisticScorer o_conv;
17994         o_conv.inner = untag_ptr(o);
17995         o_conv.is_owned = ptr_is_owned(o);
17996         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17997         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
17998         
17999         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
18000         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
18001         return tag_ptr(ret_conv, true);
18002 }
18003
18004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18005         void* e_ptr = untag_ptr(e);
18006         CHECK_ACCESS(e_ptr);
18007         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18008         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18009         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
18010         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
18011         return tag_ptr(ret_conv, true);
18012 }
18013
18014 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18015         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(o);
18016         jboolean ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
18017         return ret_conv;
18018 }
18019
18020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18021         if (!ptr_is_owned(_res)) return;
18022         void* _res_ptr = untag_ptr(_res);
18023         CHECK_ACCESS(_res_ptr);
18024         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
18025         FREE(untag_ptr(_res));
18026         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
18027 }
18028
18029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18030         LDKInitFeatures o_conv;
18031         o_conv.inner = untag_ptr(o);
18032         o_conv.is_owned = ptr_is_owned(o);
18033         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18034         o_conv = InitFeatures_clone(&o_conv);
18035         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18036         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
18037         return tag_ptr(ret_conv, true);
18038 }
18039
18040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18041         void* e_ptr = untag_ptr(e);
18042         CHECK_ACCESS(e_ptr);
18043         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18044         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18045         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18046         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
18047         return tag_ptr(ret_conv, true);
18048 }
18049
18050 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18051         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(o);
18052         jboolean ret_conv = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
18053         return ret_conv;
18054 }
18055
18056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18057         if (!ptr_is_owned(_res)) return;
18058         void* _res_ptr = untag_ptr(_res);
18059         CHECK_ACCESS(_res_ptr);
18060         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
18061         FREE(untag_ptr(_res));
18062         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
18063 }
18064
18065 static inline uint64_t CResult_InitFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18066         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18067         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(arg);
18068         return tag_ptr(ret_conv, true);
18069 }
18070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18071         LDKCResult_InitFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(arg);
18072         int64_t ret_conv = CResult_InitFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18073         return ret_conv;
18074 }
18075
18076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18077         LDKCResult_InitFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(orig);
18078         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18079         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(orig_conv);
18080         return tag_ptr(ret_conv, true);
18081 }
18082
18083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18084         LDKChannelFeatures o_conv;
18085         o_conv.inner = untag_ptr(o);
18086         o_conv.is_owned = ptr_is_owned(o);
18087         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18088         o_conv = ChannelFeatures_clone(&o_conv);
18089         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18090         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
18091         return tag_ptr(ret_conv, true);
18092 }
18093
18094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18095         void* e_ptr = untag_ptr(e);
18096         CHECK_ACCESS(e_ptr);
18097         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18098         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18099         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18100         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
18101         return tag_ptr(ret_conv, true);
18102 }
18103
18104 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18105         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(o);
18106         jboolean ret_conv = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
18107         return ret_conv;
18108 }
18109
18110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18111         if (!ptr_is_owned(_res)) return;
18112         void* _res_ptr = untag_ptr(_res);
18113         CHECK_ACCESS(_res_ptr);
18114         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
18115         FREE(untag_ptr(_res));
18116         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
18117 }
18118
18119 static inline uint64_t CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18120         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18121         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(arg);
18122         return tag_ptr(ret_conv, true);
18123 }
18124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18125         LDKCResult_ChannelFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(arg);
18126         int64_t ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18127         return ret_conv;
18128 }
18129
18130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18131         LDKCResult_ChannelFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(orig);
18132         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18133         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(orig_conv);
18134         return tag_ptr(ret_conv, true);
18135 }
18136
18137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18138         LDKNodeFeatures o_conv;
18139         o_conv.inner = untag_ptr(o);
18140         o_conv.is_owned = ptr_is_owned(o);
18141         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18142         o_conv = NodeFeatures_clone(&o_conv);
18143         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18144         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
18145         return tag_ptr(ret_conv, true);
18146 }
18147
18148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18149         void* e_ptr = untag_ptr(e);
18150         CHECK_ACCESS(e_ptr);
18151         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18152         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18153         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18154         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
18155         return tag_ptr(ret_conv, true);
18156 }
18157
18158 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18159         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(o);
18160         jboolean ret_conv = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
18161         return ret_conv;
18162 }
18163
18164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18165         if (!ptr_is_owned(_res)) return;
18166         void* _res_ptr = untag_ptr(_res);
18167         CHECK_ACCESS(_res_ptr);
18168         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
18169         FREE(untag_ptr(_res));
18170         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
18171 }
18172
18173 static inline uint64_t CResult_NodeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18174         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18175         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(arg);
18176         return tag_ptr(ret_conv, true);
18177 }
18178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18179         LDKCResult_NodeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(arg);
18180         int64_t ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18181         return ret_conv;
18182 }
18183
18184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18185         LDKCResult_NodeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(orig);
18186         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18187         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(orig_conv);
18188         return tag_ptr(ret_conv, true);
18189 }
18190
18191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18192         LDKInvoiceFeatures o_conv;
18193         o_conv.inner = untag_ptr(o);
18194         o_conv.is_owned = ptr_is_owned(o);
18195         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18196         o_conv = InvoiceFeatures_clone(&o_conv);
18197         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
18198         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
18199         return tag_ptr(ret_conv, true);
18200 }
18201
18202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18203         void* e_ptr = untag_ptr(e);
18204         CHECK_ACCESS(e_ptr);
18205         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18206         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18207         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
18208         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
18209         return tag_ptr(ret_conv, true);
18210 }
18211
18212 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18213         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(o);
18214         jboolean ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
18215         return ret_conv;
18216 }
18217
18218 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18219         if (!ptr_is_owned(_res)) return;
18220         void* _res_ptr = untag_ptr(_res);
18221         CHECK_ACCESS(_res_ptr);
18222         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
18223         FREE(untag_ptr(_res));
18224         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
18225 }
18226
18227 static inline uint64_t CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18228         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
18229         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(arg);
18230         return tag_ptr(ret_conv, true);
18231 }
18232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18233         LDKCResult_InvoiceFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(arg);
18234         int64_t ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18235         return ret_conv;
18236 }
18237
18238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18239         LDKCResult_InvoiceFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(orig);
18240         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
18241         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(orig_conv);
18242         return tag_ptr(ret_conv, true);
18243 }
18244
18245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18246         LDKChannelTypeFeatures o_conv;
18247         o_conv.inner = untag_ptr(o);
18248         o_conv.is_owned = ptr_is_owned(o);
18249         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18250         o_conv = ChannelTypeFeatures_clone(&o_conv);
18251         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
18252         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
18253         return tag_ptr(ret_conv, true);
18254 }
18255
18256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18257         void* e_ptr = untag_ptr(e);
18258         CHECK_ACCESS(e_ptr);
18259         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18260         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18261         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
18262         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
18263         return tag_ptr(ret_conv, true);
18264 }
18265
18266 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18267         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(o);
18268         jboolean ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
18269         return ret_conv;
18270 }
18271
18272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18273         if (!ptr_is_owned(_res)) return;
18274         void* _res_ptr = untag_ptr(_res);
18275         CHECK_ACCESS(_res_ptr);
18276         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
18277         FREE(untag_ptr(_res));
18278         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
18279 }
18280
18281 static inline uint64_t CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18282         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
18283         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(arg);
18284         return tag_ptr(ret_conv, true);
18285 }
18286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18287         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(arg);
18288         int64_t ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18289         return ret_conv;
18290 }
18291
18292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18293         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(orig);
18294         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
18295         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig_conv);
18296         return tag_ptr(ret_conv, true);
18297 }
18298
18299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18300         LDKNodeId o_conv;
18301         o_conv.inner = untag_ptr(o);
18302         o_conv.is_owned = ptr_is_owned(o);
18303         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18304         o_conv = NodeId_clone(&o_conv);
18305         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
18306         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
18307         return tag_ptr(ret_conv, true);
18308 }
18309
18310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18311         void* e_ptr = untag_ptr(e);
18312         CHECK_ACCESS(e_ptr);
18313         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18314         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18315         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
18316         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
18317         return tag_ptr(ret_conv, true);
18318 }
18319
18320 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18321         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(o);
18322         jboolean ret_conv = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
18323         return ret_conv;
18324 }
18325
18326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18327         if (!ptr_is_owned(_res)) return;
18328         void* _res_ptr = untag_ptr(_res);
18329         CHECK_ACCESS(_res_ptr);
18330         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
18331         FREE(untag_ptr(_res));
18332         CResult_NodeIdDecodeErrorZ_free(_res_conv);
18333 }
18334
18335 static inline uint64_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
18336         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
18337         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
18338         return tag_ptr(ret_conv, true);
18339 }
18340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18341         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(arg);
18342         int64_t ret_conv = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
18343         return ret_conv;
18344 }
18345
18346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18347         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(orig);
18348         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
18349         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
18350         return tag_ptr(ret_conv, true);
18351 }
18352
18353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18354         void* o_ptr = untag_ptr(o);
18355         CHECK_ACCESS(o_ptr);
18356         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
18357         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)untag_ptr(o));
18358         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
18359         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
18360         return tag_ptr(ret_conv, true);
18361 }
18362
18363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18364         void* e_ptr = untag_ptr(e);
18365         CHECK_ACCESS(e_ptr);
18366         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18367         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18368         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
18369         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
18370         return tag_ptr(ret_conv, true);
18371 }
18372
18373 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18374         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(o);
18375         jboolean ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
18376         return ret_conv;
18377 }
18378
18379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18380         if (!ptr_is_owned(_res)) return;
18381         void* _res_ptr = untag_ptr(_res);
18382         CHECK_ACCESS(_res_ptr);
18383         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
18384         FREE(untag_ptr(_res));
18385         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
18386 }
18387
18388 static inline uint64_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
18389         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
18390         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
18391         return tag_ptr(ret_conv, true);
18392 }
18393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18394         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(arg);
18395         int64_t ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
18396         return ret_conv;
18397 }
18398
18399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18400         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(orig);
18401         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
18402         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
18403         return tag_ptr(ret_conv, true);
18404 }
18405
18406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1some(JNIEnv *env, jclass clz, int64_t o) {
18407         void* o_ptr = untag_ptr(o);
18408         CHECK_ACCESS(o_ptr);
18409         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
18410         if (o_conv.free == LDKAccess_JCalls_free) {
18411                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18412                 LDKAccess_JCalls_cloned(&o_conv);
18413         }
18414         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
18415         *ret_copy = COption_AccessZ_some(o_conv);
18416         int64_t ret_ref = tag_ptr(ret_copy, true);
18417         return ret_ref;
18418 }
18419
18420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1none(JNIEnv *env, jclass clz) {
18421         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
18422         *ret_copy = COption_AccessZ_none();
18423         int64_t ret_ref = tag_ptr(ret_copy, true);
18424         return ret_ref;
18425 }
18426
18427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18428         if (!ptr_is_owned(_res)) return;
18429         void* _res_ptr = untag_ptr(_res);
18430         CHECK_ACCESS(_res_ptr);
18431         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
18432         FREE(untag_ptr(_res));
18433         COption_AccessZ_free(_res_conv);
18434 }
18435
18436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
18437         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
18438         *ret_conv = CResult_boolLightningErrorZ_ok(o);
18439         return tag_ptr(ret_conv, true);
18440 }
18441
18442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18443         LDKLightningError e_conv;
18444         e_conv.inner = untag_ptr(e);
18445         e_conv.is_owned = ptr_is_owned(e);
18446         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18447         e_conv = LightningError_clone(&e_conv);
18448         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
18449         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
18450         return tag_ptr(ret_conv, true);
18451 }
18452
18453 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18454         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(o);
18455         jboolean ret_conv = CResult_boolLightningErrorZ_is_ok(o_conv);
18456         return ret_conv;
18457 }
18458
18459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_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         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
18464         FREE(untag_ptr(_res));
18465         CResult_boolLightningErrorZ_free(_res_conv);
18466 }
18467
18468 static inline uint64_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
18469         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
18470         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
18471         return tag_ptr(ret_conv, true);
18472 }
18473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18474         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(arg);
18475         int64_t ret_conv = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
18476         return ret_conv;
18477 }
18478
18479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18480         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(orig);
18481         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
18482         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
18483         return tag_ptr(ret_conv, true);
18484 }
18485
18486 static inline uint64_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
18487         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
18488         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
18489         return tag_ptr(ret_conv, true);
18490 }
18491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18492         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(arg);
18493         int64_t ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
18494         return ret_conv;
18495 }
18496
18497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18498         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(orig);
18499         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
18500         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
18501         return tag_ptr(ret_conv, true);
18502 }
18503
18504 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) {
18505         LDKChannelAnnouncement a_conv;
18506         a_conv.inner = untag_ptr(a);
18507         a_conv.is_owned = ptr_is_owned(a);
18508         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18509         a_conv = ChannelAnnouncement_clone(&a_conv);
18510         LDKChannelUpdate b_conv;
18511         b_conv.inner = untag_ptr(b);
18512         b_conv.is_owned = ptr_is_owned(b);
18513         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
18514         b_conv = ChannelUpdate_clone(&b_conv);
18515         LDKChannelUpdate c_conv;
18516         c_conv.inner = untag_ptr(c);
18517         c_conv.is_owned = ptr_is_owned(c);
18518         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
18519         c_conv = ChannelUpdate_clone(&c_conv);
18520         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
18521         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
18522         return tag_ptr(ret_conv, true);
18523 }
18524
18525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18526         if (!ptr_is_owned(_res)) return;
18527         void* _res_ptr = untag_ptr(_res);
18528         CHECK_ACCESS(_res_ptr);
18529         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
18530         FREE(untag_ptr(_res));
18531         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
18532 }
18533
18534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
18535         void* o_ptr = untag_ptr(o);
18536         CHECK_ACCESS(o_ptr);
18537         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ o_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(o_ptr);
18538         o_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(o));
18539         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
18540         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_some(o_conv);
18541         int64_t ret_ref = tag_ptr(ret_copy, true);
18542         return ret_ref;
18543 }
18544
18545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1none(JNIEnv *env, jclass clz) {
18546         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
18547         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_none();
18548         int64_t ret_ref = tag_ptr(ret_copy, true);
18549         return ret_ref;
18550 }
18551
18552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18553         if (!ptr_is_owned(_res)) return;
18554         void* _res_ptr = untag_ptr(_res);
18555         CHECK_ACCESS(_res_ptr);
18556         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_conv = *(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)(_res_ptr);
18557         FREE(untag_ptr(_res));
18558         COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_conv);
18559 }
18560
18561 static inline uint64_t COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone_ptr(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *NONNULL_PTR arg) {
18562         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
18563         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(arg);
18564         int64_t ret_ref = tag_ptr(ret_copy, true);
18565         return ret_ref;
18566 }
18567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18568         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* arg_conv = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(arg);
18569         int64_t ret_conv = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone_ptr(arg_conv);
18570         return ret_conv;
18571 }
18572
18573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18574         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* orig_conv = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(orig);
18575         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
18576         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(orig_conv);
18577         int64_t ret_ref = tag_ptr(ret_copy, true);
18578         return ret_ref;
18579 }
18580
18581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
18582         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18583         *ret_conv = CResult_NoneLightningErrorZ_ok();
18584         return tag_ptr(ret_conv, true);
18585 }
18586
18587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18588         LDKLightningError e_conv;
18589         e_conv.inner = untag_ptr(e);
18590         e_conv.is_owned = ptr_is_owned(e);
18591         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18592         e_conv = LightningError_clone(&e_conv);
18593         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18594         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
18595         return tag_ptr(ret_conv, true);
18596 }
18597
18598 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18599         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(o);
18600         jboolean ret_conv = CResult_NoneLightningErrorZ_is_ok(o_conv);
18601         return ret_conv;
18602 }
18603
18604 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18605         if (!ptr_is_owned(_res)) return;
18606         void* _res_ptr = untag_ptr(_res);
18607         CHECK_ACCESS(_res_ptr);
18608         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
18609         FREE(untag_ptr(_res));
18610         CResult_NoneLightningErrorZ_free(_res_conv);
18611 }
18612
18613 static inline uint64_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
18614         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18615         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
18616         return tag_ptr(ret_conv, true);
18617 }
18618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18619         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(arg);
18620         int64_t ret_conv = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
18621         return ret_conv;
18622 }
18623
18624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18625         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(orig);
18626         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18627         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
18628         return tag_ptr(ret_conv, true);
18629 }
18630
18631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18632         LDKChannelUpdateInfo o_conv;
18633         o_conv.inner = untag_ptr(o);
18634         o_conv.is_owned = ptr_is_owned(o);
18635         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18636         o_conv = ChannelUpdateInfo_clone(&o_conv);
18637         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
18638         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
18639         return tag_ptr(ret_conv, true);
18640 }
18641
18642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18643         void* e_ptr = untag_ptr(e);
18644         CHECK_ACCESS(e_ptr);
18645         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18646         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18647         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
18648         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
18649         return tag_ptr(ret_conv, true);
18650 }
18651
18652 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18653         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(o);
18654         jboolean ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
18655         return ret_conv;
18656 }
18657
18658 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18659         if (!ptr_is_owned(_res)) return;
18660         void* _res_ptr = untag_ptr(_res);
18661         CHECK_ACCESS(_res_ptr);
18662         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
18663         FREE(untag_ptr(_res));
18664         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
18665 }
18666
18667 static inline uint64_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
18668         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
18669         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
18670         return tag_ptr(ret_conv, true);
18671 }
18672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18673         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(arg);
18674         int64_t ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
18675         return ret_conv;
18676 }
18677
18678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18679         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(orig);
18680         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
18681         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
18682         return tag_ptr(ret_conv, true);
18683 }
18684
18685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18686         LDKChannelInfo o_conv;
18687         o_conv.inner = untag_ptr(o);
18688         o_conv.is_owned = ptr_is_owned(o);
18689         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18690         o_conv = ChannelInfo_clone(&o_conv);
18691         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
18692         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
18693         return tag_ptr(ret_conv, true);
18694 }
18695
18696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18697         void* e_ptr = untag_ptr(e);
18698         CHECK_ACCESS(e_ptr);
18699         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18700         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18701         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
18702         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
18703         return tag_ptr(ret_conv, true);
18704 }
18705
18706 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18707         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(o);
18708         jboolean ret_conv = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
18709         return ret_conv;
18710 }
18711
18712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18713         if (!ptr_is_owned(_res)) return;
18714         void* _res_ptr = untag_ptr(_res);
18715         CHECK_ACCESS(_res_ptr);
18716         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
18717         FREE(untag_ptr(_res));
18718         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
18719 }
18720
18721 static inline uint64_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
18722         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
18723         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
18724         return tag_ptr(ret_conv, true);
18725 }
18726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18727         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(arg);
18728         int64_t ret_conv = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
18729         return ret_conv;
18730 }
18731
18732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18733         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(orig);
18734         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
18735         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
18736         return tag_ptr(ret_conv, true);
18737 }
18738
18739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18740         LDKRoutingFees o_conv;
18741         o_conv.inner = untag_ptr(o);
18742         o_conv.is_owned = ptr_is_owned(o);
18743         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18744         o_conv = RoutingFees_clone(&o_conv);
18745         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
18746         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
18747         return tag_ptr(ret_conv, true);
18748 }
18749
18750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18751         void* e_ptr = untag_ptr(e);
18752         CHECK_ACCESS(e_ptr);
18753         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18754         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18755         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
18756         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
18757         return tag_ptr(ret_conv, true);
18758 }
18759
18760 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18761         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(o);
18762         jboolean ret_conv = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
18763         return ret_conv;
18764 }
18765
18766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18767         if (!ptr_is_owned(_res)) return;
18768         void* _res_ptr = untag_ptr(_res);
18769         CHECK_ACCESS(_res_ptr);
18770         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
18771         FREE(untag_ptr(_res));
18772         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
18773 }
18774
18775 static inline uint64_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
18776         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
18777         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
18778         return tag_ptr(ret_conv, true);
18779 }
18780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18781         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(arg);
18782         int64_t ret_conv = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
18783         return ret_conv;
18784 }
18785
18786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18787         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(orig);
18788         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
18789         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
18790         return tag_ptr(ret_conv, true);
18791 }
18792
18793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18794         LDKCVec_NetAddressZ _res_constr;
18795         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18796         if (_res_constr.datalen > 0)
18797                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
18798         else
18799                 _res_constr.data = NULL;
18800         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18801         for (size_t m = 0; m < _res_constr.datalen; m++) {
18802                 int64_t _res_conv_12 = _res_vals[m];
18803                 void* _res_conv_12_ptr = untag_ptr(_res_conv_12);
18804                 CHECK_ACCESS(_res_conv_12_ptr);
18805                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
18806                 FREE(untag_ptr(_res_conv_12));
18807                 _res_constr.data[m] = _res_conv_12_conv;
18808         }
18809         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18810         CVec_NetAddressZ_free(_res_constr);
18811 }
18812
18813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18814         LDKNodeAnnouncementInfo o_conv;
18815         o_conv.inner = untag_ptr(o);
18816         o_conv.is_owned = ptr_is_owned(o);
18817         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18818         o_conv = NodeAnnouncementInfo_clone(&o_conv);
18819         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
18820         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
18821         return tag_ptr(ret_conv, true);
18822 }
18823
18824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18825         void* e_ptr = untag_ptr(e);
18826         CHECK_ACCESS(e_ptr);
18827         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18828         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18829         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
18830         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
18831         return tag_ptr(ret_conv, true);
18832 }
18833
18834 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18835         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(o);
18836         jboolean ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
18837         return ret_conv;
18838 }
18839
18840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18841         if (!ptr_is_owned(_res)) return;
18842         void* _res_ptr = untag_ptr(_res);
18843         CHECK_ACCESS(_res_ptr);
18844         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
18845         FREE(untag_ptr(_res));
18846         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
18847 }
18848
18849 static inline uint64_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
18850         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
18851         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
18852         return tag_ptr(ret_conv, true);
18853 }
18854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18855         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(arg);
18856         int64_t ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
18857         return ret_conv;
18858 }
18859
18860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18861         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(orig);
18862         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
18863         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
18864         return tag_ptr(ret_conv, true);
18865 }
18866
18867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18868         LDKNodeAlias o_conv;
18869         o_conv.inner = untag_ptr(o);
18870         o_conv.is_owned = ptr_is_owned(o);
18871         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18872         o_conv = NodeAlias_clone(&o_conv);
18873         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
18874         *ret_conv = CResult_NodeAliasDecodeErrorZ_ok(o_conv);
18875         return tag_ptr(ret_conv, true);
18876 }
18877
18878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18879         void* e_ptr = untag_ptr(e);
18880         CHECK_ACCESS(e_ptr);
18881         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18882         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18883         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
18884         *ret_conv = CResult_NodeAliasDecodeErrorZ_err(e_conv);
18885         return tag_ptr(ret_conv, true);
18886 }
18887
18888 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18889         LDKCResult_NodeAliasDecodeErrorZ* o_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(o);
18890         jboolean ret_conv = CResult_NodeAliasDecodeErrorZ_is_ok(o_conv);
18891         return ret_conv;
18892 }
18893
18894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18895         if (!ptr_is_owned(_res)) return;
18896         void* _res_ptr = untag_ptr(_res);
18897         CHECK_ACCESS(_res_ptr);
18898         LDKCResult_NodeAliasDecodeErrorZ _res_conv = *(LDKCResult_NodeAliasDecodeErrorZ*)(_res_ptr);
18899         FREE(untag_ptr(_res));
18900         CResult_NodeAliasDecodeErrorZ_free(_res_conv);
18901 }
18902
18903 static inline uint64_t CResult_NodeAliasDecodeErrorZ_clone_ptr(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR arg) {
18904         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
18905         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(arg);
18906         return tag_ptr(ret_conv, true);
18907 }
18908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18909         LDKCResult_NodeAliasDecodeErrorZ* arg_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(arg);
18910         int64_t ret_conv = CResult_NodeAliasDecodeErrorZ_clone_ptr(arg_conv);
18911         return ret_conv;
18912 }
18913
18914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18915         LDKCResult_NodeAliasDecodeErrorZ* orig_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(orig);
18916         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
18917         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(orig_conv);
18918         return tag_ptr(ret_conv, true);
18919 }
18920
18921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18922         LDKNodeInfo o_conv;
18923         o_conv.inner = untag_ptr(o);
18924         o_conv.is_owned = ptr_is_owned(o);
18925         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18926         o_conv = NodeInfo_clone(&o_conv);
18927         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
18928         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
18929         return tag_ptr(ret_conv, true);
18930 }
18931
18932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18933         void* e_ptr = untag_ptr(e);
18934         CHECK_ACCESS(e_ptr);
18935         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18936         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18937         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
18938         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
18939         return tag_ptr(ret_conv, true);
18940 }
18941
18942 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18943         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(o);
18944         jboolean ret_conv = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
18945         return ret_conv;
18946 }
18947
18948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18949         if (!ptr_is_owned(_res)) return;
18950         void* _res_ptr = untag_ptr(_res);
18951         CHECK_ACCESS(_res_ptr);
18952         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
18953         FREE(untag_ptr(_res));
18954         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
18955 }
18956
18957 static inline uint64_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
18958         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
18959         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
18960         return tag_ptr(ret_conv, true);
18961 }
18962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18963         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(arg);
18964         int64_t ret_conv = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
18965         return ret_conv;
18966 }
18967
18968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18969         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(orig);
18970         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
18971         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
18972         return tag_ptr(ret_conv, true);
18973 }
18974
18975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18976         LDKNetworkGraph o_conv;
18977         o_conv.inner = untag_ptr(o);
18978         o_conv.is_owned = ptr_is_owned(o);
18979         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18980         // WARNING: we need a move here but no clone is available for LDKNetworkGraph
18981         
18982         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
18983         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
18984         return tag_ptr(ret_conv, true);
18985 }
18986
18987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18988         void* e_ptr = untag_ptr(e);
18989         CHECK_ACCESS(e_ptr);
18990         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18991         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18992         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
18993         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
18994         return tag_ptr(ret_conv, true);
18995 }
18996
18997 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18998         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(o);
18999         jboolean ret_conv = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
19000         return ret_conv;
19001 }
19002
19003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19004         if (!ptr_is_owned(_res)) return;
19005         void* _res_ptr = untag_ptr(_res);
19006         CHECK_ACCESS(_res_ptr);
19007         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
19008         FREE(untag_ptr(_res));
19009         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
19010 }
19011
19012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1some(JNIEnv *env, jclass clz, int64_tArray o) {
19013         LDKCVec_NetAddressZ o_constr;
19014         o_constr.datalen = (*env)->GetArrayLength(env, o);
19015         if (o_constr.datalen > 0)
19016                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
19017         else
19018                 o_constr.data = NULL;
19019         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
19020         for (size_t m = 0; m < o_constr.datalen; m++) {
19021                 int64_t o_conv_12 = o_vals[m];
19022                 void* o_conv_12_ptr = untag_ptr(o_conv_12);
19023                 CHECK_ACCESS(o_conv_12_ptr);
19024                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
19025                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o_conv_12));
19026                 o_constr.data[m] = o_conv_12_conv;
19027         }
19028         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
19029         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
19030         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
19031         int64_t ret_ref = tag_ptr(ret_copy, true);
19032         return ret_ref;
19033 }
19034
19035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1none(JNIEnv *env, jclass clz) {
19036         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
19037         *ret_copy = COption_CVec_NetAddressZZ_none();
19038         int64_t ret_ref = tag_ptr(ret_copy, true);
19039         return ret_ref;
19040 }
19041
19042 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19043         if (!ptr_is_owned(_res)) return;
19044         void* _res_ptr = untag_ptr(_res);
19045         CHECK_ACCESS(_res_ptr);
19046         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
19047         FREE(untag_ptr(_res));
19048         COption_CVec_NetAddressZZ_free(_res_conv);
19049 }
19050
19051 static inline uint64_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
19052         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
19053         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
19054         int64_t ret_ref = tag_ptr(ret_copy, true);
19055         return ret_ref;
19056 }
19057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19058         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)untag_ptr(arg);
19059         int64_t ret_conv = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
19060         return ret_conv;
19061 }
19062
19063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19064         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)untag_ptr(orig);
19065         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
19066         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
19067         int64_t ret_ref = tag_ptr(ret_copy, true);
19068         return ret_ref;
19069 }
19070
19071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19072         LDKDelayedPaymentOutputDescriptor o_conv;
19073         o_conv.inner = untag_ptr(o);
19074         o_conv.is_owned = ptr_is_owned(o);
19075         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19076         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
19077         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
19078         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
19079         return tag_ptr(ret_conv, true);
19080 }
19081
19082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19083         void* e_ptr = untag_ptr(e);
19084         CHECK_ACCESS(e_ptr);
19085         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19086         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19087         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
19088         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
19089         return tag_ptr(ret_conv, true);
19090 }
19091
19092 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19093         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(o);
19094         jboolean ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
19095         return ret_conv;
19096 }
19097
19098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19099         if (!ptr_is_owned(_res)) return;
19100         void* _res_ptr = untag_ptr(_res);
19101         CHECK_ACCESS(_res_ptr);
19102         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
19103         FREE(untag_ptr(_res));
19104         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
19105 }
19106
19107 static inline uint64_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
19108         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
19109         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
19110         return tag_ptr(ret_conv, true);
19111 }
19112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19113         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
19114         int64_t ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
19115         return ret_conv;
19116 }
19117
19118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19119         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
19120         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
19121         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
19122         return tag_ptr(ret_conv, true);
19123 }
19124
19125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19126         LDKStaticPaymentOutputDescriptor o_conv;
19127         o_conv.inner = untag_ptr(o);
19128         o_conv.is_owned = ptr_is_owned(o);
19129         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19130         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
19131         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
19132         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
19133         return tag_ptr(ret_conv, true);
19134 }
19135
19136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19137         void* e_ptr = untag_ptr(e);
19138         CHECK_ACCESS(e_ptr);
19139         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19140         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19141         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
19142         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
19143         return tag_ptr(ret_conv, true);
19144 }
19145
19146 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19147         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(o);
19148         jboolean ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
19149         return ret_conv;
19150 }
19151
19152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19153         if (!ptr_is_owned(_res)) return;
19154         void* _res_ptr = untag_ptr(_res);
19155         CHECK_ACCESS(_res_ptr);
19156         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
19157         FREE(untag_ptr(_res));
19158         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
19159 }
19160
19161 static inline uint64_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
19162         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
19163         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
19164         return tag_ptr(ret_conv, true);
19165 }
19166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19167         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
19168         int64_t ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
19169         return ret_conv;
19170 }
19171
19172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19173         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
19174         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
19175         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
19176         return tag_ptr(ret_conv, true);
19177 }
19178
19179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19180         void* o_ptr = untag_ptr(o);
19181         CHECK_ACCESS(o_ptr);
19182         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
19183         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(o));
19184         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
19185         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
19186         return tag_ptr(ret_conv, true);
19187 }
19188
19189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19190         void* e_ptr = untag_ptr(e);
19191         CHECK_ACCESS(e_ptr);
19192         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19193         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19194         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
19195         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
19196         return tag_ptr(ret_conv, true);
19197 }
19198
19199 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19200         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(o);
19201         jboolean ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
19202         return ret_conv;
19203 }
19204
19205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19206         if (!ptr_is_owned(_res)) return;
19207         void* _res_ptr = untag_ptr(_res);
19208         CHECK_ACCESS(_res_ptr);
19209         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
19210         FREE(untag_ptr(_res));
19211         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
19212 }
19213
19214 static inline uint64_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
19215         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
19216         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
19217         return tag_ptr(ret_conv, true);
19218 }
19219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19220         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
19221         int64_t ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
19222         return ret_conv;
19223 }
19224
19225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19226         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
19227         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
19228         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
19229         return tag_ptr(ret_conv, true);
19230 }
19231
19232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PaymentPreimageZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
19233         LDKCVec_PaymentPreimageZ _res_constr;
19234         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19235         if (_res_constr.datalen > 0)
19236                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
19237         else
19238                 _res_constr.data = NULL;
19239         for (size_t i = 0; i < _res_constr.datalen; i++) {
19240                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
19241                 LDKThirtyTwoBytes _res_conv_8_ref;
19242                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
19243                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
19244                 _res_constr.data[i] = _res_conv_8_ref;
19245         }
19246         CVec_PaymentPreimageZ_free(_res_constr);
19247 }
19248
19249 static inline uint64_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
19250         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
19251         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
19252         return tag_ptr(ret_conv, true);
19253 }
19254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19255         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(arg);
19256         int64_t ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
19257         return ret_conv;
19258 }
19259
19260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19261         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(orig);
19262         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
19263         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
19264         return tag_ptr(ret_conv, true);
19265 }
19266
19267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
19268         LDKSignature a_ref;
19269         CHECK((*env)->GetArrayLength(env, a) == 64);
19270         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
19271         LDKCVec_SignatureZ b_constr;
19272         b_constr.datalen = (*env)->GetArrayLength(env, b);
19273         if (b_constr.datalen > 0)
19274                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
19275         else
19276                 b_constr.data = NULL;
19277         for (size_t i = 0; i < b_constr.datalen; i++) {
19278                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
19279                 LDKSignature b_conv_8_ref;
19280                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
19281                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
19282                 b_constr.data[i] = b_conv_8_ref;
19283         }
19284         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
19285         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
19286         return tag_ptr(ret_conv, true);
19287 }
19288
19289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19290         if (!ptr_is_owned(_res)) return;
19291         void* _res_ptr = untag_ptr(_res);
19292         CHECK_ACCESS(_res_ptr);
19293         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
19294         FREE(untag_ptr(_res));
19295         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
19296 }
19297
19298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19299         void* o_ptr = untag_ptr(o);
19300         CHECK_ACCESS(o_ptr);
19301         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
19302         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(o));
19303         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
19304         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
19305         return tag_ptr(ret_conv, true);
19306 }
19307
19308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
19309         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
19310         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
19311         return tag_ptr(ret_conv, true);
19312 }
19313
19314 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19315         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(o);
19316         jboolean ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
19317         return ret_conv;
19318 }
19319
19320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19321         if (!ptr_is_owned(_res)) return;
19322         void* _res_ptr = untag_ptr(_res);
19323         CHECK_ACCESS(_res_ptr);
19324         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
19325         FREE(untag_ptr(_res));
19326         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
19327 }
19328
19329 static inline uint64_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
19330         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
19331         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
19332         return tag_ptr(ret_conv, true);
19333 }
19334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19335         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(arg);
19336         int64_t ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
19337         return ret_conv;
19338 }
19339
19340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19341         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(orig);
19342         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
19343         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
19344         return tag_ptr(ret_conv, true);
19345 }
19346
19347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19348         LDKSignature o_ref;
19349         CHECK((*env)->GetArrayLength(env, o) == 64);
19350         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
19351         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
19352         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
19353         return tag_ptr(ret_conv, true);
19354 }
19355
19356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
19357         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
19358         *ret_conv = CResult_SignatureNoneZ_err();
19359         return tag_ptr(ret_conv, true);
19360 }
19361
19362 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19363         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(o);
19364         jboolean ret_conv = CResult_SignatureNoneZ_is_ok(o_conv);
19365         return ret_conv;
19366 }
19367
19368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19369         if (!ptr_is_owned(_res)) return;
19370         void* _res_ptr = untag_ptr(_res);
19371         CHECK_ACCESS(_res_ptr);
19372         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
19373         FREE(untag_ptr(_res));
19374         CResult_SignatureNoneZ_free(_res_conv);
19375 }
19376
19377 static inline uint64_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
19378         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
19379         *ret_conv = CResult_SignatureNoneZ_clone(arg);
19380         return tag_ptr(ret_conv, true);
19381 }
19382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19383         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(arg);
19384         int64_t ret_conv = CResult_SignatureNoneZ_clone_ptr(arg_conv);
19385         return ret_conv;
19386 }
19387
19388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19389         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(orig);
19390         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
19391         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
19392         return tag_ptr(ret_conv, true);
19393 }
19394
19395 static inline uint64_t C2Tuple_SignatureSignatureZ_clone_ptr(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR arg) {
19396         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
19397         *ret_conv = C2Tuple_SignatureSignatureZ_clone(arg);
19398         return tag_ptr(ret_conv, true);
19399 }
19400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19401         LDKC2Tuple_SignatureSignatureZ* arg_conv = (LDKC2Tuple_SignatureSignatureZ*)untag_ptr(arg);
19402         int64_t ret_conv = C2Tuple_SignatureSignatureZ_clone_ptr(arg_conv);
19403         return ret_conv;
19404 }
19405
19406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19407         LDKC2Tuple_SignatureSignatureZ* orig_conv = (LDKC2Tuple_SignatureSignatureZ*)untag_ptr(orig);
19408         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
19409         *ret_conv = C2Tuple_SignatureSignatureZ_clone(orig_conv);
19410         return tag_ptr(ret_conv, true);
19411 }
19412
19413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
19414         LDKSignature a_ref;
19415         CHECK((*env)->GetArrayLength(env, a) == 64);
19416         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
19417         LDKSignature b_ref;
19418         CHECK((*env)->GetArrayLength(env, b) == 64);
19419         (*env)->GetByteArrayRegion(env, b, 0, 64, b_ref.compact_form);
19420         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
19421         *ret_conv = C2Tuple_SignatureSignatureZ_new(a_ref, b_ref);
19422         return tag_ptr(ret_conv, true);
19423 }
19424
19425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19426         if (!ptr_is_owned(_res)) return;
19427         void* _res_ptr = untag_ptr(_res);
19428         CHECK_ACCESS(_res_ptr);
19429         LDKC2Tuple_SignatureSignatureZ _res_conv = *(LDKC2Tuple_SignatureSignatureZ*)(_res_ptr);
19430         FREE(untag_ptr(_res));
19431         C2Tuple_SignatureSignatureZ_free(_res_conv);
19432 }
19433
19434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19435         void* o_ptr = untag_ptr(o);
19436         CHECK_ACCESS(o_ptr);
19437         LDKC2Tuple_SignatureSignatureZ o_conv = *(LDKC2Tuple_SignatureSignatureZ*)(o_ptr);
19438         o_conv = C2Tuple_SignatureSignatureZ_clone((LDKC2Tuple_SignatureSignatureZ*)untag_ptr(o));
19439         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
19440         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o_conv);
19441         return tag_ptr(ret_conv, true);
19442 }
19443
19444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
19445         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
19446         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_err();
19447         return tag_ptr(ret_conv, true);
19448 }
19449
19450 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19451         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(o);
19452         jboolean ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o_conv);
19453         return ret_conv;
19454 }
19455
19456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19457         if (!ptr_is_owned(_res)) return;
19458         void* _res_ptr = untag_ptr(_res);
19459         CHECK_ACCESS(_res_ptr);
19460         LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(_res_ptr);
19461         FREE(untag_ptr(_res));
19462         CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res_conv);
19463 }
19464
19465 static inline uint64_t CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR arg) {
19466         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
19467         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(arg);
19468         return tag_ptr(ret_conv, true);
19469 }
19470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19471         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(arg);
19472         int64_t ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(arg_conv);
19473         return ret_conv;
19474 }
19475
19476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19477         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(orig);
19478         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
19479         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig_conv);
19480         return tag_ptr(ret_conv, true);
19481 }
19482
19483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19484         LDKSecretKey o_ref;
19485         CHECK((*env)->GetArrayLength(env, o) == 32);
19486         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
19487         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
19488         *ret_conv = CResult_SecretKeyNoneZ_ok(o_ref);
19489         return tag_ptr(ret_conv, true);
19490 }
19491
19492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1err(JNIEnv *env, jclass clz) {
19493         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
19494         *ret_conv = CResult_SecretKeyNoneZ_err();
19495         return tag_ptr(ret_conv, true);
19496 }
19497
19498 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19499         LDKCResult_SecretKeyNoneZ* o_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(o);
19500         jboolean ret_conv = CResult_SecretKeyNoneZ_is_ok(o_conv);
19501         return ret_conv;
19502 }
19503
19504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19505         if (!ptr_is_owned(_res)) return;
19506         void* _res_ptr = untag_ptr(_res);
19507         CHECK_ACCESS(_res_ptr);
19508         LDKCResult_SecretKeyNoneZ _res_conv = *(LDKCResult_SecretKeyNoneZ*)(_res_ptr);
19509         FREE(untag_ptr(_res));
19510         CResult_SecretKeyNoneZ_free(_res_conv);
19511 }
19512
19513 static inline uint64_t CResult_SecretKeyNoneZ_clone_ptr(LDKCResult_SecretKeyNoneZ *NONNULL_PTR arg) {
19514         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
19515         *ret_conv = CResult_SecretKeyNoneZ_clone(arg);
19516         return tag_ptr(ret_conv, true);
19517 }
19518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19519         LDKCResult_SecretKeyNoneZ* arg_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(arg);
19520         int64_t ret_conv = CResult_SecretKeyNoneZ_clone_ptr(arg_conv);
19521         return ret_conv;
19522 }
19523
19524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19525         LDKCResult_SecretKeyNoneZ* orig_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(orig);
19526         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
19527         *ret_conv = CResult_SecretKeyNoneZ_clone(orig_conv);
19528         return tag_ptr(ret_conv, true);
19529 }
19530
19531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19532         LDKPublicKey o_ref;
19533         CHECK((*env)->GetArrayLength(env, o) == 33);
19534         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
19535         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
19536         *ret_conv = CResult_PublicKeyNoneZ_ok(o_ref);
19537         return tag_ptr(ret_conv, true);
19538 }
19539
19540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1err(JNIEnv *env, jclass clz) {
19541         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
19542         *ret_conv = CResult_PublicKeyNoneZ_err();
19543         return tag_ptr(ret_conv, true);
19544 }
19545
19546 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19547         LDKCResult_PublicKeyNoneZ* o_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(o);
19548         jboolean ret_conv = CResult_PublicKeyNoneZ_is_ok(o_conv);
19549         return ret_conv;
19550 }
19551
19552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19553         if (!ptr_is_owned(_res)) return;
19554         void* _res_ptr = untag_ptr(_res);
19555         CHECK_ACCESS(_res_ptr);
19556         LDKCResult_PublicKeyNoneZ _res_conv = *(LDKCResult_PublicKeyNoneZ*)(_res_ptr);
19557         FREE(untag_ptr(_res));
19558         CResult_PublicKeyNoneZ_free(_res_conv);
19559 }
19560
19561 static inline uint64_t CResult_PublicKeyNoneZ_clone_ptr(LDKCResult_PublicKeyNoneZ *NONNULL_PTR arg) {
19562         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
19563         *ret_conv = CResult_PublicKeyNoneZ_clone(arg);
19564         return tag_ptr(ret_conv, true);
19565 }
19566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19567         LDKCResult_PublicKeyNoneZ* arg_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(arg);
19568         int64_t ret_conv = CResult_PublicKeyNoneZ_clone_ptr(arg_conv);
19569         return ret_conv;
19570 }
19571
19572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19573         LDKCResult_PublicKeyNoneZ* orig_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(orig);
19574         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
19575         *ret_conv = CResult_PublicKeyNoneZ_clone(orig_conv);
19576         return tag_ptr(ret_conv, true);
19577 }
19578
19579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ScalarZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19580         void* o_ptr = untag_ptr(o);
19581         CHECK_ACCESS(o_ptr);
19582         LDKBigEndianScalar o_conv = *(LDKBigEndianScalar*)(o_ptr);
19583         // WARNING: we may need a move here but no clone is available for LDKBigEndianScalar
19584         LDKCOption_ScalarZ *ret_copy = MALLOC(sizeof(LDKCOption_ScalarZ), "LDKCOption_ScalarZ");
19585         *ret_copy = COption_ScalarZ_some(o_conv);
19586         int64_t ret_ref = tag_ptr(ret_copy, true);
19587         return ret_ref;
19588 }
19589
19590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ScalarZ_1none(JNIEnv *env, jclass clz) {
19591         LDKCOption_ScalarZ *ret_copy = MALLOC(sizeof(LDKCOption_ScalarZ), "LDKCOption_ScalarZ");
19592         *ret_copy = COption_ScalarZ_none();
19593         int64_t ret_ref = tag_ptr(ret_copy, true);
19594         return ret_ref;
19595 }
19596
19597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ScalarZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19598         if (!ptr_is_owned(_res)) return;
19599         void* _res_ptr = untag_ptr(_res);
19600         CHECK_ACCESS(_res_ptr);
19601         LDKCOption_ScalarZ _res_conv = *(LDKCOption_ScalarZ*)(_res_ptr);
19602         FREE(untag_ptr(_res));
19603         COption_ScalarZ_free(_res_conv);
19604 }
19605
19606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19607         LDKThirtyTwoBytes o_ref;
19608         CHECK((*env)->GetArrayLength(env, o) == 32);
19609         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
19610         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
19611         *ret_conv = CResult_SharedSecretNoneZ_ok(o_ref);
19612         return tag_ptr(ret_conv, true);
19613 }
19614
19615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1err(JNIEnv *env, jclass clz) {
19616         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
19617         *ret_conv = CResult_SharedSecretNoneZ_err();
19618         return tag_ptr(ret_conv, true);
19619 }
19620
19621 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19622         LDKCResult_SharedSecretNoneZ* o_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(o);
19623         jboolean ret_conv = CResult_SharedSecretNoneZ_is_ok(o_conv);
19624         return ret_conv;
19625 }
19626
19627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19628         if (!ptr_is_owned(_res)) return;
19629         void* _res_ptr = untag_ptr(_res);
19630         CHECK_ACCESS(_res_ptr);
19631         LDKCResult_SharedSecretNoneZ _res_conv = *(LDKCResult_SharedSecretNoneZ*)(_res_ptr);
19632         FREE(untag_ptr(_res));
19633         CResult_SharedSecretNoneZ_free(_res_conv);
19634 }
19635
19636 static inline uint64_t CResult_SharedSecretNoneZ_clone_ptr(LDKCResult_SharedSecretNoneZ *NONNULL_PTR arg) {
19637         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
19638         *ret_conv = CResult_SharedSecretNoneZ_clone(arg);
19639         return tag_ptr(ret_conv, true);
19640 }
19641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19642         LDKCResult_SharedSecretNoneZ* arg_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(arg);
19643         int64_t ret_conv = CResult_SharedSecretNoneZ_clone_ptr(arg_conv);
19644         return ret_conv;
19645 }
19646
19647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19648         LDKCResult_SharedSecretNoneZ* orig_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(orig);
19649         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
19650         *ret_conv = CResult_SharedSecretNoneZ_clone(orig_conv);
19651         return tag_ptr(ret_conv, true);
19652 }
19653
19654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19655         void* o_ptr = untag_ptr(o);
19656         CHECK_ACCESS(o_ptr);
19657         LDKSign o_conv = *(LDKSign*)(o_ptr);
19658         if (o_conv.free == LDKSign_JCalls_free) {
19659                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19660                 LDKSign_JCalls_cloned(&o_conv);
19661         }
19662         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
19663         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
19664         return tag_ptr(ret_conv, true);
19665 }
19666
19667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19668         void* e_ptr = untag_ptr(e);
19669         CHECK_ACCESS(e_ptr);
19670         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19671         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19672         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
19673         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
19674         return tag_ptr(ret_conv, true);
19675 }
19676
19677 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19678         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(o);
19679         jboolean ret_conv = CResult_SignDecodeErrorZ_is_ok(o_conv);
19680         return ret_conv;
19681 }
19682
19683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19684         if (!ptr_is_owned(_res)) return;
19685         void* _res_ptr = untag_ptr(_res);
19686         CHECK_ACCESS(_res_ptr);
19687         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
19688         FREE(untag_ptr(_res));
19689         CResult_SignDecodeErrorZ_free(_res_conv);
19690 }
19691
19692 static inline uint64_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
19693         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
19694         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
19695         return tag_ptr(ret_conv, true);
19696 }
19697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19698         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(arg);
19699         int64_t ret_conv = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
19700         return ret_conv;
19701 }
19702
19703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19704         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(orig);
19705         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
19706         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
19707         return tag_ptr(ret_conv, true);
19708 }
19709
19710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u5Z_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
19711         LDKCVec_u5Z _res_constr;
19712         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19713         if (_res_constr.datalen > 0)
19714                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
19715         else
19716                 _res_constr.data = NULL;
19717         int8_t* _res_vals = (*env)->GetByteArrayElements (env, _res, NULL);
19718         for (size_t h = 0; h < _res_constr.datalen; h++) {
19719                 int8_t _res_conv_7 = _res_vals[h];
19720                 
19721                 _res_constr.data[h] = (LDKu5){ ._0 = _res_conv_7 };
19722         }
19723         (*env)->ReleaseByteArrayElements(env, _res, _res_vals, 0);
19724         CVec_u5Z_free(_res_constr);
19725 }
19726
19727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19728         LDKRecoverableSignature o_ref;
19729         CHECK((*env)->GetArrayLength(env, o) == 68);
19730         (*env)->GetByteArrayRegion(env, o, 0, 68, o_ref.serialized_form);
19731         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
19732         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
19733         return tag_ptr(ret_conv, true);
19734 }
19735
19736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
19737         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
19738         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
19739         return tag_ptr(ret_conv, true);
19740 }
19741
19742 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19743         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(o);
19744         jboolean ret_conv = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
19745         return ret_conv;
19746 }
19747
19748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19749         if (!ptr_is_owned(_res)) return;
19750         void* _res_ptr = untag_ptr(_res);
19751         CHECK_ACCESS(_res_ptr);
19752         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
19753         FREE(untag_ptr(_res));
19754         CResult_RecoverableSignatureNoneZ_free(_res_conv);
19755 }
19756
19757 static inline uint64_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
19758         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
19759         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
19760         return tag_ptr(ret_conv, true);
19761 }
19762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19763         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(arg);
19764         int64_t ret_conv = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
19765         return ret_conv;
19766 }
19767
19768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19769         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(orig);
19770         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
19771         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
19772         return tag_ptr(ret_conv, true);
19773 }
19774
19775 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
19776         LDKCVec_u8Z _res_ref;
19777         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
19778         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
19779         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
19780         CVec_u8Z_free(_res_ref);
19781 }
19782
19783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
19784         LDKCVec_CVec_u8ZZ _res_constr;
19785         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19786         if (_res_constr.datalen > 0)
19787                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
19788         else
19789                 _res_constr.data = NULL;
19790         for (size_t i = 0; i < _res_constr.datalen; i++) {
19791                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
19792                 LDKCVec_u8Z _res_conv_8_ref;
19793                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
19794                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
19795                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
19796                 _res_constr.data[i] = _res_conv_8_ref;
19797         }
19798         CVec_CVec_u8ZZ_free(_res_constr);
19799 }
19800
19801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
19802         LDKCVec_CVec_u8ZZ o_constr;
19803         o_constr.datalen = (*env)->GetArrayLength(env, o);
19804         if (o_constr.datalen > 0)
19805                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
19806         else
19807                 o_constr.data = NULL;
19808         for (size_t i = 0; i < o_constr.datalen; i++) {
19809                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
19810                 LDKCVec_u8Z o_conv_8_ref;
19811                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
19812                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
19813                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
19814                 o_constr.data[i] = o_conv_8_ref;
19815         }
19816         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
19817         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
19818         return tag_ptr(ret_conv, true);
19819 }
19820
19821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
19822         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
19823         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
19824         return tag_ptr(ret_conv, true);
19825 }
19826
19827 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19828         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(o);
19829         jboolean ret_conv = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
19830         return ret_conv;
19831 }
19832
19833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19834         if (!ptr_is_owned(_res)) return;
19835         void* _res_ptr = untag_ptr(_res);
19836         CHECK_ACCESS(_res_ptr);
19837         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
19838         FREE(untag_ptr(_res));
19839         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
19840 }
19841
19842 static inline uint64_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
19843         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
19844         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
19845         return tag_ptr(ret_conv, true);
19846 }
19847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19848         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(arg);
19849         int64_t ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
19850         return ret_conv;
19851 }
19852
19853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19854         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(orig);
19855         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
19856         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
19857         return tag_ptr(ret_conv, true);
19858 }
19859
19860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19861         LDKInMemorySigner o_conv;
19862         o_conv.inner = untag_ptr(o);
19863         o_conv.is_owned = ptr_is_owned(o);
19864         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19865         o_conv = InMemorySigner_clone(&o_conv);
19866         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
19867         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
19868         return tag_ptr(ret_conv, true);
19869 }
19870
19871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19872         void* e_ptr = untag_ptr(e);
19873         CHECK_ACCESS(e_ptr);
19874         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19875         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19876         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
19877         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
19878         return tag_ptr(ret_conv, true);
19879 }
19880
19881 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19882         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(o);
19883         jboolean ret_conv = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
19884         return ret_conv;
19885 }
19886
19887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19888         if (!ptr_is_owned(_res)) return;
19889         void* _res_ptr = untag_ptr(_res);
19890         CHECK_ACCESS(_res_ptr);
19891         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
19892         FREE(untag_ptr(_res));
19893         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
19894 }
19895
19896 static inline uint64_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
19897         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
19898         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
19899         return tag_ptr(ret_conv, true);
19900 }
19901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19902         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(arg);
19903         int64_t ret_conv = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
19904         return ret_conv;
19905 }
19906
19907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19908         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(orig);
19909         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
19910         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
19911         return tag_ptr(ret_conv, true);
19912 }
19913
19914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19915         LDKCVec_TxOutZ _res_constr;
19916         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19917         if (_res_constr.datalen > 0)
19918                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
19919         else
19920                 _res_constr.data = NULL;
19921         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19922         for (size_t h = 0; h < _res_constr.datalen; h++) {
19923                 int64_t _res_conv_7 = _res_vals[h];
19924                 void* _res_conv_7_ptr = untag_ptr(_res_conv_7);
19925                 CHECK_ACCESS(_res_conv_7_ptr);
19926                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
19927                 FREE(untag_ptr(_res_conv_7));
19928                 _res_constr.data[h] = _res_conv_7_conv;
19929         }
19930         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19931         CVec_TxOutZ_free(_res_constr);
19932 }
19933
19934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19935         LDKTransaction o_ref;
19936         o_ref.datalen = (*env)->GetArrayLength(env, o);
19937         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
19938         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
19939         o_ref.data_is_owned = true;
19940         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
19941         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
19942         return tag_ptr(ret_conv, true);
19943 }
19944
19945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
19946         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
19947         *ret_conv = CResult_TransactionNoneZ_err();
19948         return tag_ptr(ret_conv, true);
19949 }
19950
19951 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19952         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(o);
19953         jboolean ret_conv = CResult_TransactionNoneZ_is_ok(o_conv);
19954         return ret_conv;
19955 }
19956
19957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19958         if (!ptr_is_owned(_res)) return;
19959         void* _res_ptr = untag_ptr(_res);
19960         CHECK_ACCESS(_res_ptr);
19961         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
19962         FREE(untag_ptr(_res));
19963         CResult_TransactionNoneZ_free(_res_conv);
19964 }
19965
19966 static inline uint64_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
19967         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
19968         *ret_conv = CResult_TransactionNoneZ_clone(arg);
19969         return tag_ptr(ret_conv, true);
19970 }
19971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19972         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(arg);
19973         int64_t ret_conv = CResult_TransactionNoneZ_clone_ptr(arg_conv);
19974         return ret_conv;
19975 }
19976
19977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19978         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(orig);
19979         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
19980         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
19981         return tag_ptr(ret_conv, true);
19982 }
19983
19984 static inline uint64_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
19985         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
19986         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
19987         return tag_ptr(ret_conv, true);
19988 }
19989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19990         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(arg);
19991         int64_t ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
19992         return ret_conv;
19993 }
19994
19995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19996         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(orig);
19997         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
19998         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
19999         return tag_ptr(ret_conv, true);
20000 }
20001
20002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
20003         LDKThirtyTwoBytes a_ref;
20004         CHECK((*env)->GetArrayLength(env, a) == 32);
20005         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
20006         LDKChannelMonitor b_conv;
20007         b_conv.inner = untag_ptr(b);
20008         b_conv.is_owned = ptr_is_owned(b);
20009         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
20010         b_conv = ChannelMonitor_clone(&b_conv);
20011         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
20012         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
20013         return tag_ptr(ret_conv, true);
20014 }
20015
20016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20017         if (!ptr_is_owned(_res)) return;
20018         void* _res_ptr = untag_ptr(_res);
20019         CHECK_ACCESS(_res_ptr);
20020         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
20021         FREE(untag_ptr(_res));
20022         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
20023 }
20024
20025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20026         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
20027         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20028         if (_res_constr.datalen > 0)
20029                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
20030         else
20031                 _res_constr.data = NULL;
20032         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20033         for (size_t j = 0; j < _res_constr.datalen; j++) {
20034                 int64_t _res_conv_35 = _res_vals[j];
20035                 void* _res_conv_35_ptr = untag_ptr(_res_conv_35);
20036                 CHECK_ACCESS(_res_conv_35_ptr);
20037                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
20038                 FREE(untag_ptr(_res_conv_35));
20039                 _res_constr.data[j] = _res_conv_35_conv;
20040         }
20041         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20042         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
20043 }
20044
20045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
20046         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
20047         o_constr.datalen = (*env)->GetArrayLength(env, o);
20048         if (o_constr.datalen > 0)
20049                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
20050         else
20051                 o_constr.data = NULL;
20052         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
20053         for (size_t j = 0; j < o_constr.datalen; j++) {
20054                 int64_t o_conv_35 = o_vals[j];
20055                 void* o_conv_35_ptr = untag_ptr(o_conv_35);
20056                 CHECK_ACCESS(o_conv_35_ptr);
20057                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
20058                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(o_conv_35));
20059                 o_constr.data[j] = o_conv_35_conv;
20060         }
20061         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
20062         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
20063         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
20064         return tag_ptr(ret_conv, true);
20065 }
20066
20067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20068         LDKIOError e_conv = LDKIOError_from_java(env, e);
20069         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
20070         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
20071         return tag_ptr(ret_conv, true);
20072 }
20073
20074 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20075         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(o);
20076         jboolean ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o_conv);
20077         return ret_conv;
20078 }
20079
20080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20081         if (!ptr_is_owned(_res)) return;
20082         void* _res_ptr = untag_ptr(_res);
20083         CHECK_ACCESS(_res_ptr);
20084         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
20085         FREE(untag_ptr(_res));
20086         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
20087 }
20088
20089 static inline uint64_t CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR arg) {
20090         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
20091         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(arg);
20092         return tag_ptr(ret_conv, true);
20093 }
20094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20095         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(arg);
20096         int64_t ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(arg_conv);
20097         return ret_conv;
20098 }
20099
20100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20101         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(orig);
20102         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
20103         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
20104         return tag_ptr(ret_conv, true);
20105 }
20106
20107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
20108         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
20109         *ret_copy = COption_u16Z_some(o);
20110         int64_t ret_ref = tag_ptr(ret_copy, true);
20111         return ret_ref;
20112 }
20113
20114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
20115         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
20116         *ret_copy = COption_u16Z_none();
20117         int64_t ret_ref = tag_ptr(ret_copy, true);
20118         return ret_ref;
20119 }
20120
20121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
20122         if (!ptr_is_owned(_res)) return;
20123         void* _res_ptr = untag_ptr(_res);
20124         CHECK_ACCESS(_res_ptr);
20125         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
20126         FREE(untag_ptr(_res));
20127         COption_u16Z_free(_res_conv);
20128 }
20129
20130 static inline uint64_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
20131         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
20132         *ret_copy = COption_u16Z_clone(arg);
20133         int64_t ret_ref = tag_ptr(ret_copy, true);
20134         return ret_ref;
20135 }
20136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20137         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)untag_ptr(arg);
20138         int64_t ret_conv = COption_u16Z_clone_ptr(arg_conv);
20139         return ret_conv;
20140 }
20141
20142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20143         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)untag_ptr(orig);
20144         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
20145         *ret_copy = COption_u16Z_clone(orig_conv);
20146         int64_t ret_ref = tag_ptr(ret_copy, true);
20147         return ret_ref;
20148 }
20149
20150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
20151         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
20152         *ret_conv = CResult_NoneAPIErrorZ_ok();
20153         return tag_ptr(ret_conv, true);
20154 }
20155
20156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20157         void* e_ptr = untag_ptr(e);
20158         CHECK_ACCESS(e_ptr);
20159         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
20160         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
20161         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
20162         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
20163         return tag_ptr(ret_conv, true);
20164 }
20165
20166 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20167         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(o);
20168         jboolean ret_conv = CResult_NoneAPIErrorZ_is_ok(o_conv);
20169         return ret_conv;
20170 }
20171
20172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20173         if (!ptr_is_owned(_res)) return;
20174         void* _res_ptr = untag_ptr(_res);
20175         CHECK_ACCESS(_res_ptr);
20176         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
20177         FREE(untag_ptr(_res));
20178         CResult_NoneAPIErrorZ_free(_res_conv);
20179 }
20180
20181 static inline uint64_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
20182         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
20183         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
20184         return tag_ptr(ret_conv, true);
20185 }
20186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20187         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(arg);
20188         int64_t ret_conv = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
20189         return ret_conv;
20190 }
20191
20192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20193         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(orig);
20194         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
20195         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
20196         return tag_ptr(ret_conv, true);
20197 }
20198
20199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20200         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
20201         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20202         if (_res_constr.datalen > 0)
20203                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
20204         else
20205                 _res_constr.data = NULL;
20206         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20207         for (size_t w = 0; w < _res_constr.datalen; w++) {
20208                 int64_t _res_conv_22 = _res_vals[w];
20209                 void* _res_conv_22_ptr = untag_ptr(_res_conv_22);
20210                 CHECK_ACCESS(_res_conv_22_ptr);
20211                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
20212                 FREE(untag_ptr(_res_conv_22));
20213                 _res_constr.data[w] = _res_conv_22_conv;
20214         }
20215         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20216         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
20217 }
20218
20219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20220         LDKCVec_APIErrorZ _res_constr;
20221         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20222         if (_res_constr.datalen > 0)
20223                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
20224         else
20225                 _res_constr.data = NULL;
20226         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20227         for (size_t k = 0; k < _res_constr.datalen; k++) {
20228                 int64_t _res_conv_10 = _res_vals[k];
20229                 void* _res_conv_10_ptr = untag_ptr(_res_conv_10);
20230                 CHECK_ACCESS(_res_conv_10_ptr);
20231                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
20232                 FREE(untag_ptr(_res_conv_10));
20233                 _res_constr.data[k] = _res_conv_10_conv;
20234         }
20235         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20236         CVec_APIErrorZ_free(_res_constr);
20237 }
20238
20239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20240         LDKThirtyTwoBytes o_ref;
20241         CHECK((*env)->GetArrayLength(env, o) == 32);
20242         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20243         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
20244         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
20245         return tag_ptr(ret_conv, true);
20246 }
20247
20248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20249         void* e_ptr = untag_ptr(e);
20250         CHECK_ACCESS(e_ptr);
20251         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
20252         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
20253         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
20254         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
20255         return tag_ptr(ret_conv, true);
20256 }
20257
20258 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20259         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(o);
20260         jboolean ret_conv = CResult__u832APIErrorZ_is_ok(o_conv);
20261         return ret_conv;
20262 }
20263
20264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20265         if (!ptr_is_owned(_res)) return;
20266         void* _res_ptr = untag_ptr(_res);
20267         CHECK_ACCESS(_res_ptr);
20268         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
20269         FREE(untag_ptr(_res));
20270         CResult__u832APIErrorZ_free(_res_conv);
20271 }
20272
20273 static inline uint64_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
20274         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
20275         *ret_conv = CResult__u832APIErrorZ_clone(arg);
20276         return tag_ptr(ret_conv, true);
20277 }
20278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20279         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(arg);
20280         int64_t ret_conv = CResult__u832APIErrorZ_clone_ptr(arg_conv);
20281         return ret_conv;
20282 }
20283
20284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20285         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(orig);
20286         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
20287         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
20288         return tag_ptr(ret_conv, true);
20289 }
20290
20291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20292         LDKThirtyTwoBytes o_ref;
20293         CHECK((*env)->GetArrayLength(env, o) == 32);
20294         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20295         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
20296         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
20297         return tag_ptr(ret_conv, true);
20298 }
20299
20300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20301         void* e_ptr = untag_ptr(e);
20302         CHECK_ACCESS(e_ptr);
20303         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
20304         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
20305         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
20306         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
20307         return tag_ptr(ret_conv, true);
20308 }
20309
20310 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20311         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)untag_ptr(o);
20312         jboolean ret_conv = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
20313         return ret_conv;
20314 }
20315
20316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20317         if (!ptr_is_owned(_res)) return;
20318         void* _res_ptr = untag_ptr(_res);
20319         CHECK_ACCESS(_res_ptr);
20320         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
20321         FREE(untag_ptr(_res));
20322         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
20323 }
20324
20325 static inline uint64_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
20326         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
20327         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
20328         return tag_ptr(ret_conv, true);
20329 }
20330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20331         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)untag_ptr(arg);
20332         int64_t ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
20333         return ret_conv;
20334 }
20335
20336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20337         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)untag_ptr(orig);
20338         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
20339         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
20340         return tag_ptr(ret_conv, true);
20341 }
20342
20343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
20344         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20345         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
20346         return tag_ptr(ret_conv, true);
20347 }
20348
20349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20350         void* e_ptr = untag_ptr(e);
20351         CHECK_ACCESS(e_ptr);
20352         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
20353         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
20354         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20355         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
20356         return tag_ptr(ret_conv, true);
20357 }
20358
20359 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20360         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(o);
20361         jboolean ret_conv = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
20362         return ret_conv;
20363 }
20364
20365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20366         if (!ptr_is_owned(_res)) return;
20367         void* _res_ptr = untag_ptr(_res);
20368         CHECK_ACCESS(_res_ptr);
20369         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
20370         FREE(untag_ptr(_res));
20371         CResult_NonePaymentSendFailureZ_free(_res_conv);
20372 }
20373
20374 static inline uint64_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
20375         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20376         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
20377         return tag_ptr(ret_conv, true);
20378 }
20379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20380         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(arg);
20381         int64_t ret_conv = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
20382         return ret_conv;
20383 }
20384
20385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20386         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(orig);
20387         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20388         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
20389         return tag_ptr(ret_conv, true);
20390 }
20391
20392 static inline uint64_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
20393         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
20394         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
20395         return tag_ptr(ret_conv, true);
20396 }
20397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20398         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(arg);
20399         int64_t ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
20400         return ret_conv;
20401 }
20402
20403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20404         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(orig);
20405         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
20406         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
20407         return tag_ptr(ret_conv, true);
20408 }
20409
20410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
20411         LDKThirtyTwoBytes a_ref;
20412         CHECK((*env)->GetArrayLength(env, a) == 32);
20413         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
20414         LDKThirtyTwoBytes b_ref;
20415         CHECK((*env)->GetArrayLength(env, b) == 32);
20416         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
20417         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
20418         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
20419         return tag_ptr(ret_conv, true);
20420 }
20421
20422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20423         if (!ptr_is_owned(_res)) return;
20424         void* _res_ptr = untag_ptr(_res);
20425         CHECK_ACCESS(_res_ptr);
20426         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
20427         FREE(untag_ptr(_res));
20428         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
20429 }
20430
20431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20432         void* o_ptr = untag_ptr(o);
20433         CHECK_ACCESS(o_ptr);
20434         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
20435         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(o));
20436         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
20437         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
20438         return tag_ptr(ret_conv, true);
20439 }
20440
20441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20442         void* e_ptr = untag_ptr(e);
20443         CHECK_ACCESS(e_ptr);
20444         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
20445         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
20446         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
20447         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
20448         return tag_ptr(ret_conv, true);
20449 }
20450
20451 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20452         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(o);
20453         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
20454         return ret_conv;
20455 }
20456
20457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20458         if (!ptr_is_owned(_res)) return;
20459         void* _res_ptr = untag_ptr(_res);
20460         CHECK_ACCESS(_res_ptr);
20461         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
20462         FREE(untag_ptr(_res));
20463         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
20464 }
20465
20466 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
20467         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
20468         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
20469         return tag_ptr(ret_conv, true);
20470 }
20471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20472         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(arg);
20473         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
20474         return ret_conv;
20475 }
20476
20477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20478         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(orig);
20479         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
20480         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
20481         return tag_ptr(ret_conv, true);
20482 }
20483
20484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ThirtyTwoBytesZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
20485         LDKCVec_ThirtyTwoBytesZ _res_constr;
20486         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20487         if (_res_constr.datalen > 0)
20488                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
20489         else
20490                 _res_constr.data = NULL;
20491         for (size_t i = 0; i < _res_constr.datalen; i++) {
20492                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
20493                 LDKThirtyTwoBytes _res_conv_8_ref;
20494                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
20495                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
20496                 _res_constr.data[i] = _res_conv_8_ref;
20497         }
20498         CVec_ThirtyTwoBytesZ_free(_res_constr);
20499 }
20500
20501 static inline uint64_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
20502         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
20503         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
20504         return tag_ptr(ret_conv, true);
20505 }
20506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20507         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(arg);
20508         int64_t ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
20509         return ret_conv;
20510 }
20511
20512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20513         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(orig);
20514         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
20515         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
20516         return tag_ptr(ret_conv, true);
20517 }
20518
20519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
20520         LDKThirtyTwoBytes a_ref;
20521         CHECK((*env)->GetArrayLength(env, a) == 32);
20522         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
20523         LDKThirtyTwoBytes b_ref;
20524         CHECK((*env)->GetArrayLength(env, b) == 32);
20525         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
20526         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
20527         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
20528         return tag_ptr(ret_conv, true);
20529 }
20530
20531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20532         if (!ptr_is_owned(_res)) return;
20533         void* _res_ptr = untag_ptr(_res);
20534         CHECK_ACCESS(_res_ptr);
20535         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
20536         FREE(untag_ptr(_res));
20537         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
20538 }
20539
20540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20541         void* o_ptr = untag_ptr(o);
20542         CHECK_ACCESS(o_ptr);
20543         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
20544         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(o));
20545         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
20546         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
20547         return tag_ptr(ret_conv, true);
20548 }
20549
20550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1err(JNIEnv *env, jclass clz) {
20551         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
20552         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
20553         return tag_ptr(ret_conv, true);
20554 }
20555
20556 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20557         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(o);
20558         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
20559         return ret_conv;
20560 }
20561
20562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20563         if (!ptr_is_owned(_res)) return;
20564         void* _res_ptr = untag_ptr(_res);
20565         CHECK_ACCESS(_res_ptr);
20566         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
20567         FREE(untag_ptr(_res));
20568         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
20569 }
20570
20571 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
20572         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
20573         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
20574         return tag_ptr(ret_conv, true);
20575 }
20576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20577         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(arg);
20578         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
20579         return ret_conv;
20580 }
20581
20582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20583         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(orig);
20584         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
20585         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
20586         return tag_ptr(ret_conv, true);
20587 }
20588
20589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20590         void* o_ptr = untag_ptr(o);
20591         CHECK_ACCESS(o_ptr);
20592         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
20593         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(o));
20594         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
20595         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
20596         return tag_ptr(ret_conv, true);
20597 }
20598
20599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20600         void* e_ptr = untag_ptr(e);
20601         CHECK_ACCESS(e_ptr);
20602         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
20603         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
20604         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
20605         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
20606         return tag_ptr(ret_conv, true);
20607 }
20608
20609 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20610         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(o);
20611         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
20612         return ret_conv;
20613 }
20614
20615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20616         if (!ptr_is_owned(_res)) return;
20617         void* _res_ptr = untag_ptr(_res);
20618         CHECK_ACCESS(_res_ptr);
20619         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
20620         FREE(untag_ptr(_res));
20621         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
20622 }
20623
20624 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
20625         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
20626         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
20627         return tag_ptr(ret_conv, true);
20628 }
20629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20630         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(arg);
20631         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
20632         return ret_conv;
20633 }
20634
20635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20636         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(orig);
20637         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
20638         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
20639         return tag_ptr(ret_conv, true);
20640 }
20641
20642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20643         LDKThirtyTwoBytes o_ref;
20644         CHECK((*env)->GetArrayLength(env, o) == 32);
20645         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20646         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
20647         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
20648         return tag_ptr(ret_conv, true);
20649 }
20650
20651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1err(JNIEnv *env, jclass clz) {
20652         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
20653         *ret_conv = CResult_PaymentSecretNoneZ_err();
20654         return tag_ptr(ret_conv, true);
20655 }
20656
20657 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20658         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(o);
20659         jboolean ret_conv = CResult_PaymentSecretNoneZ_is_ok(o_conv);
20660         return ret_conv;
20661 }
20662
20663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20664         if (!ptr_is_owned(_res)) return;
20665         void* _res_ptr = untag_ptr(_res);
20666         CHECK_ACCESS(_res_ptr);
20667         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
20668         FREE(untag_ptr(_res));
20669         CResult_PaymentSecretNoneZ_free(_res_conv);
20670 }
20671
20672 static inline uint64_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
20673         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
20674         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
20675         return tag_ptr(ret_conv, true);
20676 }
20677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20678         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(arg);
20679         int64_t ret_conv = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
20680         return ret_conv;
20681 }
20682
20683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20684         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(orig);
20685         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
20686         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
20687         return tag_ptr(ret_conv, true);
20688 }
20689
20690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20691         LDKThirtyTwoBytes o_ref;
20692         CHECK((*env)->GetArrayLength(env, o) == 32);
20693         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20694         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
20695         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
20696         return tag_ptr(ret_conv, true);
20697 }
20698
20699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20700         void* e_ptr = untag_ptr(e);
20701         CHECK_ACCESS(e_ptr);
20702         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
20703         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
20704         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
20705         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
20706         return tag_ptr(ret_conv, true);
20707 }
20708
20709 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20710         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(o);
20711         jboolean ret_conv = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
20712         return ret_conv;
20713 }
20714
20715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20716         if (!ptr_is_owned(_res)) return;
20717         void* _res_ptr = untag_ptr(_res);
20718         CHECK_ACCESS(_res_ptr);
20719         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
20720         FREE(untag_ptr(_res));
20721         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
20722 }
20723
20724 static inline uint64_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
20725         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
20726         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
20727         return tag_ptr(ret_conv, true);
20728 }
20729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20730         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(arg);
20731         int64_t ret_conv = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
20732         return ret_conv;
20733 }
20734
20735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20736         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(orig);
20737         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
20738         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
20739         return tag_ptr(ret_conv, true);
20740 }
20741
20742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20743         LDKThirtyTwoBytes o_ref;
20744         CHECK((*env)->GetArrayLength(env, o) == 32);
20745         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20746         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
20747         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
20748         return tag_ptr(ret_conv, true);
20749 }
20750
20751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20752         void* e_ptr = untag_ptr(e);
20753         CHECK_ACCESS(e_ptr);
20754         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
20755         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
20756         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
20757         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
20758         return tag_ptr(ret_conv, true);
20759 }
20760
20761 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20762         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(o);
20763         jboolean ret_conv = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
20764         return ret_conv;
20765 }
20766
20767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20768         if (!ptr_is_owned(_res)) return;
20769         void* _res_ptr = untag_ptr(_res);
20770         CHECK_ACCESS(_res_ptr);
20771         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
20772         FREE(untag_ptr(_res));
20773         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
20774 }
20775
20776 static inline uint64_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
20777         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
20778         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
20779         return tag_ptr(ret_conv, true);
20780 }
20781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20782         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(arg);
20783         int64_t ret_conv = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
20784         return ret_conv;
20785 }
20786
20787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20788         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(orig);
20789         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
20790         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
20791         return tag_ptr(ret_conv, true);
20792 }
20793
20794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20795         LDKCounterpartyForwardingInfo o_conv;
20796         o_conv.inner = untag_ptr(o);
20797         o_conv.is_owned = ptr_is_owned(o);
20798         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20799         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
20800         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
20801         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
20802         return tag_ptr(ret_conv, true);
20803 }
20804
20805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20806         void* e_ptr = untag_ptr(e);
20807         CHECK_ACCESS(e_ptr);
20808         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20809         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20810         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
20811         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
20812         return tag_ptr(ret_conv, true);
20813 }
20814
20815 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20816         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(o);
20817         jboolean ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
20818         return ret_conv;
20819 }
20820
20821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20822         if (!ptr_is_owned(_res)) return;
20823         void* _res_ptr = untag_ptr(_res);
20824         CHECK_ACCESS(_res_ptr);
20825         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
20826         FREE(untag_ptr(_res));
20827         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
20828 }
20829
20830 static inline uint64_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
20831         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
20832         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
20833         return tag_ptr(ret_conv, true);
20834 }
20835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20836         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(arg);
20837         int64_t ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
20838         return ret_conv;
20839 }
20840
20841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20842         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(orig);
20843         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
20844         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
20845         return tag_ptr(ret_conv, true);
20846 }
20847
20848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20849         LDKChannelCounterparty o_conv;
20850         o_conv.inner = untag_ptr(o);
20851         o_conv.is_owned = ptr_is_owned(o);
20852         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20853         o_conv = ChannelCounterparty_clone(&o_conv);
20854         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
20855         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
20856         return tag_ptr(ret_conv, true);
20857 }
20858
20859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20860         void* e_ptr = untag_ptr(e);
20861         CHECK_ACCESS(e_ptr);
20862         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20863         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20864         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
20865         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
20866         return tag_ptr(ret_conv, true);
20867 }
20868
20869 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20870         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(o);
20871         jboolean ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
20872         return ret_conv;
20873 }
20874
20875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20876         if (!ptr_is_owned(_res)) return;
20877         void* _res_ptr = untag_ptr(_res);
20878         CHECK_ACCESS(_res_ptr);
20879         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
20880         FREE(untag_ptr(_res));
20881         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
20882 }
20883
20884 static inline uint64_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
20885         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
20886         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
20887         return tag_ptr(ret_conv, true);
20888 }
20889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20890         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(arg);
20891         int64_t ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
20892         return ret_conv;
20893 }
20894
20895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20896         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(orig);
20897         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
20898         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
20899         return tag_ptr(ret_conv, true);
20900 }
20901
20902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20903         LDKChannelDetails o_conv;
20904         o_conv.inner = untag_ptr(o);
20905         o_conv.is_owned = ptr_is_owned(o);
20906         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20907         o_conv = ChannelDetails_clone(&o_conv);
20908         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
20909         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
20910         return tag_ptr(ret_conv, true);
20911 }
20912
20913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20914         void* e_ptr = untag_ptr(e);
20915         CHECK_ACCESS(e_ptr);
20916         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20917         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20918         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
20919         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
20920         return tag_ptr(ret_conv, true);
20921 }
20922
20923 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20924         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(o);
20925         jboolean ret_conv = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
20926         return ret_conv;
20927 }
20928
20929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20930         if (!ptr_is_owned(_res)) return;
20931         void* _res_ptr = untag_ptr(_res);
20932         CHECK_ACCESS(_res_ptr);
20933         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
20934         FREE(untag_ptr(_res));
20935         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
20936 }
20937
20938 static inline uint64_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
20939         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
20940         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
20941         return tag_ptr(ret_conv, true);
20942 }
20943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20944         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(arg);
20945         int64_t ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
20946         return ret_conv;
20947 }
20948
20949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20950         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(orig);
20951         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
20952         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
20953         return tag_ptr(ret_conv, true);
20954 }
20955
20956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20957         LDKPhantomRouteHints o_conv;
20958         o_conv.inner = untag_ptr(o);
20959         o_conv.is_owned = ptr_is_owned(o);
20960         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20961         o_conv = PhantomRouteHints_clone(&o_conv);
20962         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
20963         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
20964         return tag_ptr(ret_conv, true);
20965 }
20966
20967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20968         void* e_ptr = untag_ptr(e);
20969         CHECK_ACCESS(e_ptr);
20970         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20971         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20972         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
20973         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
20974         return tag_ptr(ret_conv, true);
20975 }
20976
20977 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20978         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(o);
20979         jboolean ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
20980         return ret_conv;
20981 }
20982
20983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20984         if (!ptr_is_owned(_res)) return;
20985         void* _res_ptr = untag_ptr(_res);
20986         CHECK_ACCESS(_res_ptr);
20987         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
20988         FREE(untag_ptr(_res));
20989         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
20990 }
20991
20992 static inline uint64_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
20993         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
20994         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
20995         return tag_ptr(ret_conv, true);
20996 }
20997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20998         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(arg);
20999         int64_t ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
21000         return ret_conv;
21001 }
21002
21003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21004         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(orig);
21005         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
21006         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
21007         return tag_ptr(ret_conv, true);
21008 }
21009
21010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21011         LDKCVec_ChannelMonitorZ _res_constr;
21012         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21013         if (_res_constr.datalen > 0)
21014                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
21015         else
21016                 _res_constr.data = NULL;
21017         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21018         for (size_t q = 0; q < _res_constr.datalen; q++) {
21019                 int64_t _res_conv_16 = _res_vals[q];
21020                 LDKChannelMonitor _res_conv_16_conv;
21021                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
21022                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
21023                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
21024                 _res_constr.data[q] = _res_conv_16_conv;
21025         }
21026         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21027         CVec_ChannelMonitorZ_free(_res_constr);
21028 }
21029
21030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
21031         LDKThirtyTwoBytes a_ref;
21032         CHECK((*env)->GetArrayLength(env, a) == 32);
21033         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21034         LDKChannelManager b_conv;
21035         b_conv.inner = untag_ptr(b);
21036         b_conv.is_owned = ptr_is_owned(b);
21037         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
21038         // WARNING: we need a move here but no clone is available for LDKChannelManager
21039         
21040         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
21041         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
21042         return tag_ptr(ret_conv, true);
21043 }
21044
21045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21046         if (!ptr_is_owned(_res)) return;
21047         void* _res_ptr = untag_ptr(_res);
21048         CHECK_ACCESS(_res_ptr);
21049         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
21050         FREE(untag_ptr(_res));
21051         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
21052 }
21053
21054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21055         void* o_ptr = untag_ptr(o);
21056         CHECK_ACCESS(o_ptr);
21057         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
21058         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
21059         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
21060         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
21061         return tag_ptr(ret_conv, true);
21062 }
21063
21064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21065         void* e_ptr = untag_ptr(e);
21066         CHECK_ACCESS(e_ptr);
21067         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21068         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21069         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
21070         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
21071         return tag_ptr(ret_conv, true);
21072 }
21073
21074 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21075         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(o);
21076         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
21077         return ret_conv;
21078 }
21079
21080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21081         if (!ptr_is_owned(_res)) return;
21082         void* _res_ptr = untag_ptr(_res);
21083         CHECK_ACCESS(_res_ptr);
21084         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
21085         FREE(untag_ptr(_res));
21086         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
21087 }
21088
21089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21090         LDKChannelConfig o_conv;
21091         o_conv.inner = untag_ptr(o);
21092         o_conv.is_owned = ptr_is_owned(o);
21093         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21094         o_conv = ChannelConfig_clone(&o_conv);
21095         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21096         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
21097         return tag_ptr(ret_conv, true);
21098 }
21099
21100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21101         void* e_ptr = untag_ptr(e);
21102         CHECK_ACCESS(e_ptr);
21103         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21104         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21105         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21106         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
21107         return tag_ptr(ret_conv, true);
21108 }
21109
21110 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21111         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(o);
21112         jboolean ret_conv = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
21113         return ret_conv;
21114 }
21115
21116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21117         if (!ptr_is_owned(_res)) return;
21118         void* _res_ptr = untag_ptr(_res);
21119         CHECK_ACCESS(_res_ptr);
21120         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
21121         FREE(untag_ptr(_res));
21122         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
21123 }
21124
21125 static inline uint64_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
21126         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21127         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
21128         return tag_ptr(ret_conv, true);
21129 }
21130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21131         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(arg);
21132         int64_t ret_conv = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
21133         return ret_conv;
21134 }
21135
21136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21137         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(orig);
21138         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21139         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
21140         return tag_ptr(ret_conv, true);
21141 }
21142
21143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21144         LDKOutPoint o_conv;
21145         o_conv.inner = untag_ptr(o);
21146         o_conv.is_owned = ptr_is_owned(o);
21147         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21148         o_conv = OutPoint_clone(&o_conv);
21149         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
21150         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
21151         return tag_ptr(ret_conv, true);
21152 }
21153
21154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21155         void* e_ptr = untag_ptr(e);
21156         CHECK_ACCESS(e_ptr);
21157         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21158         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21159         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
21160         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
21161         return tag_ptr(ret_conv, true);
21162 }
21163
21164 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21165         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(o);
21166         jboolean ret_conv = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
21167         return ret_conv;
21168 }
21169
21170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21171         if (!ptr_is_owned(_res)) return;
21172         void* _res_ptr = untag_ptr(_res);
21173         CHECK_ACCESS(_res_ptr);
21174         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
21175         FREE(untag_ptr(_res));
21176         CResult_OutPointDecodeErrorZ_free(_res_conv);
21177 }
21178
21179 static inline uint64_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
21180         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
21181         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
21182         return tag_ptr(ret_conv, true);
21183 }
21184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21185         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(arg);
21186         int64_t ret_conv = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
21187         return ret_conv;
21188 }
21189
21190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21191         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(orig);
21192         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
21193         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
21194         return tag_ptr(ret_conv, true);
21195 }
21196
21197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) {
21198         void* o_ptr = untag_ptr(o);
21199         CHECK_ACCESS(o_ptr);
21200         LDKType o_conv = *(LDKType*)(o_ptr);
21201         if (o_conv.free == LDKType_JCalls_free) {
21202                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21203                 LDKType_JCalls_cloned(&o_conv);
21204         }
21205         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
21206         *ret_copy = COption_TypeZ_some(o_conv);
21207         int64_t ret_ref = tag_ptr(ret_copy, true);
21208         return ret_ref;
21209 }
21210
21211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) {
21212         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
21213         *ret_copy = COption_TypeZ_none();
21214         int64_t ret_ref = tag_ptr(ret_copy, true);
21215         return ret_ref;
21216 }
21217
21218 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21219         if (!ptr_is_owned(_res)) return;
21220         void* _res_ptr = untag_ptr(_res);
21221         CHECK_ACCESS(_res_ptr);
21222         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
21223         FREE(untag_ptr(_res));
21224         COption_TypeZ_free(_res_conv);
21225 }
21226
21227 static inline uint64_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
21228         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
21229         *ret_copy = COption_TypeZ_clone(arg);
21230         int64_t ret_ref = tag_ptr(ret_copy, true);
21231         return ret_ref;
21232 }
21233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21234         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)untag_ptr(arg);
21235         int64_t ret_conv = COption_TypeZ_clone_ptr(arg_conv);
21236         return ret_conv;
21237 }
21238
21239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21240         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)untag_ptr(orig);
21241         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
21242         *ret_copy = COption_TypeZ_clone(orig_conv);
21243         int64_t ret_ref = tag_ptr(ret_copy, true);
21244         return ret_ref;
21245 }
21246
21247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21248         void* o_ptr = untag_ptr(o);
21249         CHECK_ACCESS(o_ptr);
21250         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
21251         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)untag_ptr(o));
21252         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
21253         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
21254         return tag_ptr(ret_conv, true);
21255 }
21256
21257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21258         void* e_ptr = untag_ptr(e);
21259         CHECK_ACCESS(e_ptr);
21260         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21261         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21262         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
21263         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
21264         return tag_ptr(ret_conv, true);
21265 }
21266
21267 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21268         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(o);
21269         jboolean ret_conv = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
21270         return ret_conv;
21271 }
21272
21273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21274         if (!ptr_is_owned(_res)) return;
21275         void* _res_ptr = untag_ptr(_res);
21276         CHECK_ACCESS(_res_ptr);
21277         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
21278         FREE(untag_ptr(_res));
21279         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
21280 }
21281
21282 static inline uint64_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
21283         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
21284         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
21285         return tag_ptr(ret_conv, true);
21286 }
21287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21288         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(arg);
21289         int64_t ret_conv = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
21290         return ret_conv;
21291 }
21292
21293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21294         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(orig);
21295         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
21296         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
21297         return tag_ptr(ret_conv, true);
21298 }
21299
21300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21301         LDKThirtyTwoBytes o_ref;
21302         CHECK((*env)->GetArrayLength(env, o) == 32);
21303         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
21304         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
21305         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
21306         return tag_ptr(ret_conv, true);
21307 }
21308
21309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21310         void* e_ptr = untag_ptr(e);
21311         CHECK_ACCESS(e_ptr);
21312         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
21313         e_conv = PaymentError_clone((LDKPaymentError*)untag_ptr(e));
21314         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
21315         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
21316         return tag_ptr(ret_conv, true);
21317 }
21318
21319 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21320         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(o);
21321         jboolean ret_conv = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
21322         return ret_conv;
21323 }
21324
21325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_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_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
21330         FREE(untag_ptr(_res));
21331         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
21332 }
21333
21334 static inline uint64_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
21335         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
21336         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
21337         return tag_ptr(ret_conv, true);
21338 }
21339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21340         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(arg);
21341         int64_t ret_conv = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
21342         return ret_conv;
21343 }
21344
21345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21346         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(orig);
21347         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
21348         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
21349         return tag_ptr(ret_conv, true);
21350 }
21351
21352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21353         LDKInFlightHtlcs 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         // WARNING: we need a move here but no clone is available for LDKInFlightHtlcs
21358         
21359         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
21360         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_ok(o_conv);
21361         return tag_ptr(ret_conv, true);
21362 }
21363
21364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21365         void* e_ptr = untag_ptr(e);
21366         CHECK_ACCESS(e_ptr);
21367         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21368         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21369         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
21370         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_err(e_conv);
21371         return tag_ptr(ret_conv, true);
21372 }
21373
21374 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21375         LDKCResult_InFlightHtlcsDecodeErrorZ* o_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(o);
21376         jboolean ret_conv = CResult_InFlightHtlcsDecodeErrorZ_is_ok(o_conv);
21377         return ret_conv;
21378 }
21379
21380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_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_InFlightHtlcsDecodeErrorZ _res_conv = *(LDKCResult_InFlightHtlcsDecodeErrorZ*)(_res_ptr);
21385         FREE(untag_ptr(_res));
21386         CResult_InFlightHtlcsDecodeErrorZ_free(_res_conv);
21387 }
21388
21389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1ok(JNIEnv *env, jclass clz, jclass o) {
21390         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
21391         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
21392         *ret_conv = CResult_SiPrefixParseErrorZ_ok(o_conv);
21393         return tag_ptr(ret_conv, true);
21394 }
21395
21396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21397         void* e_ptr = untag_ptr(e);
21398         CHECK_ACCESS(e_ptr);
21399         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
21400         e_conv = ParseError_clone((LDKParseError*)untag_ptr(e));
21401         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
21402         *ret_conv = CResult_SiPrefixParseErrorZ_err(e_conv);
21403         return tag_ptr(ret_conv, true);
21404 }
21405
21406 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21407         LDKCResult_SiPrefixParseErrorZ* o_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(o);
21408         jboolean ret_conv = CResult_SiPrefixParseErrorZ_is_ok(o_conv);
21409         return ret_conv;
21410 }
21411
21412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21413         if (!ptr_is_owned(_res)) return;
21414         void* _res_ptr = untag_ptr(_res);
21415         CHECK_ACCESS(_res_ptr);
21416         LDKCResult_SiPrefixParseErrorZ _res_conv = *(LDKCResult_SiPrefixParseErrorZ*)(_res_ptr);
21417         FREE(untag_ptr(_res));
21418         CResult_SiPrefixParseErrorZ_free(_res_conv);
21419 }
21420
21421 static inline uint64_t CResult_SiPrefixParseErrorZ_clone_ptr(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR arg) {
21422         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
21423         *ret_conv = CResult_SiPrefixParseErrorZ_clone(arg);
21424         return tag_ptr(ret_conv, true);
21425 }
21426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21427         LDKCResult_SiPrefixParseErrorZ* arg_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(arg);
21428         int64_t ret_conv = CResult_SiPrefixParseErrorZ_clone_ptr(arg_conv);
21429         return ret_conv;
21430 }
21431
21432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21433         LDKCResult_SiPrefixParseErrorZ* orig_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(orig);
21434         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
21435         *ret_conv = CResult_SiPrefixParseErrorZ_clone(orig_conv);
21436         return tag_ptr(ret_conv, true);
21437 }
21438
21439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21440         LDKInvoice o_conv;
21441         o_conv.inner = untag_ptr(o);
21442         o_conv.is_owned = ptr_is_owned(o);
21443         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21444         o_conv = Invoice_clone(&o_conv);
21445         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
21446         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_ok(o_conv);
21447         return tag_ptr(ret_conv, true);
21448 }
21449
21450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21451         void* e_ptr = untag_ptr(e);
21452         CHECK_ACCESS(e_ptr);
21453         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
21454         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)untag_ptr(e));
21455         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
21456         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_err(e_conv);
21457         return tag_ptr(ret_conv, true);
21458 }
21459
21460 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21461         LDKCResult_InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(o);
21462         jboolean ret_conv = CResult_InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
21463         return ret_conv;
21464 }
21465
21466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21467         if (!ptr_is_owned(_res)) return;
21468         void* _res_ptr = untag_ptr(_res);
21469         CHECK_ACCESS(_res_ptr);
21470         LDKCResult_InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_InvoiceParseOrSemanticErrorZ*)(_res_ptr);
21471         FREE(untag_ptr(_res));
21472         CResult_InvoiceParseOrSemanticErrorZ_free(_res_conv);
21473 }
21474
21475 static inline uint64_t CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
21476         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
21477         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(arg);
21478         return tag_ptr(ret_conv, true);
21479 }
21480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21481         LDKCResult_InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(arg);
21482         int64_t ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
21483         return ret_conv;
21484 }
21485
21486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21487         LDKCResult_InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(orig);
21488         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
21489         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(orig_conv);
21490         return tag_ptr(ret_conv, true);
21491 }
21492
21493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21494         LDKSignedRawInvoice o_conv;
21495         o_conv.inner = untag_ptr(o);
21496         o_conv.is_owned = ptr_is_owned(o);
21497         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21498         o_conv = SignedRawInvoice_clone(&o_conv);
21499         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
21500         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_ok(o_conv);
21501         return tag_ptr(ret_conv, true);
21502 }
21503
21504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21505         void* e_ptr = untag_ptr(e);
21506         CHECK_ACCESS(e_ptr);
21507         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
21508         e_conv = ParseError_clone((LDKParseError*)untag_ptr(e));
21509         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
21510         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_err(e_conv);
21511         return tag_ptr(ret_conv, true);
21512 }
21513
21514 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21515         LDKCResult_SignedRawInvoiceParseErrorZ* o_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(o);
21516         jboolean ret_conv = CResult_SignedRawInvoiceParseErrorZ_is_ok(o_conv);
21517         return ret_conv;
21518 }
21519
21520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21521         if (!ptr_is_owned(_res)) return;
21522         void* _res_ptr = untag_ptr(_res);
21523         CHECK_ACCESS(_res_ptr);
21524         LDKCResult_SignedRawInvoiceParseErrorZ _res_conv = *(LDKCResult_SignedRawInvoiceParseErrorZ*)(_res_ptr);
21525         FREE(untag_ptr(_res));
21526         CResult_SignedRawInvoiceParseErrorZ_free(_res_conv);
21527 }
21528
21529 static inline uint64_t CResult_SignedRawInvoiceParseErrorZ_clone_ptr(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR arg) {
21530         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
21531         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(arg);
21532         return tag_ptr(ret_conv, true);
21533 }
21534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21535         LDKCResult_SignedRawInvoiceParseErrorZ* arg_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(arg);
21536         int64_t ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone_ptr(arg_conv);
21537         return ret_conv;
21538 }
21539
21540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21541         LDKCResult_SignedRawInvoiceParseErrorZ* orig_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(orig);
21542         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
21543         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(orig_conv);
21544         return tag_ptr(ret_conv, true);
21545 }
21546
21547 static inline uint64_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
21548         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
21549         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
21550         return tag_ptr(ret_conv, true);
21551 }
21552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21553         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(arg);
21554         int64_t ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
21555         return ret_conv;
21556 }
21557
21558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21559         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(orig);
21560         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
21561         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
21562         return tag_ptr(ret_conv, true);
21563 }
21564
21565 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) {
21566         LDKRawInvoice a_conv;
21567         a_conv.inner = untag_ptr(a);
21568         a_conv.is_owned = ptr_is_owned(a);
21569         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21570         a_conv = RawInvoice_clone(&a_conv);
21571         LDKThirtyTwoBytes b_ref;
21572         CHECK((*env)->GetArrayLength(env, b) == 32);
21573         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
21574         LDKInvoiceSignature c_conv;
21575         c_conv.inner = untag_ptr(c);
21576         c_conv.is_owned = ptr_is_owned(c);
21577         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
21578         c_conv = InvoiceSignature_clone(&c_conv);
21579         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
21580         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
21581         return tag_ptr(ret_conv, true);
21582 }
21583
21584 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21585         if (!ptr_is_owned(_res)) return;
21586         void* _res_ptr = untag_ptr(_res);
21587         CHECK_ACCESS(_res_ptr);
21588         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
21589         FREE(untag_ptr(_res));
21590         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
21591 }
21592
21593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21594         LDKPayeePubKey o_conv;
21595         o_conv.inner = untag_ptr(o);
21596         o_conv.is_owned = ptr_is_owned(o);
21597         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21598         o_conv = PayeePubKey_clone(&o_conv);
21599         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
21600         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
21601         return tag_ptr(ret_conv, true);
21602 }
21603
21604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21605         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
21606         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
21607         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
21608         return tag_ptr(ret_conv, true);
21609 }
21610
21611 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21612         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(o);
21613         jboolean ret_conv = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
21614         return ret_conv;
21615 }
21616
21617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21618         if (!ptr_is_owned(_res)) return;
21619         void* _res_ptr = untag_ptr(_res);
21620         CHECK_ACCESS(_res_ptr);
21621         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
21622         FREE(untag_ptr(_res));
21623         CResult_PayeePubKeyErrorZ_free(_res_conv);
21624 }
21625
21626 static inline uint64_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
21627         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
21628         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
21629         return tag_ptr(ret_conv, true);
21630 }
21631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21632         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(arg);
21633         int64_t ret_conv = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
21634         return ret_conv;
21635 }
21636
21637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21638         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(orig);
21639         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
21640         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
21641         return tag_ptr(ret_conv, true);
21642 }
21643
21644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21645         LDKCVec_PrivateRouteZ _res_constr;
21646         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21647         if (_res_constr.datalen > 0)
21648                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
21649         else
21650                 _res_constr.data = NULL;
21651         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21652         for (size_t o = 0; o < _res_constr.datalen; o++) {
21653                 int64_t _res_conv_14 = _res_vals[o];
21654                 LDKPrivateRoute _res_conv_14_conv;
21655                 _res_conv_14_conv.inner = untag_ptr(_res_conv_14);
21656                 _res_conv_14_conv.is_owned = ptr_is_owned(_res_conv_14);
21657                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
21658                 _res_constr.data[o] = _res_conv_14_conv;
21659         }
21660         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21661         CVec_PrivateRouteZ_free(_res_constr);
21662 }
21663
21664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21665         LDKPositiveTimestamp o_conv;
21666         o_conv.inner = untag_ptr(o);
21667         o_conv.is_owned = ptr_is_owned(o);
21668         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21669         o_conv = PositiveTimestamp_clone(&o_conv);
21670         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
21671         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
21672         return tag_ptr(ret_conv, true);
21673 }
21674
21675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21676         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
21677         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
21678         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
21679         return tag_ptr(ret_conv, true);
21680 }
21681
21682 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21683         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(o);
21684         jboolean ret_conv = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
21685         return ret_conv;
21686 }
21687
21688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21689         if (!ptr_is_owned(_res)) return;
21690         void* _res_ptr = untag_ptr(_res);
21691         CHECK_ACCESS(_res_ptr);
21692         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
21693         FREE(untag_ptr(_res));
21694         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
21695 }
21696
21697 static inline uint64_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
21698         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
21699         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
21700         return tag_ptr(ret_conv, true);
21701 }
21702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21703         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(arg);
21704         int64_t ret_conv = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
21705         return ret_conv;
21706 }
21707
21708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21709         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(orig);
21710         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
21711         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
21712         return tag_ptr(ret_conv, true);
21713 }
21714
21715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
21716         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
21717         *ret_conv = CResult_NoneSemanticErrorZ_ok();
21718         return tag_ptr(ret_conv, true);
21719 }
21720
21721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21722         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
21723         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
21724         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
21725         return tag_ptr(ret_conv, true);
21726 }
21727
21728 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21729         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(o);
21730         jboolean ret_conv = CResult_NoneSemanticErrorZ_is_ok(o_conv);
21731         return ret_conv;
21732 }
21733
21734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21735         if (!ptr_is_owned(_res)) return;
21736         void* _res_ptr = untag_ptr(_res);
21737         CHECK_ACCESS(_res_ptr);
21738         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
21739         FREE(untag_ptr(_res));
21740         CResult_NoneSemanticErrorZ_free(_res_conv);
21741 }
21742
21743 static inline uint64_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
21744         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
21745         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
21746         return tag_ptr(ret_conv, true);
21747 }
21748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21749         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(arg);
21750         int64_t ret_conv = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
21751         return ret_conv;
21752 }
21753
21754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21755         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(orig);
21756         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
21757         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
21758         return tag_ptr(ret_conv, true);
21759 }
21760
21761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21762         LDKInvoice o_conv;
21763         o_conv.inner = untag_ptr(o);
21764         o_conv.is_owned = ptr_is_owned(o);
21765         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21766         o_conv = Invoice_clone(&o_conv);
21767         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
21768         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
21769         return tag_ptr(ret_conv, true);
21770 }
21771
21772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21773         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
21774         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
21775         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
21776         return tag_ptr(ret_conv, true);
21777 }
21778
21779 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21780         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(o);
21781         jboolean ret_conv = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
21782         return ret_conv;
21783 }
21784
21785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21786         if (!ptr_is_owned(_res)) return;
21787         void* _res_ptr = untag_ptr(_res);
21788         CHECK_ACCESS(_res_ptr);
21789         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
21790         FREE(untag_ptr(_res));
21791         CResult_InvoiceSemanticErrorZ_free(_res_conv);
21792 }
21793
21794 static inline uint64_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
21795         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
21796         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
21797         return tag_ptr(ret_conv, true);
21798 }
21799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21800         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(arg);
21801         int64_t ret_conv = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
21802         return ret_conv;
21803 }
21804
21805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21806         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(orig);
21807         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
21808         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
21809         return tag_ptr(ret_conv, true);
21810 }
21811
21812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21813         LDKDescription o_conv;
21814         o_conv.inner = untag_ptr(o);
21815         o_conv.is_owned = ptr_is_owned(o);
21816         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21817         o_conv = Description_clone(&o_conv);
21818         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
21819         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
21820         return tag_ptr(ret_conv, true);
21821 }
21822
21823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21824         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
21825         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
21826         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
21827         return tag_ptr(ret_conv, true);
21828 }
21829
21830 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21831         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(o);
21832         jboolean ret_conv = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
21833         return ret_conv;
21834 }
21835
21836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21837         if (!ptr_is_owned(_res)) return;
21838         void* _res_ptr = untag_ptr(_res);
21839         CHECK_ACCESS(_res_ptr);
21840         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
21841         FREE(untag_ptr(_res));
21842         CResult_DescriptionCreationErrorZ_free(_res_conv);
21843 }
21844
21845 static inline uint64_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
21846         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
21847         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
21848         return tag_ptr(ret_conv, true);
21849 }
21850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21851         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(arg);
21852         int64_t ret_conv = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
21853         return ret_conv;
21854 }
21855
21856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21857         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(orig);
21858         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
21859         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
21860         return tag_ptr(ret_conv, true);
21861 }
21862
21863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21864         LDKPrivateRoute o_conv;
21865         o_conv.inner = untag_ptr(o);
21866         o_conv.is_owned = ptr_is_owned(o);
21867         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21868         o_conv = PrivateRoute_clone(&o_conv);
21869         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
21870         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
21871         return tag_ptr(ret_conv, true);
21872 }
21873
21874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21875         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
21876         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
21877         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
21878         return tag_ptr(ret_conv, true);
21879 }
21880
21881 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21882         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(o);
21883         jboolean ret_conv = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
21884         return ret_conv;
21885 }
21886
21887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21888         if (!ptr_is_owned(_res)) return;
21889         void* _res_ptr = untag_ptr(_res);
21890         CHECK_ACCESS(_res_ptr);
21891         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
21892         FREE(untag_ptr(_res));
21893         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
21894 }
21895
21896 static inline uint64_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
21897         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
21898         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
21899         return tag_ptr(ret_conv, true);
21900 }
21901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21902         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(arg);
21903         int64_t ret_conv = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
21904         return ret_conv;
21905 }
21906
21907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21908         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(orig);
21909         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
21910         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
21911         return tag_ptr(ret_conv, true);
21912 }
21913
21914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
21915         LDKStr o_conv = java_to_owned_str(env, o);
21916         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
21917         *ret_conv = CResult_StringErrorZ_ok(o_conv);
21918         return tag_ptr(ret_conv, true);
21919 }
21920
21921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21922         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
21923         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
21924         *ret_conv = CResult_StringErrorZ_err(e_conv);
21925         return tag_ptr(ret_conv, true);
21926 }
21927
21928 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21929         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)untag_ptr(o);
21930         jboolean ret_conv = CResult_StringErrorZ_is_ok(o_conv);
21931         return ret_conv;
21932 }
21933
21934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21935         if (!ptr_is_owned(_res)) return;
21936         void* _res_ptr = untag_ptr(_res);
21937         CHECK_ACCESS(_res_ptr);
21938         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
21939         FREE(untag_ptr(_res));
21940         CResult_StringErrorZ_free(_res_conv);
21941 }
21942
21943 static inline uint64_t CResult_StringErrorZ_clone_ptr(LDKCResult_StringErrorZ *NONNULL_PTR arg) {
21944         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
21945         *ret_conv = CResult_StringErrorZ_clone(arg);
21946         return tag_ptr(ret_conv, true);
21947 }
21948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21949         LDKCResult_StringErrorZ* arg_conv = (LDKCResult_StringErrorZ*)untag_ptr(arg);
21950         int64_t ret_conv = CResult_StringErrorZ_clone_ptr(arg_conv);
21951         return ret_conv;
21952 }
21953
21954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21955         LDKCResult_StringErrorZ* orig_conv = (LDKCResult_StringErrorZ*)untag_ptr(orig);
21956         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
21957         *ret_conv = CResult_StringErrorZ_clone(orig_conv);
21958         return tag_ptr(ret_conv, true);
21959 }
21960
21961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21962         LDKChannelMonitorUpdate o_conv;
21963         o_conv.inner = untag_ptr(o);
21964         o_conv.is_owned = ptr_is_owned(o);
21965         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21966         o_conv = ChannelMonitorUpdate_clone(&o_conv);
21967         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
21968         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
21969         return tag_ptr(ret_conv, true);
21970 }
21971
21972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21973         void* e_ptr = untag_ptr(e);
21974         CHECK_ACCESS(e_ptr);
21975         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21976         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21977         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
21978         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
21979         return tag_ptr(ret_conv, true);
21980 }
21981
21982 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21983         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(o);
21984         jboolean ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
21985         return ret_conv;
21986 }
21987
21988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21989         if (!ptr_is_owned(_res)) return;
21990         void* _res_ptr = untag_ptr(_res);
21991         CHECK_ACCESS(_res_ptr);
21992         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
21993         FREE(untag_ptr(_res));
21994         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
21995 }
21996
21997 static inline uint64_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
21998         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
21999         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
22000         return tag_ptr(ret_conv, true);
22001 }
22002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22003         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(arg);
22004         int64_t ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
22005         return ret_conv;
22006 }
22007
22008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22009         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(orig);
22010         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22011         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
22012         return tag_ptr(ret_conv, true);
22013 }
22014
22015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
22016         void* o_ptr = untag_ptr(o);
22017         CHECK_ACCESS(o_ptr);
22018         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
22019         o_conv = MonitorEvent_clone((LDKMonitorEvent*)untag_ptr(o));
22020         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
22021         *ret_copy = COption_MonitorEventZ_some(o_conv);
22022         int64_t ret_ref = tag_ptr(ret_copy, true);
22023         return ret_ref;
22024 }
22025
22026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1none(JNIEnv *env, jclass clz) {
22027         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
22028         *ret_copy = COption_MonitorEventZ_none();
22029         int64_t ret_ref = tag_ptr(ret_copy, true);
22030         return ret_ref;
22031 }
22032
22033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22034         if (!ptr_is_owned(_res)) return;
22035         void* _res_ptr = untag_ptr(_res);
22036         CHECK_ACCESS(_res_ptr);
22037         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
22038         FREE(untag_ptr(_res));
22039         COption_MonitorEventZ_free(_res_conv);
22040 }
22041
22042 static inline uint64_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
22043         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
22044         *ret_copy = COption_MonitorEventZ_clone(arg);
22045         int64_t ret_ref = tag_ptr(ret_copy, true);
22046         return ret_ref;
22047 }
22048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22049         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)untag_ptr(arg);
22050         int64_t ret_conv = COption_MonitorEventZ_clone_ptr(arg_conv);
22051         return ret_conv;
22052 }
22053
22054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22055         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)untag_ptr(orig);
22056         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
22057         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
22058         int64_t ret_ref = tag_ptr(ret_copy, true);
22059         return ret_ref;
22060 }
22061
22062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22063         void* o_ptr = untag_ptr(o);
22064         CHECK_ACCESS(o_ptr);
22065         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
22066         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)untag_ptr(o));
22067         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22068         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
22069         return tag_ptr(ret_conv, true);
22070 }
22071
22072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22073         void* e_ptr = untag_ptr(e);
22074         CHECK_ACCESS(e_ptr);
22075         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22076         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22077         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22078         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
22079         return tag_ptr(ret_conv, true);
22080 }
22081
22082 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22083         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(o);
22084         jboolean ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
22085         return ret_conv;
22086 }
22087
22088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22089         if (!ptr_is_owned(_res)) return;
22090         void* _res_ptr = untag_ptr(_res);
22091         CHECK_ACCESS(_res_ptr);
22092         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
22093         FREE(untag_ptr(_res));
22094         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
22095 }
22096
22097 static inline uint64_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
22098         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22099         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
22100         return tag_ptr(ret_conv, true);
22101 }
22102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22103         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(arg);
22104         int64_t ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
22105         return ret_conv;
22106 }
22107
22108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22109         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(orig);
22110         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22111         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
22112         return tag_ptr(ret_conv, true);
22113 }
22114
22115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22116         LDKHTLCUpdate o_conv;
22117         o_conv.inner = untag_ptr(o);
22118         o_conv.is_owned = ptr_is_owned(o);
22119         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22120         o_conv = HTLCUpdate_clone(&o_conv);
22121         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22122         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
22123         return tag_ptr(ret_conv, true);
22124 }
22125
22126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22127         void* e_ptr = untag_ptr(e);
22128         CHECK_ACCESS(e_ptr);
22129         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22130         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22131         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22132         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
22133         return tag_ptr(ret_conv, true);
22134 }
22135
22136 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22137         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(o);
22138         jboolean ret_conv = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
22139         return ret_conv;
22140 }
22141
22142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22143         if (!ptr_is_owned(_res)) return;
22144         void* _res_ptr = untag_ptr(_res);
22145         CHECK_ACCESS(_res_ptr);
22146         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
22147         FREE(untag_ptr(_res));
22148         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
22149 }
22150
22151 static inline uint64_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
22152         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22153         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
22154         return tag_ptr(ret_conv, true);
22155 }
22156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22157         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(arg);
22158         int64_t ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
22159         return ret_conv;
22160 }
22161
22162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22163         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(orig);
22164         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22165         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
22166         return tag_ptr(ret_conv, true);
22167 }
22168
22169 static inline uint64_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
22170         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
22171         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
22172         return tag_ptr(ret_conv, true);
22173 }
22174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22175         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(arg);
22176         int64_t ret_conv = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
22177         return ret_conv;
22178 }
22179
22180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22181         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(orig);
22182         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
22183         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
22184         return tag_ptr(ret_conv, true);
22185 }
22186
22187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
22188         LDKOutPoint a_conv;
22189         a_conv.inner = untag_ptr(a);
22190         a_conv.is_owned = ptr_is_owned(a);
22191         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22192         a_conv = OutPoint_clone(&a_conv);
22193         LDKCVec_u8Z b_ref;
22194         b_ref.datalen = (*env)->GetArrayLength(env, b);
22195         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
22196         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
22197         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
22198         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
22199         return tag_ptr(ret_conv, true);
22200 }
22201
22202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22203         if (!ptr_is_owned(_res)) return;
22204         void* _res_ptr = untag_ptr(_res);
22205         CHECK_ACCESS(_res_ptr);
22206         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
22207         FREE(untag_ptr(_res));
22208         C2Tuple_OutPointScriptZ_free(_res_conv);
22209 }
22210
22211 static inline uint64_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
22212         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
22213         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
22214         return tag_ptr(ret_conv, true);
22215 }
22216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22217         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(arg);
22218         int64_t ret_conv = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
22219         return ret_conv;
22220 }
22221
22222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22223         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(orig);
22224         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
22225         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
22226         return tag_ptr(ret_conv, true);
22227 }
22228
22229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
22230         LDKCVec_u8Z b_ref;
22231         b_ref.datalen = (*env)->GetArrayLength(env, b);
22232         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
22233         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
22234         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
22235         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
22236         return tag_ptr(ret_conv, true);
22237 }
22238
22239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22240         if (!ptr_is_owned(_res)) return;
22241         void* _res_ptr = untag_ptr(_res);
22242         CHECK_ACCESS(_res_ptr);
22243         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
22244         FREE(untag_ptr(_res));
22245         C2Tuple_u32ScriptZ_free(_res_conv);
22246 }
22247
22248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22249         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
22250         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22251         if (_res_constr.datalen > 0)
22252                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
22253         else
22254                 _res_constr.data = NULL;
22255         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22256         for (size_t v = 0; v < _res_constr.datalen; v++) {
22257                 int64_t _res_conv_21 = _res_vals[v];
22258                 void* _res_conv_21_ptr = untag_ptr(_res_conv_21);
22259                 CHECK_ACCESS(_res_conv_21_ptr);
22260                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
22261                 FREE(untag_ptr(_res_conv_21));
22262                 _res_constr.data[v] = _res_conv_21_conv;
22263         }
22264         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22265         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
22266 }
22267
22268 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
22269         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
22270         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
22271         return tag_ptr(ret_conv, true);
22272 }
22273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22274         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(arg);
22275         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
22276         return ret_conv;
22277 }
22278
22279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22280         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(orig);
22281         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
22282         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
22283         return tag_ptr(ret_conv, true);
22284 }
22285
22286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
22287         LDKThirtyTwoBytes a_ref;
22288         CHECK((*env)->GetArrayLength(env, a) == 32);
22289         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
22290         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
22291         b_constr.datalen = (*env)->GetArrayLength(env, b);
22292         if (b_constr.datalen > 0)
22293                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
22294         else
22295                 b_constr.data = NULL;
22296         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
22297         for (size_t v = 0; v < b_constr.datalen; v++) {
22298                 int64_t b_conv_21 = b_vals[v];
22299                 void* b_conv_21_ptr = untag_ptr(b_conv_21);
22300                 CHECK_ACCESS(b_conv_21_ptr);
22301                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
22302                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)untag_ptr(b_conv_21));
22303                 b_constr.data[v] = b_conv_21_conv;
22304         }
22305         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
22306         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
22307         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
22308         return tag_ptr(ret_conv, true);
22309 }
22310
22311 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22312         if (!ptr_is_owned(_res)) return;
22313         void* _res_ptr = untag_ptr(_res);
22314         CHECK_ACCESS(_res_ptr);
22315         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
22316         FREE(untag_ptr(_res));
22317         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
22318 }
22319
22320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22321         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
22322         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22323         if (_res_constr.datalen > 0)
22324                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
22325         else
22326                 _res_constr.data = NULL;
22327         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22328         for (size_t o = 0; o < _res_constr.datalen; o++) {
22329                 int64_t _res_conv_40 = _res_vals[o];
22330                 void* _res_conv_40_ptr = untag_ptr(_res_conv_40);
22331                 CHECK_ACCESS(_res_conv_40_ptr);
22332                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
22333                 FREE(untag_ptr(_res_conv_40));
22334                 _res_constr.data[o] = _res_conv_40_conv;
22335         }
22336         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22337         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
22338 }
22339
22340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22341         LDKCVec_EventZ _res_constr;
22342         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22343         if (_res_constr.datalen > 0)
22344                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
22345         else
22346                 _res_constr.data = NULL;
22347         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22348         for (size_t h = 0; h < _res_constr.datalen; h++) {
22349                 int64_t _res_conv_7 = _res_vals[h];
22350                 void* _res_conv_7_ptr = untag_ptr(_res_conv_7);
22351                 CHECK_ACCESS(_res_conv_7_ptr);
22352                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
22353                 FREE(untag_ptr(_res_conv_7));
22354                 _res_constr.data[h] = _res_conv_7_conv;
22355         }
22356         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22357         CVec_EventZ_free(_res_constr);
22358 }
22359
22360 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
22361         LDKCVec_TransactionZ _res_constr;
22362         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22363         if (_res_constr.datalen > 0)
22364                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
22365         else
22366                 _res_constr.data = NULL;
22367         for (size_t i = 0; i < _res_constr.datalen; i++) {
22368                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
22369                 LDKTransaction _res_conv_8_ref;
22370                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
22371                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
22372                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
22373                 _res_conv_8_ref.data_is_owned = true;
22374                 _res_constr.data[i] = _res_conv_8_ref;
22375         }
22376         CVec_TransactionZ_free(_res_constr);
22377 }
22378
22379 static inline uint64_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
22380         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
22381         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
22382         return tag_ptr(ret_conv, true);
22383 }
22384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22385         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(arg);
22386         int64_t ret_conv = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
22387         return ret_conv;
22388 }
22389
22390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22391         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(orig);
22392         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
22393         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
22394         return tag_ptr(ret_conv, true);
22395 }
22396
22397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
22398         void* b_ptr = untag_ptr(b);
22399         CHECK_ACCESS(b_ptr);
22400         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
22401         b_conv = TxOut_clone((LDKTxOut*)untag_ptr(b));
22402         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
22403         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
22404         return tag_ptr(ret_conv, true);
22405 }
22406
22407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22408         if (!ptr_is_owned(_res)) return;
22409         void* _res_ptr = untag_ptr(_res);
22410         CHECK_ACCESS(_res_ptr);
22411         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
22412         FREE(untag_ptr(_res));
22413         C2Tuple_u32TxOutZ_free(_res_conv);
22414 }
22415
22416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22417         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
22418         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22419         if (_res_constr.datalen > 0)
22420                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
22421         else
22422                 _res_constr.data = NULL;
22423         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22424         for (size_t u = 0; u < _res_constr.datalen; u++) {
22425                 int64_t _res_conv_20 = _res_vals[u];
22426                 void* _res_conv_20_ptr = untag_ptr(_res_conv_20);
22427                 CHECK_ACCESS(_res_conv_20_ptr);
22428                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
22429                 FREE(untag_ptr(_res_conv_20));
22430                 _res_constr.data[u] = _res_conv_20_conv;
22431         }
22432         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22433         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
22434 }
22435
22436 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
22437         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22438         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
22439         return tag_ptr(ret_conv, true);
22440 }
22441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22442         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(arg);
22443         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
22444         return ret_conv;
22445 }
22446
22447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22448         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(orig);
22449         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22450         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
22451         return tag_ptr(ret_conv, true);
22452 }
22453
22454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
22455         LDKThirtyTwoBytes a_ref;
22456         CHECK((*env)->GetArrayLength(env, a) == 32);
22457         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
22458         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
22459         b_constr.datalen = (*env)->GetArrayLength(env, b);
22460         if (b_constr.datalen > 0)
22461                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
22462         else
22463                 b_constr.data = NULL;
22464         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
22465         for (size_t u = 0; u < b_constr.datalen; u++) {
22466                 int64_t b_conv_20 = b_vals[u];
22467                 void* b_conv_20_ptr = untag_ptr(b_conv_20);
22468                 CHECK_ACCESS(b_conv_20_ptr);
22469                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
22470                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)untag_ptr(b_conv_20));
22471                 b_constr.data[u] = b_conv_20_conv;
22472         }
22473         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
22474         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22475         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
22476         return tag_ptr(ret_conv, true);
22477 }
22478
22479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22480         if (!ptr_is_owned(_res)) return;
22481         void* _res_ptr = untag_ptr(_res);
22482         CHECK_ACCESS(_res_ptr);
22483         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
22484         FREE(untag_ptr(_res));
22485         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
22486 }
22487
22488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22489         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
22490         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22491         if (_res_constr.datalen > 0)
22492                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
22493         else
22494                 _res_constr.data = NULL;
22495         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22496         for (size_t n = 0; n < _res_constr.datalen; n++) {
22497                 int64_t _res_conv_39 = _res_vals[n];
22498                 void* _res_conv_39_ptr = untag_ptr(_res_conv_39);
22499                 CHECK_ACCESS(_res_conv_39_ptr);
22500                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
22501                 FREE(untag_ptr(_res_conv_39));
22502                 _res_constr.data[n] = _res_conv_39_conv;
22503         }
22504         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22505         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
22506 }
22507
22508 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22509         LDKCVec_BalanceZ _res_constr;
22510         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22511         if (_res_constr.datalen > 0)
22512                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
22513         else
22514                 _res_constr.data = NULL;
22515         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22516         for (size_t j = 0; j < _res_constr.datalen; j++) {
22517                 int64_t _res_conv_9 = _res_vals[j];
22518                 void* _res_conv_9_ptr = untag_ptr(_res_conv_9);
22519                 CHECK_ACCESS(_res_conv_9_ptr);
22520                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
22521                 FREE(untag_ptr(_res_conv_9));
22522                 _res_constr.data[j] = _res_conv_9_conv;
22523         }
22524         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22525         CVec_BalanceZ_free(_res_constr);
22526 }
22527
22528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22529         void* o_ptr = untag_ptr(o);
22530         CHECK_ACCESS(o_ptr);
22531         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
22532         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(o));
22533         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22534         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
22535         return tag_ptr(ret_conv, true);
22536 }
22537
22538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22539         void* e_ptr = untag_ptr(e);
22540         CHECK_ACCESS(e_ptr);
22541         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22542         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22543         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22544         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
22545         return tag_ptr(ret_conv, true);
22546 }
22547
22548 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22549         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(o);
22550         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
22551         return ret_conv;
22552 }
22553
22554 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22555         if (!ptr_is_owned(_res)) return;
22556         void* _res_ptr = untag_ptr(_res);
22557         CHECK_ACCESS(_res_ptr);
22558         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
22559         FREE(untag_ptr(_res));
22560         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
22561 }
22562
22563 static inline uint64_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
22564         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22565         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
22566         return tag_ptr(ret_conv, true);
22567 }
22568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22569         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(arg);
22570         int64_t ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
22571         return ret_conv;
22572 }
22573
22574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22575         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(orig);
22576         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22577         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
22578         return tag_ptr(ret_conv, true);
22579 }
22580
22581 static inline uint64_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
22582         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
22583         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
22584         return tag_ptr(ret_conv, true);
22585 }
22586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22587         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(arg);
22588         int64_t ret_conv = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
22589         return ret_conv;
22590 }
22591
22592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22593         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(orig);
22594         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
22595         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
22596         return tag_ptr(ret_conv, true);
22597 }
22598
22599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
22600         LDKPublicKey a_ref;
22601         CHECK((*env)->GetArrayLength(env, a) == 33);
22602         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
22603         void* b_ptr = untag_ptr(b);
22604         CHECK_ACCESS(b_ptr);
22605         LDKType b_conv = *(LDKType*)(b_ptr);
22606         if (b_conv.free == LDKType_JCalls_free) {
22607                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22608                 LDKType_JCalls_cloned(&b_conv);
22609         }
22610         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
22611         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
22612         return tag_ptr(ret_conv, true);
22613 }
22614
22615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22616         if (!ptr_is_owned(_res)) return;
22617         void* _res_ptr = untag_ptr(_res);
22618         CHECK_ACCESS(_res_ptr);
22619         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
22620         FREE(untag_ptr(_res));
22621         C2Tuple_PublicKeyTypeZ_free(_res_conv);
22622 }
22623
22624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22625         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
22626         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22627         if (_res_constr.datalen > 0)
22628                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
22629         else
22630                 _res_constr.data = NULL;
22631         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22632         for (size_t z = 0; z < _res_constr.datalen; z++) {
22633                 int64_t _res_conv_25 = _res_vals[z];
22634                 void* _res_conv_25_ptr = untag_ptr(_res_conv_25);
22635                 CHECK_ACCESS(_res_conv_25_ptr);
22636                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
22637                 FREE(untag_ptr(_res_conv_25));
22638                 _res_constr.data[z] = _res_conv_25_conv;
22639         }
22640         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22641         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
22642 }
22643
22644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1some(JNIEnv *env, jclass clz, int64_t o) {
22645         void* o_ptr = untag_ptr(o);
22646         CHECK_ACCESS(o_ptr);
22647         LDKCustomOnionMessageContents o_conv = *(LDKCustomOnionMessageContents*)(o_ptr);
22648         if (o_conv.free == LDKCustomOnionMessageContents_JCalls_free) {
22649                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22650                 LDKCustomOnionMessageContents_JCalls_cloned(&o_conv);
22651         }
22652         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
22653         *ret_copy = COption_CustomOnionMessageContentsZ_some(o_conv);
22654         int64_t ret_ref = tag_ptr(ret_copy, true);
22655         return ret_ref;
22656 }
22657
22658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1none(JNIEnv *env, jclass clz) {
22659         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
22660         *ret_copy = COption_CustomOnionMessageContentsZ_none();
22661         int64_t ret_ref = tag_ptr(ret_copy, true);
22662         return ret_ref;
22663 }
22664
22665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22666         if (!ptr_is_owned(_res)) return;
22667         void* _res_ptr = untag_ptr(_res);
22668         CHECK_ACCESS(_res_ptr);
22669         LDKCOption_CustomOnionMessageContentsZ _res_conv = *(LDKCOption_CustomOnionMessageContentsZ*)(_res_ptr);
22670         FREE(untag_ptr(_res));
22671         COption_CustomOnionMessageContentsZ_free(_res_conv);
22672 }
22673
22674 static inline uint64_t COption_CustomOnionMessageContentsZ_clone_ptr(LDKCOption_CustomOnionMessageContentsZ *NONNULL_PTR arg) {
22675         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
22676         *ret_copy = COption_CustomOnionMessageContentsZ_clone(arg);
22677         int64_t ret_ref = tag_ptr(ret_copy, true);
22678         return ret_ref;
22679 }
22680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22681         LDKCOption_CustomOnionMessageContentsZ* arg_conv = (LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(arg);
22682         int64_t ret_conv = COption_CustomOnionMessageContentsZ_clone_ptr(arg_conv);
22683         return ret_conv;
22684 }
22685
22686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22687         LDKCOption_CustomOnionMessageContentsZ* orig_conv = (LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(orig);
22688         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
22689         *ret_copy = COption_CustomOnionMessageContentsZ_clone(orig_conv);
22690         int64_t ret_ref = tag_ptr(ret_copy, true);
22691         return ret_ref;
22692 }
22693
22694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22695         void* o_ptr = untag_ptr(o);
22696         CHECK_ACCESS(o_ptr);
22697         LDKCOption_CustomOnionMessageContentsZ o_conv = *(LDKCOption_CustomOnionMessageContentsZ*)(o_ptr);
22698         o_conv = COption_CustomOnionMessageContentsZ_clone((LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(o));
22699         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
22700         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_ok(o_conv);
22701         return tag_ptr(ret_conv, true);
22702 }
22703
22704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22705         void* e_ptr = untag_ptr(e);
22706         CHECK_ACCESS(e_ptr);
22707         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22708         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22709         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
22710         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_err(e_conv);
22711         return tag_ptr(ret_conv, true);
22712 }
22713
22714 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22715         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* o_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(o);
22716         jboolean ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_is_ok(o_conv);
22717         return ret_conv;
22718 }
22719
22720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22721         if (!ptr_is_owned(_res)) return;
22722         void* _res_ptr = untag_ptr(_res);
22723         CHECK_ACCESS(_res_ptr);
22724         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ _res_conv = *(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)(_res_ptr);
22725         FREE(untag_ptr(_res));
22726         CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_free(_res_conv);
22727 }
22728
22729 static inline uint64_t CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone_ptr(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ *NONNULL_PTR arg) {
22730         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
22731         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone(arg);
22732         return tag_ptr(ret_conv, true);
22733 }
22734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22735         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* arg_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(arg);
22736         int64_t ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone_ptr(arg_conv);
22737         return ret_conv;
22738 }
22739
22740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22741         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* orig_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(orig);
22742         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
22743         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone(orig_conv);
22744         return tag_ptr(ret_conv, true);
22745 }
22746
22747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1some(JNIEnv *env, jclass clz, int64_t o) {
22748         void* o_ptr = untag_ptr(o);
22749         CHECK_ACCESS(o_ptr);
22750         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
22751         o_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o));
22752         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
22753         *ret_copy = COption_NetAddressZ_some(o_conv);
22754         int64_t ret_ref = tag_ptr(ret_copy, true);
22755         return ret_ref;
22756 }
22757
22758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1none(JNIEnv *env, jclass clz) {
22759         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
22760         *ret_copy = COption_NetAddressZ_none();
22761         int64_t ret_ref = tag_ptr(ret_copy, true);
22762         return ret_ref;
22763 }
22764
22765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22766         if (!ptr_is_owned(_res)) return;
22767         void* _res_ptr = untag_ptr(_res);
22768         CHECK_ACCESS(_res_ptr);
22769         LDKCOption_NetAddressZ _res_conv = *(LDKCOption_NetAddressZ*)(_res_ptr);
22770         FREE(untag_ptr(_res));
22771         COption_NetAddressZ_free(_res_conv);
22772 }
22773
22774 static inline uint64_t COption_NetAddressZ_clone_ptr(LDKCOption_NetAddressZ *NONNULL_PTR arg) {
22775         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
22776         *ret_copy = COption_NetAddressZ_clone(arg);
22777         int64_t ret_ref = tag_ptr(ret_copy, true);
22778         return ret_ref;
22779 }
22780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22781         LDKCOption_NetAddressZ* arg_conv = (LDKCOption_NetAddressZ*)untag_ptr(arg);
22782         int64_t ret_conv = COption_NetAddressZ_clone_ptr(arg_conv);
22783         return ret_conv;
22784 }
22785
22786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22787         LDKCOption_NetAddressZ* orig_conv = (LDKCOption_NetAddressZ*)untag_ptr(orig);
22788         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
22789         *ret_copy = COption_NetAddressZ_clone(orig_conv);
22790         int64_t ret_ref = tag_ptr(ret_copy, true);
22791         return ret_ref;
22792 }
22793
22794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
22795         LDKCVec_u8Z o_ref;
22796         o_ref.datalen = (*env)->GetArrayLength(env, o);
22797         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
22798         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
22799         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
22800         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
22801         return tag_ptr(ret_conv, true);
22802 }
22803
22804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22805         LDKPeerHandleError e_conv;
22806         e_conv.inner = untag_ptr(e);
22807         e_conv.is_owned = ptr_is_owned(e);
22808         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22809         e_conv = PeerHandleError_clone(&e_conv);
22810         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
22811         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
22812         return tag_ptr(ret_conv, true);
22813 }
22814
22815 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22816         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(o);
22817         jboolean ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
22818         return ret_conv;
22819 }
22820
22821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22822         if (!ptr_is_owned(_res)) return;
22823         void* _res_ptr = untag_ptr(_res);
22824         CHECK_ACCESS(_res_ptr);
22825         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
22826         FREE(untag_ptr(_res));
22827         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
22828 }
22829
22830 static inline uint64_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
22831         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
22832         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
22833         return tag_ptr(ret_conv, true);
22834 }
22835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22836         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(arg);
22837         int64_t ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
22838         return ret_conv;
22839 }
22840
22841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22842         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(orig);
22843         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
22844         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
22845         return tag_ptr(ret_conv, true);
22846 }
22847
22848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
22849         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22850         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
22851         return tag_ptr(ret_conv, true);
22852 }
22853
22854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22855         LDKPeerHandleError e_conv;
22856         e_conv.inner = untag_ptr(e);
22857         e_conv.is_owned = ptr_is_owned(e);
22858         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22859         e_conv = PeerHandleError_clone(&e_conv);
22860         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22861         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
22862         return tag_ptr(ret_conv, true);
22863 }
22864
22865 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22866         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(o);
22867         jboolean ret_conv = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
22868         return ret_conv;
22869 }
22870
22871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22872         if (!ptr_is_owned(_res)) return;
22873         void* _res_ptr = untag_ptr(_res);
22874         CHECK_ACCESS(_res_ptr);
22875         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
22876         FREE(untag_ptr(_res));
22877         CResult_NonePeerHandleErrorZ_free(_res_conv);
22878 }
22879
22880 static inline uint64_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
22881         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22882         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
22883         return tag_ptr(ret_conv, true);
22884 }
22885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22886         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(arg);
22887         int64_t ret_conv = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
22888         return ret_conv;
22889 }
22890
22891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22892         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(orig);
22893         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22894         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
22895         return tag_ptr(ret_conv, true);
22896 }
22897
22898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
22899         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
22900         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
22901         return tag_ptr(ret_conv, true);
22902 }
22903
22904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22905         LDKPeerHandleError e_conv;
22906         e_conv.inner = untag_ptr(e);
22907         e_conv.is_owned = ptr_is_owned(e);
22908         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22909         e_conv = PeerHandleError_clone(&e_conv);
22910         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
22911         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
22912         return tag_ptr(ret_conv, true);
22913 }
22914
22915 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22916         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(o);
22917         jboolean ret_conv = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
22918         return ret_conv;
22919 }
22920
22921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22922         if (!ptr_is_owned(_res)) return;
22923         void* _res_ptr = untag_ptr(_res);
22924         CHECK_ACCESS(_res_ptr);
22925         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
22926         FREE(untag_ptr(_res));
22927         CResult_boolPeerHandleErrorZ_free(_res_conv);
22928 }
22929
22930 static inline uint64_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
22931         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
22932         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
22933         return tag_ptr(ret_conv, true);
22934 }
22935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22936         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(arg);
22937         int64_t ret_conv = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
22938         return ret_conv;
22939 }
22940
22941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22942         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(orig);
22943         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
22944         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
22945         return tag_ptr(ret_conv, true);
22946 }
22947
22948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1ok(JNIEnv *env, jclass clz) {
22949         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
22950         *ret_conv = CResult_NoneSendErrorZ_ok();
22951         return tag_ptr(ret_conv, true);
22952 }
22953
22954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22955         void* e_ptr = untag_ptr(e);
22956         CHECK_ACCESS(e_ptr);
22957         LDKSendError e_conv = *(LDKSendError*)(e_ptr);
22958         e_conv = SendError_clone((LDKSendError*)untag_ptr(e));
22959         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
22960         *ret_conv = CResult_NoneSendErrorZ_err(e_conv);
22961         return tag_ptr(ret_conv, true);
22962 }
22963
22964 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22965         LDKCResult_NoneSendErrorZ* o_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(o);
22966         jboolean ret_conv = CResult_NoneSendErrorZ_is_ok(o_conv);
22967         return ret_conv;
22968 }
22969
22970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22971         if (!ptr_is_owned(_res)) return;
22972         void* _res_ptr = untag_ptr(_res);
22973         CHECK_ACCESS(_res_ptr);
22974         LDKCResult_NoneSendErrorZ _res_conv = *(LDKCResult_NoneSendErrorZ*)(_res_ptr);
22975         FREE(untag_ptr(_res));
22976         CResult_NoneSendErrorZ_free(_res_conv);
22977 }
22978
22979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1ok(JNIEnv *env, jclass clz, int32_t o) {
22980         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
22981         *ret_conv = CResult_u32GraphSyncErrorZ_ok(o);
22982         return tag_ptr(ret_conv, true);
22983 }
22984
22985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22986         void* e_ptr = untag_ptr(e);
22987         CHECK_ACCESS(e_ptr);
22988         LDKGraphSyncError e_conv = *(LDKGraphSyncError*)(e_ptr);
22989         e_conv = GraphSyncError_clone((LDKGraphSyncError*)untag_ptr(e));
22990         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
22991         *ret_conv = CResult_u32GraphSyncErrorZ_err(e_conv);
22992         return tag_ptr(ret_conv, true);
22993 }
22994
22995 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22996         LDKCResult_u32GraphSyncErrorZ* o_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(o);
22997         jboolean ret_conv = CResult_u32GraphSyncErrorZ_is_ok(o_conv);
22998         return ret_conv;
22999 }
23000
23001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23002         if (!ptr_is_owned(_res)) return;
23003         void* _res_ptr = untag_ptr(_res);
23004         CHECK_ACCESS(_res_ptr);
23005         LDKCResult_u32GraphSyncErrorZ _res_conv = *(LDKCResult_u32GraphSyncErrorZ*)(_res_ptr);
23006         FREE(untag_ptr(_res));
23007         CResult_u32GraphSyncErrorZ_free(_res_conv);
23008 }
23009
23010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23011         void* o_ptr = untag_ptr(o);
23012         CHECK_ACCESS(o_ptr);
23013         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
23014         o_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o));
23015         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
23016         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
23017         return tag_ptr(ret_conv, true);
23018 }
23019
23020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23021         void* e_ptr = untag_ptr(e);
23022         CHECK_ACCESS(e_ptr);
23023         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23024         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23025         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
23026         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
23027         return tag_ptr(ret_conv, true);
23028 }
23029
23030 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23031         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(o);
23032         jboolean ret_conv = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
23033         return ret_conv;
23034 }
23035
23036 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23037         if (!ptr_is_owned(_res)) return;
23038         void* _res_ptr = untag_ptr(_res);
23039         CHECK_ACCESS(_res_ptr);
23040         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
23041         FREE(untag_ptr(_res));
23042         CResult_NetAddressDecodeErrorZ_free(_res_conv);
23043 }
23044
23045 static inline uint64_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
23046         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
23047         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
23048         return tag_ptr(ret_conv, true);
23049 }
23050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23051         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(arg);
23052         int64_t ret_conv = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
23053         return ret_conv;
23054 }
23055
23056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23057         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(orig);
23058         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
23059         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
23060         return tag_ptr(ret_conv, true);
23061 }
23062
23063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23064         LDKCVec_UpdateAddHTLCZ _res_constr;
23065         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23066         if (_res_constr.datalen > 0)
23067                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
23068         else
23069                 _res_constr.data = NULL;
23070         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23071         for (size_t p = 0; p < _res_constr.datalen; p++) {
23072                 int64_t _res_conv_15 = _res_vals[p];
23073                 LDKUpdateAddHTLC _res_conv_15_conv;
23074                 _res_conv_15_conv.inner = untag_ptr(_res_conv_15);
23075                 _res_conv_15_conv.is_owned = ptr_is_owned(_res_conv_15);
23076                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
23077                 _res_constr.data[p] = _res_conv_15_conv;
23078         }
23079         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23080         CVec_UpdateAddHTLCZ_free(_res_constr);
23081 }
23082
23083 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23084         LDKCVec_UpdateFulfillHTLCZ _res_constr;
23085         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23086         if (_res_constr.datalen > 0)
23087                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
23088         else
23089                 _res_constr.data = NULL;
23090         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23091         for (size_t t = 0; t < _res_constr.datalen; t++) {
23092                 int64_t _res_conv_19 = _res_vals[t];
23093                 LDKUpdateFulfillHTLC _res_conv_19_conv;
23094                 _res_conv_19_conv.inner = untag_ptr(_res_conv_19);
23095                 _res_conv_19_conv.is_owned = ptr_is_owned(_res_conv_19);
23096                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
23097                 _res_constr.data[t] = _res_conv_19_conv;
23098         }
23099         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23100         CVec_UpdateFulfillHTLCZ_free(_res_constr);
23101 }
23102
23103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23104         LDKCVec_UpdateFailHTLCZ _res_constr;
23105         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23106         if (_res_constr.datalen > 0)
23107                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
23108         else
23109                 _res_constr.data = NULL;
23110         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23111         for (size_t q = 0; q < _res_constr.datalen; q++) {
23112                 int64_t _res_conv_16 = _res_vals[q];
23113                 LDKUpdateFailHTLC _res_conv_16_conv;
23114                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
23115                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
23116                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
23117                 _res_constr.data[q] = _res_conv_16_conv;
23118         }
23119         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23120         CVec_UpdateFailHTLCZ_free(_res_constr);
23121 }
23122
23123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23124         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
23125         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23126         if (_res_constr.datalen > 0)
23127                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
23128         else
23129                 _res_constr.data = NULL;
23130         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23131         for (size_t z = 0; z < _res_constr.datalen; z++) {
23132                 int64_t _res_conv_25 = _res_vals[z];
23133                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
23134                 _res_conv_25_conv.inner = untag_ptr(_res_conv_25);
23135                 _res_conv_25_conv.is_owned = ptr_is_owned(_res_conv_25);
23136                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
23137                 _res_constr.data[z] = _res_conv_25_conv;
23138         }
23139         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23140         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
23141 }
23142
23143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23144         LDKAcceptChannel o_conv;
23145         o_conv.inner = untag_ptr(o);
23146         o_conv.is_owned = ptr_is_owned(o);
23147         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23148         o_conv = AcceptChannel_clone(&o_conv);
23149         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
23150         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
23151         return tag_ptr(ret_conv, true);
23152 }
23153
23154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23155         void* e_ptr = untag_ptr(e);
23156         CHECK_ACCESS(e_ptr);
23157         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23158         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23159         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
23160         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
23161         return tag_ptr(ret_conv, true);
23162 }
23163
23164 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23165         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(o);
23166         jboolean ret_conv = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
23167         return ret_conv;
23168 }
23169
23170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23171         if (!ptr_is_owned(_res)) return;
23172         void* _res_ptr = untag_ptr(_res);
23173         CHECK_ACCESS(_res_ptr);
23174         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
23175         FREE(untag_ptr(_res));
23176         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
23177 }
23178
23179 static inline uint64_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
23180         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
23181         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
23182         return tag_ptr(ret_conv, true);
23183 }
23184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23185         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(arg);
23186         int64_t ret_conv = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
23187         return ret_conv;
23188 }
23189
23190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23191         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(orig);
23192         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
23193         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
23194         return tag_ptr(ret_conv, true);
23195 }
23196
23197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23198         LDKAnnouncementSignatures o_conv;
23199         o_conv.inner = untag_ptr(o);
23200         o_conv.is_owned = ptr_is_owned(o);
23201         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23202         o_conv = AnnouncementSignatures_clone(&o_conv);
23203         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
23204         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
23205         return tag_ptr(ret_conv, true);
23206 }
23207
23208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23209         void* e_ptr = untag_ptr(e);
23210         CHECK_ACCESS(e_ptr);
23211         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23212         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23213         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
23214         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
23215         return tag_ptr(ret_conv, true);
23216 }
23217
23218 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23219         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(o);
23220         jboolean ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
23221         return ret_conv;
23222 }
23223
23224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23225         if (!ptr_is_owned(_res)) return;
23226         void* _res_ptr = untag_ptr(_res);
23227         CHECK_ACCESS(_res_ptr);
23228         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
23229         FREE(untag_ptr(_res));
23230         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
23231 }
23232
23233 static inline uint64_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
23234         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
23235         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
23236         return tag_ptr(ret_conv, true);
23237 }
23238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23239         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(arg);
23240         int64_t ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
23241         return ret_conv;
23242 }
23243
23244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23245         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(orig);
23246         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
23247         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
23248         return tag_ptr(ret_conv, true);
23249 }
23250
23251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23252         LDKChannelReestablish o_conv;
23253         o_conv.inner = untag_ptr(o);
23254         o_conv.is_owned = ptr_is_owned(o);
23255         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23256         o_conv = ChannelReestablish_clone(&o_conv);
23257         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
23258         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
23259         return tag_ptr(ret_conv, true);
23260 }
23261
23262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23263         void* e_ptr = untag_ptr(e);
23264         CHECK_ACCESS(e_ptr);
23265         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23266         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23267         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
23268         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
23269         return tag_ptr(ret_conv, true);
23270 }
23271
23272 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23273         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(o);
23274         jboolean ret_conv = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
23275         return ret_conv;
23276 }
23277
23278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23279         if (!ptr_is_owned(_res)) return;
23280         void* _res_ptr = untag_ptr(_res);
23281         CHECK_ACCESS(_res_ptr);
23282         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
23283         FREE(untag_ptr(_res));
23284         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
23285 }
23286
23287 static inline uint64_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
23288         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
23289         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
23290         return tag_ptr(ret_conv, true);
23291 }
23292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23293         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(arg);
23294         int64_t ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
23295         return ret_conv;
23296 }
23297
23298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23299         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(orig);
23300         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
23301         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
23302         return tag_ptr(ret_conv, true);
23303 }
23304
23305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23306         LDKClosingSigned o_conv;
23307         o_conv.inner = untag_ptr(o);
23308         o_conv.is_owned = ptr_is_owned(o);
23309         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23310         o_conv = ClosingSigned_clone(&o_conv);
23311         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
23312         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
23313         return tag_ptr(ret_conv, true);
23314 }
23315
23316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23317         void* e_ptr = untag_ptr(e);
23318         CHECK_ACCESS(e_ptr);
23319         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23320         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23321         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
23322         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
23323         return tag_ptr(ret_conv, true);
23324 }
23325
23326 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23327         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(o);
23328         jboolean ret_conv = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
23329         return ret_conv;
23330 }
23331
23332 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23333         if (!ptr_is_owned(_res)) return;
23334         void* _res_ptr = untag_ptr(_res);
23335         CHECK_ACCESS(_res_ptr);
23336         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
23337         FREE(untag_ptr(_res));
23338         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
23339 }
23340
23341 static inline uint64_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
23342         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
23343         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
23344         return tag_ptr(ret_conv, true);
23345 }
23346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23347         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(arg);
23348         int64_t ret_conv = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
23349         return ret_conv;
23350 }
23351
23352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23353         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(orig);
23354         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
23355         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
23356         return tag_ptr(ret_conv, true);
23357 }
23358
23359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23360         LDKClosingSignedFeeRange o_conv;
23361         o_conv.inner = untag_ptr(o);
23362         o_conv.is_owned = ptr_is_owned(o);
23363         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23364         o_conv = ClosingSignedFeeRange_clone(&o_conv);
23365         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
23366         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
23367         return tag_ptr(ret_conv, true);
23368 }
23369
23370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23371         void* e_ptr = untag_ptr(e);
23372         CHECK_ACCESS(e_ptr);
23373         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23374         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23375         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
23376         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
23377         return tag_ptr(ret_conv, true);
23378 }
23379
23380 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23381         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(o);
23382         jboolean ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
23383         return ret_conv;
23384 }
23385
23386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23387         if (!ptr_is_owned(_res)) return;
23388         void* _res_ptr = untag_ptr(_res);
23389         CHECK_ACCESS(_res_ptr);
23390         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
23391         FREE(untag_ptr(_res));
23392         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
23393 }
23394
23395 static inline uint64_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
23396         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
23397         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
23398         return tag_ptr(ret_conv, true);
23399 }
23400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23401         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(arg);
23402         int64_t ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
23403         return ret_conv;
23404 }
23405
23406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23407         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(orig);
23408         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
23409         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
23410         return tag_ptr(ret_conv, true);
23411 }
23412
23413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23414         LDKCommitmentSigned o_conv;
23415         o_conv.inner = untag_ptr(o);
23416         o_conv.is_owned = ptr_is_owned(o);
23417         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23418         o_conv = CommitmentSigned_clone(&o_conv);
23419         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
23420         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
23421         return tag_ptr(ret_conv, true);
23422 }
23423
23424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23425         void* e_ptr = untag_ptr(e);
23426         CHECK_ACCESS(e_ptr);
23427         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23428         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23429         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
23430         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
23431         return tag_ptr(ret_conv, true);
23432 }
23433
23434 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23435         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(o);
23436         jboolean ret_conv = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
23437         return ret_conv;
23438 }
23439
23440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23441         if (!ptr_is_owned(_res)) return;
23442         void* _res_ptr = untag_ptr(_res);
23443         CHECK_ACCESS(_res_ptr);
23444         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
23445         FREE(untag_ptr(_res));
23446         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
23447 }
23448
23449 static inline uint64_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
23450         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
23451         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
23452         return tag_ptr(ret_conv, true);
23453 }
23454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23455         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(arg);
23456         int64_t ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
23457         return ret_conv;
23458 }
23459
23460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23461         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(orig);
23462         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
23463         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
23464         return tag_ptr(ret_conv, true);
23465 }
23466
23467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23468         LDKFundingCreated o_conv;
23469         o_conv.inner = untag_ptr(o);
23470         o_conv.is_owned = ptr_is_owned(o);
23471         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23472         o_conv = FundingCreated_clone(&o_conv);
23473         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
23474         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
23475         return tag_ptr(ret_conv, true);
23476 }
23477
23478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23479         void* e_ptr = untag_ptr(e);
23480         CHECK_ACCESS(e_ptr);
23481         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23482         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23483         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
23484         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
23485         return tag_ptr(ret_conv, true);
23486 }
23487
23488 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23489         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(o);
23490         jboolean ret_conv = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
23491         return ret_conv;
23492 }
23493
23494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23495         if (!ptr_is_owned(_res)) return;
23496         void* _res_ptr = untag_ptr(_res);
23497         CHECK_ACCESS(_res_ptr);
23498         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
23499         FREE(untag_ptr(_res));
23500         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
23501 }
23502
23503 static inline uint64_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
23504         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
23505         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
23506         return tag_ptr(ret_conv, true);
23507 }
23508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23509         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(arg);
23510         int64_t ret_conv = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
23511         return ret_conv;
23512 }
23513
23514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23515         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(orig);
23516         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
23517         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
23518         return tag_ptr(ret_conv, true);
23519 }
23520
23521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23522         LDKFundingSigned o_conv;
23523         o_conv.inner = untag_ptr(o);
23524         o_conv.is_owned = ptr_is_owned(o);
23525         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23526         o_conv = FundingSigned_clone(&o_conv);
23527         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
23528         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
23529         return tag_ptr(ret_conv, true);
23530 }
23531
23532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23533         void* e_ptr = untag_ptr(e);
23534         CHECK_ACCESS(e_ptr);
23535         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23536         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23537         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
23538         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
23539         return tag_ptr(ret_conv, true);
23540 }
23541
23542 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23543         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(o);
23544         jboolean ret_conv = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
23545         return ret_conv;
23546 }
23547
23548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23549         if (!ptr_is_owned(_res)) return;
23550         void* _res_ptr = untag_ptr(_res);
23551         CHECK_ACCESS(_res_ptr);
23552         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
23553         FREE(untag_ptr(_res));
23554         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
23555 }
23556
23557 static inline uint64_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
23558         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
23559         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
23560         return tag_ptr(ret_conv, true);
23561 }
23562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23563         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(arg);
23564         int64_t ret_conv = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
23565         return ret_conv;
23566 }
23567
23568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23569         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(orig);
23570         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
23571         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
23572         return tag_ptr(ret_conv, true);
23573 }
23574
23575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23576         LDKChannelReady o_conv;
23577         o_conv.inner = untag_ptr(o);
23578         o_conv.is_owned = ptr_is_owned(o);
23579         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23580         o_conv = ChannelReady_clone(&o_conv);
23581         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
23582         *ret_conv = CResult_ChannelReadyDecodeErrorZ_ok(o_conv);
23583         return tag_ptr(ret_conv, true);
23584 }
23585
23586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23587         void* e_ptr = untag_ptr(e);
23588         CHECK_ACCESS(e_ptr);
23589         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23590         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23591         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
23592         *ret_conv = CResult_ChannelReadyDecodeErrorZ_err(e_conv);
23593         return tag_ptr(ret_conv, true);
23594 }
23595
23596 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23597         LDKCResult_ChannelReadyDecodeErrorZ* o_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(o);
23598         jboolean ret_conv = CResult_ChannelReadyDecodeErrorZ_is_ok(o_conv);
23599         return ret_conv;
23600 }
23601
23602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23603         if (!ptr_is_owned(_res)) return;
23604         void* _res_ptr = untag_ptr(_res);
23605         CHECK_ACCESS(_res_ptr);
23606         LDKCResult_ChannelReadyDecodeErrorZ _res_conv = *(LDKCResult_ChannelReadyDecodeErrorZ*)(_res_ptr);
23607         FREE(untag_ptr(_res));
23608         CResult_ChannelReadyDecodeErrorZ_free(_res_conv);
23609 }
23610
23611 static inline uint64_t CResult_ChannelReadyDecodeErrorZ_clone_ptr(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR arg) {
23612         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
23613         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(arg);
23614         return tag_ptr(ret_conv, true);
23615 }
23616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23617         LDKCResult_ChannelReadyDecodeErrorZ* arg_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(arg);
23618         int64_t ret_conv = CResult_ChannelReadyDecodeErrorZ_clone_ptr(arg_conv);
23619         return ret_conv;
23620 }
23621
23622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23623         LDKCResult_ChannelReadyDecodeErrorZ* orig_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(orig);
23624         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
23625         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(orig_conv);
23626         return tag_ptr(ret_conv, true);
23627 }
23628
23629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23630         LDKInit o_conv;
23631         o_conv.inner = untag_ptr(o);
23632         o_conv.is_owned = ptr_is_owned(o);
23633         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23634         o_conv = Init_clone(&o_conv);
23635         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
23636         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
23637         return tag_ptr(ret_conv, true);
23638 }
23639
23640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23641         void* e_ptr = untag_ptr(e);
23642         CHECK_ACCESS(e_ptr);
23643         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23644         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23645         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
23646         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
23647         return tag_ptr(ret_conv, true);
23648 }
23649
23650 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23651         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(o);
23652         jboolean ret_conv = CResult_InitDecodeErrorZ_is_ok(o_conv);
23653         return ret_conv;
23654 }
23655
23656 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23657         if (!ptr_is_owned(_res)) return;
23658         void* _res_ptr = untag_ptr(_res);
23659         CHECK_ACCESS(_res_ptr);
23660         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
23661         FREE(untag_ptr(_res));
23662         CResult_InitDecodeErrorZ_free(_res_conv);
23663 }
23664
23665 static inline uint64_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
23666         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
23667         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
23668         return tag_ptr(ret_conv, true);
23669 }
23670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23671         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(arg);
23672         int64_t ret_conv = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
23673         return ret_conv;
23674 }
23675
23676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23677         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(orig);
23678         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
23679         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
23680         return tag_ptr(ret_conv, true);
23681 }
23682
23683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23684         LDKOpenChannel o_conv;
23685         o_conv.inner = untag_ptr(o);
23686         o_conv.is_owned = ptr_is_owned(o);
23687         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23688         o_conv = OpenChannel_clone(&o_conv);
23689         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
23690         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
23691         return tag_ptr(ret_conv, true);
23692 }
23693
23694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23695         void* e_ptr = untag_ptr(e);
23696         CHECK_ACCESS(e_ptr);
23697         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23698         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23699         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
23700         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
23701         return tag_ptr(ret_conv, true);
23702 }
23703
23704 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23705         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(o);
23706         jboolean ret_conv = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
23707         return ret_conv;
23708 }
23709
23710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23711         if (!ptr_is_owned(_res)) return;
23712         void* _res_ptr = untag_ptr(_res);
23713         CHECK_ACCESS(_res_ptr);
23714         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
23715         FREE(untag_ptr(_res));
23716         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
23717 }
23718
23719 static inline uint64_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
23720         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
23721         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
23722         return tag_ptr(ret_conv, true);
23723 }
23724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23725         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(arg);
23726         int64_t ret_conv = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
23727         return ret_conv;
23728 }
23729
23730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23731         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(orig);
23732         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
23733         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
23734         return tag_ptr(ret_conv, true);
23735 }
23736
23737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23738         LDKRevokeAndACK o_conv;
23739         o_conv.inner = untag_ptr(o);
23740         o_conv.is_owned = ptr_is_owned(o);
23741         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23742         o_conv = RevokeAndACK_clone(&o_conv);
23743         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
23744         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
23745         return tag_ptr(ret_conv, true);
23746 }
23747
23748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23749         void* e_ptr = untag_ptr(e);
23750         CHECK_ACCESS(e_ptr);
23751         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23752         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23753         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
23754         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
23755         return tag_ptr(ret_conv, true);
23756 }
23757
23758 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23759         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(o);
23760         jboolean ret_conv = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
23761         return ret_conv;
23762 }
23763
23764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23765         if (!ptr_is_owned(_res)) return;
23766         void* _res_ptr = untag_ptr(_res);
23767         CHECK_ACCESS(_res_ptr);
23768         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
23769         FREE(untag_ptr(_res));
23770         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
23771 }
23772
23773 static inline uint64_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
23774         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
23775         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
23776         return tag_ptr(ret_conv, true);
23777 }
23778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23779         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(arg);
23780         int64_t ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
23781         return ret_conv;
23782 }
23783
23784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23785         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(orig);
23786         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
23787         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
23788         return tag_ptr(ret_conv, true);
23789 }
23790
23791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23792         LDKShutdown o_conv;
23793         o_conv.inner = untag_ptr(o);
23794         o_conv.is_owned = ptr_is_owned(o);
23795         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23796         o_conv = Shutdown_clone(&o_conv);
23797         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
23798         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
23799         return tag_ptr(ret_conv, true);
23800 }
23801
23802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23803         void* e_ptr = untag_ptr(e);
23804         CHECK_ACCESS(e_ptr);
23805         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23806         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23807         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
23808         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
23809         return tag_ptr(ret_conv, true);
23810 }
23811
23812 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23813         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(o);
23814         jboolean ret_conv = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
23815         return ret_conv;
23816 }
23817
23818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23819         if (!ptr_is_owned(_res)) return;
23820         void* _res_ptr = untag_ptr(_res);
23821         CHECK_ACCESS(_res_ptr);
23822         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
23823         FREE(untag_ptr(_res));
23824         CResult_ShutdownDecodeErrorZ_free(_res_conv);
23825 }
23826
23827 static inline uint64_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
23828         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
23829         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
23830         return tag_ptr(ret_conv, true);
23831 }
23832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23833         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(arg);
23834         int64_t ret_conv = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
23835         return ret_conv;
23836 }
23837
23838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23839         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(orig);
23840         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
23841         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
23842         return tag_ptr(ret_conv, true);
23843 }
23844
23845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23846         LDKUpdateFailHTLC o_conv;
23847         o_conv.inner = untag_ptr(o);
23848         o_conv.is_owned = ptr_is_owned(o);
23849         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23850         o_conv = UpdateFailHTLC_clone(&o_conv);
23851         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
23852         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
23853         return tag_ptr(ret_conv, true);
23854 }
23855
23856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23857         void* e_ptr = untag_ptr(e);
23858         CHECK_ACCESS(e_ptr);
23859         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23860         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23861         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
23862         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
23863         return tag_ptr(ret_conv, true);
23864 }
23865
23866 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23867         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(o);
23868         jboolean ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
23869         return ret_conv;
23870 }
23871
23872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23873         if (!ptr_is_owned(_res)) return;
23874         void* _res_ptr = untag_ptr(_res);
23875         CHECK_ACCESS(_res_ptr);
23876         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
23877         FREE(untag_ptr(_res));
23878         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
23879 }
23880
23881 static inline uint64_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
23882         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
23883         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
23884         return tag_ptr(ret_conv, true);
23885 }
23886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23887         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(arg);
23888         int64_t ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
23889         return ret_conv;
23890 }
23891
23892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23893         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(orig);
23894         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
23895         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
23896         return tag_ptr(ret_conv, true);
23897 }
23898
23899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23900         LDKUpdateFailMalformedHTLC o_conv;
23901         o_conv.inner = untag_ptr(o);
23902         o_conv.is_owned = ptr_is_owned(o);
23903         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23904         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
23905         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
23906         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
23907         return tag_ptr(ret_conv, true);
23908 }
23909
23910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23911         void* e_ptr = untag_ptr(e);
23912         CHECK_ACCESS(e_ptr);
23913         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23914         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23915         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
23916         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
23917         return tag_ptr(ret_conv, true);
23918 }
23919
23920 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23921         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(o);
23922         jboolean ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
23923         return ret_conv;
23924 }
23925
23926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23927         if (!ptr_is_owned(_res)) return;
23928         void* _res_ptr = untag_ptr(_res);
23929         CHECK_ACCESS(_res_ptr);
23930         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
23931         FREE(untag_ptr(_res));
23932         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
23933 }
23934
23935 static inline uint64_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
23936         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
23937         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
23938         return tag_ptr(ret_conv, true);
23939 }
23940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23941         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(arg);
23942         int64_t ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
23943         return ret_conv;
23944 }
23945
23946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23947         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(orig);
23948         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
23949         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
23950         return tag_ptr(ret_conv, true);
23951 }
23952
23953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23954         LDKUpdateFee o_conv;
23955         o_conv.inner = untag_ptr(o);
23956         o_conv.is_owned = ptr_is_owned(o);
23957         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23958         o_conv = UpdateFee_clone(&o_conv);
23959         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
23960         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
23961         return tag_ptr(ret_conv, true);
23962 }
23963
23964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23965         void* e_ptr = untag_ptr(e);
23966         CHECK_ACCESS(e_ptr);
23967         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23968         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23969         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
23970         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
23971         return tag_ptr(ret_conv, true);
23972 }
23973
23974 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23975         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(o);
23976         jboolean ret_conv = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
23977         return ret_conv;
23978 }
23979
23980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23981         if (!ptr_is_owned(_res)) return;
23982         void* _res_ptr = untag_ptr(_res);
23983         CHECK_ACCESS(_res_ptr);
23984         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
23985         FREE(untag_ptr(_res));
23986         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
23987 }
23988
23989 static inline uint64_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
23990         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
23991         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
23992         return tag_ptr(ret_conv, true);
23993 }
23994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23995         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(arg);
23996         int64_t ret_conv = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
23997         return ret_conv;
23998 }
23999
24000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24001         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(orig);
24002         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
24003         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
24004         return tag_ptr(ret_conv, true);
24005 }
24006
24007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24008         LDKUpdateFulfillHTLC o_conv;
24009         o_conv.inner = untag_ptr(o);
24010         o_conv.is_owned = ptr_is_owned(o);
24011         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24012         o_conv = UpdateFulfillHTLC_clone(&o_conv);
24013         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
24014         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
24015         return tag_ptr(ret_conv, true);
24016 }
24017
24018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24019         void* e_ptr = untag_ptr(e);
24020         CHECK_ACCESS(e_ptr);
24021         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24022         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24023         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
24024         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
24025         return tag_ptr(ret_conv, true);
24026 }
24027
24028 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24029         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(o);
24030         jboolean ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
24031         return ret_conv;
24032 }
24033
24034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24035         if (!ptr_is_owned(_res)) return;
24036         void* _res_ptr = untag_ptr(_res);
24037         CHECK_ACCESS(_res_ptr);
24038         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
24039         FREE(untag_ptr(_res));
24040         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
24041 }
24042
24043 static inline uint64_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
24044         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
24045         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
24046         return tag_ptr(ret_conv, true);
24047 }
24048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24049         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(arg);
24050         int64_t ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
24051         return ret_conv;
24052 }
24053
24054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24055         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(orig);
24056         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
24057         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
24058         return tag_ptr(ret_conv, true);
24059 }
24060
24061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24062         LDKUpdateAddHTLC o_conv;
24063         o_conv.inner = untag_ptr(o);
24064         o_conv.is_owned = ptr_is_owned(o);
24065         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24066         o_conv = UpdateAddHTLC_clone(&o_conv);
24067         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
24068         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
24069         return tag_ptr(ret_conv, true);
24070 }
24071
24072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24073         void* e_ptr = untag_ptr(e);
24074         CHECK_ACCESS(e_ptr);
24075         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24076         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24077         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
24078         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
24079         return tag_ptr(ret_conv, true);
24080 }
24081
24082 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24083         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(o);
24084         jboolean ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
24085         return ret_conv;
24086 }
24087
24088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24089         if (!ptr_is_owned(_res)) return;
24090         void* _res_ptr = untag_ptr(_res);
24091         CHECK_ACCESS(_res_ptr);
24092         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
24093         FREE(untag_ptr(_res));
24094         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
24095 }
24096
24097 static inline uint64_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
24098         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
24099         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
24100         return tag_ptr(ret_conv, true);
24101 }
24102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24103         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(arg);
24104         int64_t ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
24105         return ret_conv;
24106 }
24107
24108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24109         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(orig);
24110         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
24111         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
24112         return tag_ptr(ret_conv, true);
24113 }
24114
24115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24116         LDKOnionMessage o_conv;
24117         o_conv.inner = untag_ptr(o);
24118         o_conv.is_owned = ptr_is_owned(o);
24119         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24120         o_conv = OnionMessage_clone(&o_conv);
24121         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
24122         *ret_conv = CResult_OnionMessageDecodeErrorZ_ok(o_conv);
24123         return tag_ptr(ret_conv, true);
24124 }
24125
24126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24127         void* e_ptr = untag_ptr(e);
24128         CHECK_ACCESS(e_ptr);
24129         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24130         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24131         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
24132         *ret_conv = CResult_OnionMessageDecodeErrorZ_err(e_conv);
24133         return tag_ptr(ret_conv, true);
24134 }
24135
24136 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24137         LDKCResult_OnionMessageDecodeErrorZ* o_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(o);
24138         jboolean ret_conv = CResult_OnionMessageDecodeErrorZ_is_ok(o_conv);
24139         return ret_conv;
24140 }
24141
24142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24143         if (!ptr_is_owned(_res)) return;
24144         void* _res_ptr = untag_ptr(_res);
24145         CHECK_ACCESS(_res_ptr);
24146         LDKCResult_OnionMessageDecodeErrorZ _res_conv = *(LDKCResult_OnionMessageDecodeErrorZ*)(_res_ptr);
24147         FREE(untag_ptr(_res));
24148         CResult_OnionMessageDecodeErrorZ_free(_res_conv);
24149 }
24150
24151 static inline uint64_t CResult_OnionMessageDecodeErrorZ_clone_ptr(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR arg) {
24152         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
24153         *ret_conv = CResult_OnionMessageDecodeErrorZ_clone(arg);
24154         return tag_ptr(ret_conv, true);
24155 }
24156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24157         LDKCResult_OnionMessageDecodeErrorZ* arg_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(arg);
24158         int64_t ret_conv = CResult_OnionMessageDecodeErrorZ_clone_ptr(arg_conv);
24159         return ret_conv;
24160 }
24161
24162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24163         LDKCResult_OnionMessageDecodeErrorZ* orig_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(orig);
24164         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
24165         *ret_conv = CResult_OnionMessageDecodeErrorZ_clone(orig_conv);
24166         return tag_ptr(ret_conv, true);
24167 }
24168
24169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24170         LDKPing o_conv;
24171         o_conv.inner = untag_ptr(o);
24172         o_conv.is_owned = ptr_is_owned(o);
24173         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24174         o_conv = Ping_clone(&o_conv);
24175         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
24176         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
24177         return tag_ptr(ret_conv, true);
24178 }
24179
24180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24181         void* e_ptr = untag_ptr(e);
24182         CHECK_ACCESS(e_ptr);
24183         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24184         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24185         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
24186         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
24187         return tag_ptr(ret_conv, true);
24188 }
24189
24190 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24191         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(o);
24192         jboolean ret_conv = CResult_PingDecodeErrorZ_is_ok(o_conv);
24193         return ret_conv;
24194 }
24195
24196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24197         if (!ptr_is_owned(_res)) return;
24198         void* _res_ptr = untag_ptr(_res);
24199         CHECK_ACCESS(_res_ptr);
24200         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
24201         FREE(untag_ptr(_res));
24202         CResult_PingDecodeErrorZ_free(_res_conv);
24203 }
24204
24205 static inline uint64_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
24206         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
24207         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
24208         return tag_ptr(ret_conv, true);
24209 }
24210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24211         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(arg);
24212         int64_t ret_conv = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
24213         return ret_conv;
24214 }
24215
24216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24217         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(orig);
24218         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
24219         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
24220         return tag_ptr(ret_conv, true);
24221 }
24222
24223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24224         LDKPong o_conv;
24225         o_conv.inner = untag_ptr(o);
24226         o_conv.is_owned = ptr_is_owned(o);
24227         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24228         o_conv = Pong_clone(&o_conv);
24229         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
24230         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
24231         return tag_ptr(ret_conv, true);
24232 }
24233
24234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24235         void* e_ptr = untag_ptr(e);
24236         CHECK_ACCESS(e_ptr);
24237         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24238         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24239         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
24240         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
24241         return tag_ptr(ret_conv, true);
24242 }
24243
24244 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24245         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(o);
24246         jboolean ret_conv = CResult_PongDecodeErrorZ_is_ok(o_conv);
24247         return ret_conv;
24248 }
24249
24250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24251         if (!ptr_is_owned(_res)) return;
24252         void* _res_ptr = untag_ptr(_res);
24253         CHECK_ACCESS(_res_ptr);
24254         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
24255         FREE(untag_ptr(_res));
24256         CResult_PongDecodeErrorZ_free(_res_conv);
24257 }
24258
24259 static inline uint64_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
24260         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
24261         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
24262         return tag_ptr(ret_conv, true);
24263 }
24264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24265         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(arg);
24266         int64_t ret_conv = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
24267         return ret_conv;
24268 }
24269
24270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24271         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(orig);
24272         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
24273         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
24274         return tag_ptr(ret_conv, true);
24275 }
24276
24277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24278         LDKUnsignedChannelAnnouncement o_conv;
24279         o_conv.inner = untag_ptr(o);
24280         o_conv.is_owned = ptr_is_owned(o);
24281         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24282         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
24283         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
24284         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
24285         return tag_ptr(ret_conv, true);
24286 }
24287
24288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24289         void* e_ptr = untag_ptr(e);
24290         CHECK_ACCESS(e_ptr);
24291         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24292         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24293         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
24294         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
24295         return tag_ptr(ret_conv, true);
24296 }
24297
24298 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24299         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(o);
24300         jboolean ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
24301         return ret_conv;
24302 }
24303
24304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24305         if (!ptr_is_owned(_res)) return;
24306         void* _res_ptr = untag_ptr(_res);
24307         CHECK_ACCESS(_res_ptr);
24308         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
24309         FREE(untag_ptr(_res));
24310         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
24311 }
24312
24313 static inline uint64_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
24314         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
24315         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
24316         return tag_ptr(ret_conv, true);
24317 }
24318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24319         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(arg);
24320         int64_t ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
24321         return ret_conv;
24322 }
24323
24324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24325         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(orig);
24326         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
24327         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
24328         return tag_ptr(ret_conv, true);
24329 }
24330
24331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24332         LDKChannelAnnouncement o_conv;
24333         o_conv.inner = untag_ptr(o);
24334         o_conv.is_owned = ptr_is_owned(o);
24335         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24336         o_conv = ChannelAnnouncement_clone(&o_conv);
24337         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
24338         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
24339         return tag_ptr(ret_conv, true);
24340 }
24341
24342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24343         void* e_ptr = untag_ptr(e);
24344         CHECK_ACCESS(e_ptr);
24345         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24346         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24347         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
24348         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
24349         return tag_ptr(ret_conv, true);
24350 }
24351
24352 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24353         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(o);
24354         jboolean ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
24355         return ret_conv;
24356 }
24357
24358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24359         if (!ptr_is_owned(_res)) return;
24360         void* _res_ptr = untag_ptr(_res);
24361         CHECK_ACCESS(_res_ptr);
24362         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
24363         FREE(untag_ptr(_res));
24364         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
24365 }
24366
24367 static inline uint64_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
24368         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
24369         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
24370         return tag_ptr(ret_conv, true);
24371 }
24372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24373         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(arg);
24374         int64_t ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
24375         return ret_conv;
24376 }
24377
24378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24379         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(orig);
24380         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
24381         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
24382         return tag_ptr(ret_conv, true);
24383 }
24384
24385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24386         LDKUnsignedChannelUpdate o_conv;
24387         o_conv.inner = untag_ptr(o);
24388         o_conv.is_owned = ptr_is_owned(o);
24389         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24390         o_conv = UnsignedChannelUpdate_clone(&o_conv);
24391         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
24392         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
24393         return tag_ptr(ret_conv, true);
24394 }
24395
24396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24397         void* e_ptr = untag_ptr(e);
24398         CHECK_ACCESS(e_ptr);
24399         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24400         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24401         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
24402         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
24403         return tag_ptr(ret_conv, true);
24404 }
24405
24406 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24407         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(o);
24408         jboolean ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
24409         return ret_conv;
24410 }
24411
24412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24413         if (!ptr_is_owned(_res)) return;
24414         void* _res_ptr = untag_ptr(_res);
24415         CHECK_ACCESS(_res_ptr);
24416         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
24417         FREE(untag_ptr(_res));
24418         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
24419 }
24420
24421 static inline uint64_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
24422         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
24423         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
24424         return tag_ptr(ret_conv, true);
24425 }
24426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24427         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(arg);
24428         int64_t ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
24429         return ret_conv;
24430 }
24431
24432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24433         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(orig);
24434         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
24435         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
24436         return tag_ptr(ret_conv, true);
24437 }
24438
24439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24440         LDKChannelUpdate o_conv;
24441         o_conv.inner = untag_ptr(o);
24442         o_conv.is_owned = ptr_is_owned(o);
24443         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24444         o_conv = ChannelUpdate_clone(&o_conv);
24445         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
24446         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
24447         return tag_ptr(ret_conv, true);
24448 }
24449
24450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24451         void* e_ptr = untag_ptr(e);
24452         CHECK_ACCESS(e_ptr);
24453         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24454         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24455         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
24456         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
24457         return tag_ptr(ret_conv, true);
24458 }
24459
24460 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24461         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(o);
24462         jboolean ret_conv = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
24463         return ret_conv;
24464 }
24465
24466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24467         if (!ptr_is_owned(_res)) return;
24468         void* _res_ptr = untag_ptr(_res);
24469         CHECK_ACCESS(_res_ptr);
24470         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
24471         FREE(untag_ptr(_res));
24472         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
24473 }
24474
24475 static inline uint64_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
24476         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
24477         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
24478         return tag_ptr(ret_conv, true);
24479 }
24480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24481         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(arg);
24482         int64_t ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
24483         return ret_conv;
24484 }
24485
24486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24487         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(orig);
24488         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
24489         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
24490         return tag_ptr(ret_conv, true);
24491 }
24492
24493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24494         LDKErrorMessage o_conv;
24495         o_conv.inner = untag_ptr(o);
24496         o_conv.is_owned = ptr_is_owned(o);
24497         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24498         o_conv = ErrorMessage_clone(&o_conv);
24499         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
24500         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
24501         return tag_ptr(ret_conv, true);
24502 }
24503
24504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24505         void* e_ptr = untag_ptr(e);
24506         CHECK_ACCESS(e_ptr);
24507         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24508         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24509         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
24510         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
24511         return tag_ptr(ret_conv, true);
24512 }
24513
24514 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24515         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(o);
24516         jboolean ret_conv = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
24517         return ret_conv;
24518 }
24519
24520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24521         if (!ptr_is_owned(_res)) return;
24522         void* _res_ptr = untag_ptr(_res);
24523         CHECK_ACCESS(_res_ptr);
24524         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
24525         FREE(untag_ptr(_res));
24526         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
24527 }
24528
24529 static inline uint64_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
24530         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
24531         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
24532         return tag_ptr(ret_conv, true);
24533 }
24534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24535         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(arg);
24536         int64_t ret_conv = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
24537         return ret_conv;
24538 }
24539
24540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24541         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(orig);
24542         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
24543         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
24544         return tag_ptr(ret_conv, true);
24545 }
24546
24547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24548         LDKWarningMessage o_conv;
24549         o_conv.inner = untag_ptr(o);
24550         o_conv.is_owned = ptr_is_owned(o);
24551         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24552         o_conv = WarningMessage_clone(&o_conv);
24553         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
24554         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
24555         return tag_ptr(ret_conv, true);
24556 }
24557
24558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24559         void* e_ptr = untag_ptr(e);
24560         CHECK_ACCESS(e_ptr);
24561         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24562         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24563         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
24564         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
24565         return tag_ptr(ret_conv, true);
24566 }
24567
24568 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24569         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(o);
24570         jboolean ret_conv = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
24571         return ret_conv;
24572 }
24573
24574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24575         if (!ptr_is_owned(_res)) return;
24576         void* _res_ptr = untag_ptr(_res);
24577         CHECK_ACCESS(_res_ptr);
24578         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
24579         FREE(untag_ptr(_res));
24580         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
24581 }
24582
24583 static inline uint64_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
24584         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
24585         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
24586         return tag_ptr(ret_conv, true);
24587 }
24588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24589         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(arg);
24590         int64_t ret_conv = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
24591         return ret_conv;
24592 }
24593
24594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24595         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(orig);
24596         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
24597         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
24598         return tag_ptr(ret_conv, true);
24599 }
24600
24601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24602         LDKUnsignedNodeAnnouncement o_conv;
24603         o_conv.inner = untag_ptr(o);
24604         o_conv.is_owned = ptr_is_owned(o);
24605         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24606         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
24607         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
24608         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
24609         return tag_ptr(ret_conv, true);
24610 }
24611
24612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24613         void* e_ptr = untag_ptr(e);
24614         CHECK_ACCESS(e_ptr);
24615         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24616         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24617         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
24618         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
24619         return tag_ptr(ret_conv, true);
24620 }
24621
24622 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24623         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(o);
24624         jboolean ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
24625         return ret_conv;
24626 }
24627
24628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24629         if (!ptr_is_owned(_res)) return;
24630         void* _res_ptr = untag_ptr(_res);
24631         CHECK_ACCESS(_res_ptr);
24632         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
24633         FREE(untag_ptr(_res));
24634         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
24635 }
24636
24637 static inline uint64_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
24638         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
24639         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
24640         return tag_ptr(ret_conv, true);
24641 }
24642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24643         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(arg);
24644         int64_t ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
24645         return ret_conv;
24646 }
24647
24648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24649         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(orig);
24650         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
24651         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
24652         return tag_ptr(ret_conv, true);
24653 }
24654
24655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24656         LDKNodeAnnouncement o_conv;
24657         o_conv.inner = untag_ptr(o);
24658         o_conv.is_owned = ptr_is_owned(o);
24659         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24660         o_conv = NodeAnnouncement_clone(&o_conv);
24661         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
24662         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
24663         return tag_ptr(ret_conv, true);
24664 }
24665
24666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24667         void* e_ptr = untag_ptr(e);
24668         CHECK_ACCESS(e_ptr);
24669         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24670         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24671         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
24672         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
24673         return tag_ptr(ret_conv, true);
24674 }
24675
24676 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24677         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(o);
24678         jboolean ret_conv = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
24679         return ret_conv;
24680 }
24681
24682 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24683         if (!ptr_is_owned(_res)) return;
24684         void* _res_ptr = untag_ptr(_res);
24685         CHECK_ACCESS(_res_ptr);
24686         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
24687         FREE(untag_ptr(_res));
24688         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
24689 }
24690
24691 static inline uint64_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
24692         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
24693         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
24694         return tag_ptr(ret_conv, true);
24695 }
24696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24697         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(arg);
24698         int64_t ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
24699         return ret_conv;
24700 }
24701
24702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24703         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(orig);
24704         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
24705         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
24706         return tag_ptr(ret_conv, true);
24707 }
24708
24709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24710         LDKQueryShortChannelIds o_conv;
24711         o_conv.inner = untag_ptr(o);
24712         o_conv.is_owned = ptr_is_owned(o);
24713         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24714         o_conv = QueryShortChannelIds_clone(&o_conv);
24715         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
24716         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
24717         return tag_ptr(ret_conv, true);
24718 }
24719
24720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24721         void* e_ptr = untag_ptr(e);
24722         CHECK_ACCESS(e_ptr);
24723         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24724         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24725         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
24726         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
24727         return tag_ptr(ret_conv, true);
24728 }
24729
24730 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24731         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(o);
24732         jboolean ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
24733         return ret_conv;
24734 }
24735
24736 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24737         if (!ptr_is_owned(_res)) return;
24738         void* _res_ptr = untag_ptr(_res);
24739         CHECK_ACCESS(_res_ptr);
24740         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
24741         FREE(untag_ptr(_res));
24742         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
24743 }
24744
24745 static inline uint64_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
24746         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
24747         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
24748         return tag_ptr(ret_conv, true);
24749 }
24750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24751         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(arg);
24752         int64_t ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
24753         return ret_conv;
24754 }
24755
24756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24757         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(orig);
24758         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
24759         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
24760         return tag_ptr(ret_conv, true);
24761 }
24762
24763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24764         LDKReplyShortChannelIdsEnd o_conv;
24765         o_conv.inner = untag_ptr(o);
24766         o_conv.is_owned = ptr_is_owned(o);
24767         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24768         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
24769         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
24770         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
24771         return tag_ptr(ret_conv, true);
24772 }
24773
24774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24775         void* e_ptr = untag_ptr(e);
24776         CHECK_ACCESS(e_ptr);
24777         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24778         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24779         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
24780         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
24781         return tag_ptr(ret_conv, true);
24782 }
24783
24784 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24785         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(o);
24786         jboolean ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
24787         return ret_conv;
24788 }
24789
24790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24791         if (!ptr_is_owned(_res)) return;
24792         void* _res_ptr = untag_ptr(_res);
24793         CHECK_ACCESS(_res_ptr);
24794         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
24795         FREE(untag_ptr(_res));
24796         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
24797 }
24798
24799 static inline uint64_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
24800         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
24801         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
24802         return tag_ptr(ret_conv, true);
24803 }
24804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24805         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(arg);
24806         int64_t ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
24807         return ret_conv;
24808 }
24809
24810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24811         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(orig);
24812         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
24813         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
24814         return tag_ptr(ret_conv, true);
24815 }
24816
24817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24818         LDKQueryChannelRange o_conv;
24819         o_conv.inner = untag_ptr(o);
24820         o_conv.is_owned = ptr_is_owned(o);
24821         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24822         o_conv = QueryChannelRange_clone(&o_conv);
24823         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
24824         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
24825         return tag_ptr(ret_conv, true);
24826 }
24827
24828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24829         void* e_ptr = untag_ptr(e);
24830         CHECK_ACCESS(e_ptr);
24831         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24832         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24833         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
24834         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
24835         return tag_ptr(ret_conv, true);
24836 }
24837
24838 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24839         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(o);
24840         jboolean ret_conv = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
24841         return ret_conv;
24842 }
24843
24844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24845         if (!ptr_is_owned(_res)) return;
24846         void* _res_ptr = untag_ptr(_res);
24847         CHECK_ACCESS(_res_ptr);
24848         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
24849         FREE(untag_ptr(_res));
24850         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
24851 }
24852
24853 static inline uint64_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
24854         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
24855         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
24856         return tag_ptr(ret_conv, true);
24857 }
24858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24859         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(arg);
24860         int64_t ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
24861         return ret_conv;
24862 }
24863
24864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24865         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(orig);
24866         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
24867         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
24868         return tag_ptr(ret_conv, true);
24869 }
24870
24871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24872         LDKReplyChannelRange o_conv;
24873         o_conv.inner = untag_ptr(o);
24874         o_conv.is_owned = ptr_is_owned(o);
24875         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24876         o_conv = ReplyChannelRange_clone(&o_conv);
24877         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
24878         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
24879         return tag_ptr(ret_conv, true);
24880 }
24881
24882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24883         void* e_ptr = untag_ptr(e);
24884         CHECK_ACCESS(e_ptr);
24885         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24886         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24887         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
24888         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
24889         return tag_ptr(ret_conv, true);
24890 }
24891
24892 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24893         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(o);
24894         jboolean ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
24895         return ret_conv;
24896 }
24897
24898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24899         if (!ptr_is_owned(_res)) return;
24900         void* _res_ptr = untag_ptr(_res);
24901         CHECK_ACCESS(_res_ptr);
24902         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
24903         FREE(untag_ptr(_res));
24904         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
24905 }
24906
24907 static inline uint64_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
24908         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
24909         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
24910         return tag_ptr(ret_conv, true);
24911 }
24912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24913         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(arg);
24914         int64_t ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
24915         return ret_conv;
24916 }
24917
24918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24919         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(orig);
24920         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
24921         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
24922         return tag_ptr(ret_conv, true);
24923 }
24924
24925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24926         LDKGossipTimestampFilter o_conv;
24927         o_conv.inner = untag_ptr(o);
24928         o_conv.is_owned = ptr_is_owned(o);
24929         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24930         o_conv = GossipTimestampFilter_clone(&o_conv);
24931         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
24932         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
24933         return tag_ptr(ret_conv, true);
24934 }
24935
24936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24937         void* e_ptr = untag_ptr(e);
24938         CHECK_ACCESS(e_ptr);
24939         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24940         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24941         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
24942         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
24943         return tag_ptr(ret_conv, true);
24944 }
24945
24946 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24947         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(o);
24948         jboolean ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
24949         return ret_conv;
24950 }
24951
24952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24953         if (!ptr_is_owned(_res)) return;
24954         void* _res_ptr = untag_ptr(_res);
24955         CHECK_ACCESS(_res_ptr);
24956         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
24957         FREE(untag_ptr(_res));
24958         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
24959 }
24960
24961 static inline uint64_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
24962         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
24963         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
24964         return tag_ptr(ret_conv, true);
24965 }
24966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24967         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(arg);
24968         int64_t ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
24969         return ret_conv;
24970 }
24971
24972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24973         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(orig);
24974         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
24975         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
24976         return tag_ptr(ret_conv, true);
24977 }
24978
24979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PhantomRouteHintsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24980         LDKCVec_PhantomRouteHintsZ _res_constr;
24981         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24982         if (_res_constr.datalen > 0)
24983                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
24984         else
24985                 _res_constr.data = NULL;
24986         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24987         for (size_t t = 0; t < _res_constr.datalen; t++) {
24988                 int64_t _res_conv_19 = _res_vals[t];
24989                 LDKPhantomRouteHints _res_conv_19_conv;
24990                 _res_conv_19_conv.inner = untag_ptr(_res_conv_19);
24991                 _res_conv_19_conv.is_owned = ptr_is_owned(_res_conv_19);
24992                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
24993                 _res_constr.data[t] = _res_conv_19_conv;
24994         }
24995         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24996         CVec_PhantomRouteHintsZ_free(_res_constr);
24997 }
24998
24999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25000         LDKInvoice o_conv;
25001         o_conv.inner = untag_ptr(o);
25002         o_conv.is_owned = ptr_is_owned(o);
25003         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25004         o_conv = Invoice_clone(&o_conv);
25005         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
25006         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
25007         return tag_ptr(ret_conv, true);
25008 }
25009
25010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25011         void* e_ptr = untag_ptr(e);
25012         CHECK_ACCESS(e_ptr);
25013         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
25014         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)untag_ptr(e));
25015         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
25016         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
25017         return tag_ptr(ret_conv, true);
25018 }
25019
25020 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25021         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(o);
25022         jboolean ret_conv = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
25023         return ret_conv;
25024 }
25025
25026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25027         if (!ptr_is_owned(_res)) return;
25028         void* _res_ptr = untag_ptr(_res);
25029         CHECK_ACCESS(_res_ptr);
25030         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
25031         FREE(untag_ptr(_res));
25032         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
25033 }
25034
25035 static inline uint64_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
25036         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
25037         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
25038         return tag_ptr(ret_conv, true);
25039 }
25040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25041         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(arg);
25042         int64_t ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
25043         return ret_conv;
25044 }
25045
25046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25047         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(orig);
25048         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
25049         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
25050         return tag_ptr(ret_conv, true);
25051 }
25052
25053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) {
25054         void* o_ptr = untag_ptr(o);
25055         CHECK_ACCESS(o_ptr);
25056         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
25057         if (o_conv.free == LDKFilter_JCalls_free) {
25058                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25059                 LDKFilter_JCalls_cloned(&o_conv);
25060         }
25061         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
25062         *ret_copy = COption_FilterZ_some(o_conv);
25063         int64_t ret_ref = tag_ptr(ret_copy, true);
25064         return ret_ref;
25065 }
25066
25067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) {
25068         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
25069         *ret_copy = COption_FilterZ_none();
25070         int64_t ret_ref = tag_ptr(ret_copy, true);
25071         return ret_ref;
25072 }
25073
25074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25075         if (!ptr_is_owned(_res)) return;
25076         void* _res_ptr = untag_ptr(_res);
25077         CHECK_ACCESS(_res_ptr);
25078         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
25079         FREE(untag_ptr(_res));
25080         COption_FilterZ_free(_res_conv);
25081 }
25082
25083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25084         LDKLockedChannelMonitor o_conv;
25085         o_conv.inner = untag_ptr(o);
25086         o_conv.is_owned = ptr_is_owned(o);
25087         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25088         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
25089         
25090         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
25091         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
25092         return tag_ptr(ret_conv, true);
25093 }
25094
25095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1err(JNIEnv *env, jclass clz) {
25096         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
25097         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
25098         return tag_ptr(ret_conv, true);
25099 }
25100
25101 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25102         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(o);
25103         jboolean ret_conv = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
25104         return ret_conv;
25105 }
25106
25107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25108         if (!ptr_is_owned(_res)) return;
25109         void* _res_ptr = untag_ptr(_res);
25110         CHECK_ACCESS(_res_ptr);
25111         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
25112         FREE(untag_ptr(_res));
25113         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
25114 }
25115
25116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1OutPointZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
25117         LDKCVec_OutPointZ _res_constr;
25118         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
25119         if (_res_constr.datalen > 0)
25120                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
25121         else
25122                 _res_constr.data = NULL;
25123         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
25124         for (size_t k = 0; k < _res_constr.datalen; k++) {
25125                 int64_t _res_conv_10 = _res_vals[k];
25126                 LDKOutPoint _res_conv_10_conv;
25127                 _res_conv_10_conv.inner = untag_ptr(_res_conv_10);
25128                 _res_conv_10_conv.is_owned = ptr_is_owned(_res_conv_10);
25129                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
25130                 _res_constr.data[k] = _res_conv_10_conv;
25131         }
25132         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
25133         CVec_OutPointZ_free(_res_constr);
25134 }
25135
25136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25137         if (!ptr_is_owned(this_ptr)) return;
25138         void* this_ptr_ptr = untag_ptr(this_ptr);
25139         CHECK_ACCESS(this_ptr_ptr);
25140         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
25141         FREE(untag_ptr(this_ptr));
25142         PaymentPurpose_free(this_ptr_conv);
25143 }
25144
25145 static inline uint64_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
25146         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
25147         *ret_copy = PaymentPurpose_clone(arg);
25148         int64_t ret_ref = tag_ptr(ret_copy, true);
25149         return ret_ref;
25150 }
25151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25152         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)untag_ptr(arg);
25153         int64_t ret_conv = PaymentPurpose_clone_ptr(arg_conv);
25154         return ret_conv;
25155 }
25156
25157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25158         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)untag_ptr(orig);
25159         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
25160         *ret_copy = PaymentPurpose_clone(orig_conv);
25161         int64_t ret_ref = tag_ptr(ret_copy, true);
25162         return ret_ref;
25163 }
25164
25165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1invoice_1payment(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_secret) {
25166         LDKThirtyTwoBytes payment_preimage_ref;
25167         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
25168         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
25169         LDKThirtyTwoBytes payment_secret_ref;
25170         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
25171         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
25172         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
25173         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
25174         int64_t ret_ref = tag_ptr(ret_copy, true);
25175         return ret_ref;
25176 }
25177
25178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
25179         LDKThirtyTwoBytes a_ref;
25180         CHECK((*env)->GetArrayLength(env, a) == 32);
25181         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
25182         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
25183         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
25184         int64_t ret_ref = tag_ptr(ret_copy, true);
25185         return ret_ref;
25186 }
25187
25188 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1write(JNIEnv *env, jclass clz, int64_t obj) {
25189         LDKPaymentPurpose* obj_conv = (LDKPaymentPurpose*)untag_ptr(obj);
25190         LDKCVec_u8Z ret_var = PaymentPurpose_write(obj_conv);
25191         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25192         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25193         CVec_u8Z_free(ret_var);
25194         return ret_arr;
25195 }
25196
25197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25198         LDKu8slice ser_ref;
25199         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25200         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25201         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
25202         *ret_conv = PaymentPurpose_read(ser_ref);
25203         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25204         return tag_ptr(ret_conv, true);
25205 }
25206
25207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25208         if (!ptr_is_owned(this_ptr)) return;
25209         void* this_ptr_ptr = untag_ptr(this_ptr);
25210         CHECK_ACCESS(this_ptr_ptr);
25211         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
25212         FREE(untag_ptr(this_ptr));
25213         ClosureReason_free(this_ptr_conv);
25214 }
25215
25216 static inline uint64_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
25217         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
25218         *ret_copy = ClosureReason_clone(arg);
25219         int64_t ret_ref = tag_ptr(ret_copy, true);
25220         return ret_ref;
25221 }
25222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25223         LDKClosureReason* arg_conv = (LDKClosureReason*)untag_ptr(arg);
25224         int64_t ret_conv = ClosureReason_clone_ptr(arg_conv);
25225         return ret_conv;
25226 }
25227
25228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25229         LDKClosureReason* orig_conv = (LDKClosureReason*)untag_ptr(orig);
25230         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
25231         *ret_copy = ClosureReason_clone(orig_conv);
25232         int64_t ret_ref = tag_ptr(ret_copy, true);
25233         return ret_ref;
25234 }
25235
25236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, jstring peer_msg) {
25237         LDKStr peer_msg_conv = java_to_owned_str(env, peer_msg);
25238         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
25239         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
25240         int64_t ret_ref = tag_ptr(ret_copy, true);
25241         return ret_ref;
25242 }
25243
25244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) {
25245         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
25246         *ret_copy = ClosureReason_holder_force_closed();
25247         int64_t ret_ref = tag_ptr(ret_copy, true);
25248         return ret_ref;
25249 }
25250
25251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) {
25252         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
25253         *ret_copy = ClosureReason_cooperative_closure();
25254         int64_t ret_ref = tag_ptr(ret_copy, true);
25255         return ret_ref;
25256 }
25257
25258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) {
25259         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
25260         *ret_copy = ClosureReason_commitment_tx_confirmed();
25261         int64_t ret_ref = tag_ptr(ret_copy, true);
25262         return ret_ref;
25263 }
25264
25265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1funding_1timed_1out(JNIEnv *env, jclass clz) {
25266         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
25267         *ret_copy = ClosureReason_funding_timed_out();
25268         int64_t ret_ref = tag_ptr(ret_copy, true);
25269         return ret_ref;
25270 }
25271
25272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) {
25273         LDKStr err_conv = java_to_owned_str(env, err);
25274         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
25275         *ret_copy = ClosureReason_processing_error(err_conv);
25276         int64_t ret_ref = tag_ptr(ret_copy, true);
25277         return ret_ref;
25278 }
25279
25280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) {
25281         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
25282         *ret_copy = ClosureReason_disconnected_peer();
25283         int64_t ret_ref = tag_ptr(ret_copy, true);
25284         return ret_ref;
25285 }
25286
25287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) {
25288         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
25289         *ret_copy = ClosureReason_outdated_channel_manager();
25290         int64_t ret_ref = tag_ptr(ret_copy, true);
25291         return ret_ref;
25292 }
25293
25294 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosureReason_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25295         LDKClosureReason* a_conv = (LDKClosureReason*)untag_ptr(a);
25296         LDKClosureReason* b_conv = (LDKClosureReason*)untag_ptr(b);
25297         jboolean ret_conv = ClosureReason_eq(a_conv, b_conv);
25298         return ret_conv;
25299 }
25300
25301 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
25302         LDKClosureReason* obj_conv = (LDKClosureReason*)untag_ptr(obj);
25303         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
25304         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25305         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25306         CVec_u8Z_free(ret_var);
25307         return ret_arr;
25308 }
25309
25310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25311         LDKu8slice ser_ref;
25312         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25313         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25314         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
25315         *ret_conv = ClosureReason_read(ser_ref);
25316         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25317         return tag_ptr(ret_conv, true);
25318 }
25319
25320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25321         if (!ptr_is_owned(this_ptr)) return;
25322         void* this_ptr_ptr = untag_ptr(this_ptr);
25323         CHECK_ACCESS(this_ptr_ptr);
25324         LDKHTLCDestination this_ptr_conv = *(LDKHTLCDestination*)(this_ptr_ptr);
25325         FREE(untag_ptr(this_ptr));
25326         HTLCDestination_free(this_ptr_conv);
25327 }
25328
25329 static inline uint64_t HTLCDestination_clone_ptr(LDKHTLCDestination *NONNULL_PTR arg) {
25330         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
25331         *ret_copy = HTLCDestination_clone(arg);
25332         int64_t ret_ref = tag_ptr(ret_copy, true);
25333         return ret_ref;
25334 }
25335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25336         LDKHTLCDestination* arg_conv = (LDKHTLCDestination*)untag_ptr(arg);
25337         int64_t ret_conv = HTLCDestination_clone_ptr(arg_conv);
25338         return ret_conv;
25339 }
25340
25341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25342         LDKHTLCDestination* orig_conv = (LDKHTLCDestination*)untag_ptr(orig);
25343         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
25344         *ret_copy = HTLCDestination_clone(orig_conv);
25345         int64_t ret_ref = tag_ptr(ret_copy, true);
25346         return ret_ref;
25347 }
25348
25349 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) {
25350         LDKPublicKey node_id_ref;
25351         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25352         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25353         LDKThirtyTwoBytes channel_id_ref;
25354         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
25355         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
25356         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
25357         *ret_copy = HTLCDestination_next_hop_channel(node_id_ref, channel_id_ref);
25358         int64_t ret_ref = tag_ptr(ret_copy, true);
25359         return ret_ref;
25360 }
25361
25362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1unknown_1next_1hop(JNIEnv *env, jclass clz, int64_t requested_forward_scid) {
25363         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
25364         *ret_copy = HTLCDestination_unknown_next_hop(requested_forward_scid);
25365         int64_t ret_ref = tag_ptr(ret_copy, true);
25366         return ret_ref;
25367 }
25368
25369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1failed_1payment(JNIEnv *env, jclass clz, int8_tArray payment_hash) {
25370         LDKThirtyTwoBytes payment_hash_ref;
25371         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25372         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
25373         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
25374         *ret_copy = HTLCDestination_failed_payment(payment_hash_ref);
25375         int64_t ret_ref = tag_ptr(ret_copy, true);
25376         return ret_ref;
25377 }
25378
25379 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25380         LDKHTLCDestination* a_conv = (LDKHTLCDestination*)untag_ptr(a);
25381         LDKHTLCDestination* b_conv = (LDKHTLCDestination*)untag_ptr(b);
25382         jboolean ret_conv = HTLCDestination_eq(a_conv, b_conv);
25383         return ret_conv;
25384 }
25385
25386 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1write(JNIEnv *env, jclass clz, int64_t obj) {
25387         LDKHTLCDestination* obj_conv = (LDKHTLCDestination*)untag_ptr(obj);
25388         LDKCVec_u8Z ret_var = HTLCDestination_write(obj_conv);
25389         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25390         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25391         CVec_u8Z_free(ret_var);
25392         return ret_arr;
25393 }
25394
25395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25396         LDKu8slice ser_ref;
25397         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25398         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25399         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
25400         *ret_conv = HTLCDestination_read(ser_ref);
25401         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25402         return tag_ptr(ret_conv, true);
25403 }
25404
25405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25406         if (!ptr_is_owned(this_ptr)) return;
25407         void* this_ptr_ptr = untag_ptr(this_ptr);
25408         CHECK_ACCESS(this_ptr_ptr);
25409         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
25410         FREE(untag_ptr(this_ptr));
25411         Event_free(this_ptr_conv);
25412 }
25413
25414 static inline uint64_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
25415         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25416         *ret_copy = Event_clone(arg);
25417         int64_t ret_ref = tag_ptr(ret_copy, true);
25418         return ret_ref;
25419 }
25420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25421         LDKEvent* arg_conv = (LDKEvent*)untag_ptr(arg);
25422         int64_t ret_conv = Event_clone_ptr(arg_conv);
25423         return ret_conv;
25424 }
25425
25426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25427         LDKEvent* orig_conv = (LDKEvent*)untag_ptr(orig);
25428         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25429         *ret_copy = Event_clone(orig_conv);
25430         int64_t ret_ref = tag_ptr(ret_copy, true);
25431         return ret_ref;
25432 }
25433
25434 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) {
25435         LDKThirtyTwoBytes temporary_channel_id_ref;
25436         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
25437         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
25438         LDKPublicKey counterparty_node_id_ref;
25439         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
25440         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
25441         LDKCVec_u8Z output_script_ref;
25442         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
25443         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
25444         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
25445         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25446         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, counterparty_node_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
25447         int64_t ret_ref = tag_ptr(ret_copy, true);
25448         return ret_ref;
25449 }
25450
25451 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) {
25452         LDKThirtyTwoBytes payment_hash_ref;
25453         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25454         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
25455         void* purpose_ptr = untag_ptr(purpose);
25456         CHECK_ACCESS(purpose_ptr);
25457         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
25458         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(purpose));
25459         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25460         *ret_copy = Event_payment_received(payment_hash_ref, amount_msat, purpose_conv);
25461         int64_t ret_ref = tag_ptr(ret_copy, true);
25462         return ret_ref;
25463 }
25464
25465 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) {
25466         LDKThirtyTwoBytes payment_hash_ref;
25467         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25468         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
25469         void* purpose_ptr = untag_ptr(purpose);
25470         CHECK_ACCESS(purpose_ptr);
25471         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
25472         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(purpose));
25473         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25474         *ret_copy = Event_payment_claimed(payment_hash_ref, amount_msat, purpose_conv);
25475         int64_t ret_ref = tag_ptr(ret_copy, true);
25476         return ret_ref;
25477 }
25478
25479 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) {
25480         LDKThirtyTwoBytes payment_id_ref;
25481         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
25482         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
25483         LDKThirtyTwoBytes payment_preimage_ref;
25484         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
25485         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
25486         LDKThirtyTwoBytes payment_hash_ref;
25487         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25488         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
25489         void* fee_paid_msat_ptr = untag_ptr(fee_paid_msat);
25490         CHECK_ACCESS(fee_paid_msat_ptr);
25491         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
25492         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(fee_paid_msat));
25493         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25494         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
25495         int64_t ret_ref = tag_ptr(ret_copy, true);
25496         return ret_ref;
25497 }
25498
25499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash) {
25500         LDKThirtyTwoBytes payment_id_ref;
25501         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
25502         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
25503         LDKThirtyTwoBytes payment_hash_ref;
25504         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25505         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
25506         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25507         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
25508         int64_t ret_ref = tag_ptr(ret_copy, true);
25509         return ret_ref;
25510 }
25511
25512 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) {
25513         LDKThirtyTwoBytes payment_id_ref;
25514         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
25515         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
25516         LDKThirtyTwoBytes payment_hash_ref;
25517         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25518         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
25519         LDKCVec_RouteHopZ path_constr;
25520         path_constr.datalen = (*env)->GetArrayLength(env, path);
25521         if (path_constr.datalen > 0)
25522                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
25523         else
25524                 path_constr.data = NULL;
25525         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
25526         for (size_t k = 0; k < path_constr.datalen; k++) {
25527                 int64_t path_conv_10 = path_vals[k];
25528                 LDKRouteHop path_conv_10_conv;
25529                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
25530                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
25531                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
25532                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
25533                 path_constr.data[k] = path_conv_10_conv;
25534         }
25535         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
25536         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25537         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
25538         int64_t ret_ref = tag_ptr(ret_copy, true);
25539         return ret_ref;
25540 }
25541
25542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1path_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash, jboolean payment_failed_permanently, int64_t network_update, jboolean all_paths_failed, int64_tArray path, int64_t short_channel_id, int64_t retry) {
25543         LDKThirtyTwoBytes payment_id_ref;
25544         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
25545         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
25546         LDKThirtyTwoBytes payment_hash_ref;
25547         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25548         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
25549         void* network_update_ptr = untag_ptr(network_update);
25550         CHECK_ACCESS(network_update_ptr);
25551         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
25552         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)untag_ptr(network_update));
25553         LDKCVec_RouteHopZ path_constr;
25554         path_constr.datalen = (*env)->GetArrayLength(env, path);
25555         if (path_constr.datalen > 0)
25556                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
25557         else
25558                 path_constr.data = NULL;
25559         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
25560         for (size_t k = 0; k < path_constr.datalen; k++) {
25561                 int64_t path_conv_10 = path_vals[k];
25562                 LDKRouteHop path_conv_10_conv;
25563                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
25564                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
25565                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
25566                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
25567                 path_constr.data[k] = path_conv_10_conv;
25568         }
25569         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
25570         void* short_channel_id_ptr = untag_ptr(short_channel_id);
25571         CHECK_ACCESS(short_channel_id_ptr);
25572         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
25573         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id));
25574         LDKRouteParameters retry_conv;
25575         retry_conv.inner = untag_ptr(retry);
25576         retry_conv.is_owned = ptr_is_owned(retry);
25577         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
25578         retry_conv = RouteParameters_clone(&retry_conv);
25579         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25580         *ret_copy = Event_payment_path_failed(payment_id_ref, payment_hash_ref, payment_failed_permanently, network_update_conv, all_paths_failed, path_constr, short_channel_id_conv, retry_conv);
25581         int64_t ret_ref = tag_ptr(ret_copy, true);
25582         return ret_ref;
25583 }
25584
25585 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) {
25586         LDKThirtyTwoBytes payment_id_ref;
25587         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
25588         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
25589         LDKThirtyTwoBytes payment_hash_ref;
25590         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25591         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
25592         LDKCVec_RouteHopZ path_constr;
25593         path_constr.datalen = (*env)->GetArrayLength(env, path);
25594         if (path_constr.datalen > 0)
25595                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
25596         else
25597                 path_constr.data = NULL;
25598         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
25599         for (size_t k = 0; k < path_constr.datalen; k++) {
25600                 int64_t path_conv_10 = path_vals[k];
25601                 LDKRouteHop path_conv_10_conv;
25602                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
25603                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
25604                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
25605                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
25606                 path_constr.data[k] = path_conv_10_conv;
25607         }
25608         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
25609         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25610         *ret_copy = Event_probe_successful(payment_id_ref, payment_hash_ref, path_constr);
25611         int64_t ret_ref = tag_ptr(ret_copy, true);
25612         return ret_ref;
25613 }
25614
25615 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) {
25616         LDKThirtyTwoBytes payment_id_ref;
25617         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
25618         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
25619         LDKThirtyTwoBytes payment_hash_ref;
25620         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25621         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
25622         LDKCVec_RouteHopZ path_constr;
25623         path_constr.datalen = (*env)->GetArrayLength(env, path);
25624         if (path_constr.datalen > 0)
25625                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
25626         else
25627                 path_constr.data = NULL;
25628         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
25629         for (size_t k = 0; k < path_constr.datalen; k++) {
25630                 int64_t path_conv_10 = path_vals[k];
25631                 LDKRouteHop path_conv_10_conv;
25632                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
25633                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
25634                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
25635                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
25636                 path_constr.data[k] = path_conv_10_conv;
25637         }
25638         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
25639         void* short_channel_id_ptr = untag_ptr(short_channel_id);
25640         CHECK_ACCESS(short_channel_id_ptr);
25641         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
25642         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id));
25643         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25644         *ret_copy = Event_probe_failed(payment_id_ref, payment_hash_ref, path_constr, short_channel_id_conv);
25645         int64_t ret_ref = tag_ptr(ret_copy, true);
25646         return ret_ref;
25647 }
25648
25649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
25650         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25651         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
25652         int64_t ret_ref = tag_ptr(ret_copy, true);
25653         return ret_ref;
25654 }
25655
25656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
25657         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
25658         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
25659         if (outputs_constr.datalen > 0)
25660                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
25661         else
25662                 outputs_constr.data = NULL;
25663         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
25664         for (size_t b = 0; b < outputs_constr.datalen; b++) {
25665                 int64_t outputs_conv_27 = outputs_vals[b];
25666                 void* outputs_conv_27_ptr = untag_ptr(outputs_conv_27);
25667                 CHECK_ACCESS(outputs_conv_27_ptr);
25668                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
25669                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(outputs_conv_27));
25670                 outputs_constr.data[b] = outputs_conv_27_conv;
25671         }
25672         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
25673         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25674         *ret_copy = Event_spendable_outputs(outputs_constr);
25675         int64_t ret_ref = tag_ptr(ret_copy, true);
25676         return ret_ref;
25677 }
25678
25679 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) {
25680         LDKThirtyTwoBytes prev_channel_id_ref;
25681         CHECK((*env)->GetArrayLength(env, prev_channel_id) == 32);
25682         (*env)->GetByteArrayRegion(env, prev_channel_id, 0, 32, prev_channel_id_ref.data);
25683         LDKThirtyTwoBytes next_channel_id_ref;
25684         CHECK((*env)->GetArrayLength(env, next_channel_id) == 32);
25685         (*env)->GetByteArrayRegion(env, next_channel_id, 0, 32, next_channel_id_ref.data);
25686         void* fee_earned_msat_ptr = untag_ptr(fee_earned_msat);
25687         CHECK_ACCESS(fee_earned_msat_ptr);
25688         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
25689         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(fee_earned_msat));
25690         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25691         *ret_copy = Event_payment_forwarded(prev_channel_id_ref, next_channel_id_ref, fee_earned_msat_conv, claim_from_onchain_tx);
25692         int64_t ret_ref = tag_ptr(ret_copy, true);
25693         return ret_ref;
25694 }
25695
25696 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) {
25697         LDKThirtyTwoBytes channel_id_ref;
25698         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
25699         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
25700         void* reason_ptr = untag_ptr(reason);
25701         CHECK_ACCESS(reason_ptr);
25702         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
25703         reason_conv = ClosureReason_clone((LDKClosureReason*)untag_ptr(reason));
25704         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25705         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
25706         int64_t ret_ref = tag_ptr(ret_copy, true);
25707         return ret_ref;
25708 }
25709
25710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1discard_1funding(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray transaction) {
25711         LDKThirtyTwoBytes channel_id_ref;
25712         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
25713         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
25714         LDKTransaction transaction_ref;
25715         transaction_ref.datalen = (*env)->GetArrayLength(env, transaction);
25716         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
25717         (*env)->GetByteArrayRegion(env, transaction, 0, transaction_ref.datalen, transaction_ref.data);
25718         transaction_ref.data_is_owned = true;
25719         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25720         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
25721         int64_t ret_ref = tag_ptr(ret_copy, true);
25722         return ret_ref;
25723 }
25724
25725 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) {
25726         LDKThirtyTwoBytes temporary_channel_id_ref;
25727         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
25728         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
25729         LDKPublicKey counterparty_node_id_ref;
25730         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
25731         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
25732         LDKChannelTypeFeatures channel_type_conv;
25733         channel_type_conv.inner = untag_ptr(channel_type);
25734         channel_type_conv.is_owned = ptr_is_owned(channel_type);
25735         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
25736         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
25737         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25738         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
25739         int64_t ret_ref = tag_ptr(ret_copy, true);
25740         return ret_ref;
25741 }
25742
25743 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) {
25744         LDKThirtyTwoBytes prev_channel_id_ref;
25745         CHECK((*env)->GetArrayLength(env, prev_channel_id) == 32);
25746         (*env)->GetByteArrayRegion(env, prev_channel_id, 0, 32, prev_channel_id_ref.data);
25747         void* failed_next_destination_ptr = untag_ptr(failed_next_destination);
25748         CHECK_ACCESS(failed_next_destination_ptr);
25749         LDKHTLCDestination failed_next_destination_conv = *(LDKHTLCDestination*)(failed_next_destination_ptr);
25750         failed_next_destination_conv = HTLCDestination_clone((LDKHTLCDestination*)untag_ptr(failed_next_destination));
25751         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25752         *ret_copy = Event_htlchandling_failed(prev_channel_id_ref, failed_next_destination_conv);
25753         int64_t ret_ref = tag_ptr(ret_copy, true);
25754         return ret_ref;
25755 }
25756
25757 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
25758         LDKEvent* obj_conv = (LDKEvent*)untag_ptr(obj);
25759         LDKCVec_u8Z ret_var = Event_write(obj_conv);
25760         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25761         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25762         CVec_u8Z_free(ret_var);
25763         return ret_arr;
25764 }
25765
25766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25767         LDKu8slice ser_ref;
25768         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25769         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25770         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
25771         *ret_conv = Event_read(ser_ref);
25772         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25773         return tag_ptr(ret_conv, true);
25774 }
25775
25776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25777         if (!ptr_is_owned(this_ptr)) return;
25778         void* this_ptr_ptr = untag_ptr(this_ptr);
25779         CHECK_ACCESS(this_ptr_ptr);
25780         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
25781         FREE(untag_ptr(this_ptr));
25782         MessageSendEvent_free(this_ptr_conv);
25783 }
25784
25785 static inline uint64_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
25786         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25787         *ret_copy = MessageSendEvent_clone(arg);
25788         int64_t ret_ref = tag_ptr(ret_copy, true);
25789         return ret_ref;
25790 }
25791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25792         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)untag_ptr(arg);
25793         int64_t ret_conv = MessageSendEvent_clone_ptr(arg_conv);
25794         return ret_conv;
25795 }
25796
25797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25798         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)untag_ptr(orig);
25799         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25800         *ret_copy = MessageSendEvent_clone(orig_conv);
25801         int64_t ret_ref = tag_ptr(ret_copy, true);
25802         return ret_ref;
25803 }
25804
25805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25806         LDKPublicKey node_id_ref;
25807         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25808         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25809         LDKAcceptChannel msg_conv;
25810         msg_conv.inner = untag_ptr(msg);
25811         msg_conv.is_owned = ptr_is_owned(msg);
25812         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25813         msg_conv = AcceptChannel_clone(&msg_conv);
25814         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25815         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
25816         int64_t ret_ref = tag_ptr(ret_copy, true);
25817         return ret_ref;
25818 }
25819
25820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25821         LDKPublicKey node_id_ref;
25822         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25823         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25824         LDKOpenChannel msg_conv;
25825         msg_conv.inner = untag_ptr(msg);
25826         msg_conv.is_owned = ptr_is_owned(msg);
25827         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25828         msg_conv = OpenChannel_clone(&msg_conv);
25829         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25830         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
25831         int64_t ret_ref = tag_ptr(ret_copy, true);
25832         return ret_ref;
25833 }
25834
25835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25836         LDKPublicKey node_id_ref;
25837         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25838         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25839         LDKFundingCreated msg_conv;
25840         msg_conv.inner = untag_ptr(msg);
25841         msg_conv.is_owned = ptr_is_owned(msg);
25842         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25843         msg_conv = FundingCreated_clone(&msg_conv);
25844         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25845         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
25846         int64_t ret_ref = tag_ptr(ret_copy, true);
25847         return ret_ref;
25848 }
25849
25850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25851         LDKPublicKey node_id_ref;
25852         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25853         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25854         LDKFundingSigned msg_conv;
25855         msg_conv.inner = untag_ptr(msg);
25856         msg_conv.is_owned = ptr_is_owned(msg);
25857         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25858         msg_conv = FundingSigned_clone(&msg_conv);
25859         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25860         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
25861         int64_t ret_ref = tag_ptr(ret_copy, true);
25862         return ret_ref;
25863 }
25864
25865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1ready(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25866         LDKPublicKey node_id_ref;
25867         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25868         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25869         LDKChannelReady msg_conv;
25870         msg_conv.inner = untag_ptr(msg);
25871         msg_conv.is_owned = ptr_is_owned(msg);
25872         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25873         msg_conv = ChannelReady_clone(&msg_conv);
25874         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25875         *ret_copy = MessageSendEvent_send_channel_ready(node_id_ref, msg_conv);
25876         int64_t ret_ref = tag_ptr(ret_copy, true);
25877         return ret_ref;
25878 }
25879
25880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25881         LDKPublicKey node_id_ref;
25882         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25883         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25884         LDKAnnouncementSignatures msg_conv;
25885         msg_conv.inner = untag_ptr(msg);
25886         msg_conv.is_owned = ptr_is_owned(msg);
25887         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25888         msg_conv = AnnouncementSignatures_clone(&msg_conv);
25889         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25890         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
25891         int64_t ret_ref = tag_ptr(ret_copy, true);
25892         return ret_ref;
25893 }
25894
25895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
25896         LDKPublicKey node_id_ref;
25897         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25898         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25899         LDKCommitmentUpdate updates_conv;
25900         updates_conv.inner = untag_ptr(updates);
25901         updates_conv.is_owned = ptr_is_owned(updates);
25902         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
25903         updates_conv = CommitmentUpdate_clone(&updates_conv);
25904         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25905         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
25906         int64_t ret_ref = tag_ptr(ret_copy, true);
25907         return ret_ref;
25908 }
25909
25910 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) {
25911         LDKPublicKey node_id_ref;
25912         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25913         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25914         LDKRevokeAndACK msg_conv;
25915         msg_conv.inner = untag_ptr(msg);
25916         msg_conv.is_owned = ptr_is_owned(msg);
25917         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25918         msg_conv = RevokeAndACK_clone(&msg_conv);
25919         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25920         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
25921         int64_t ret_ref = tag_ptr(ret_copy, true);
25922         return ret_ref;
25923 }
25924
25925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25926         LDKPublicKey node_id_ref;
25927         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25928         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25929         LDKClosingSigned msg_conv;
25930         msg_conv.inner = untag_ptr(msg);
25931         msg_conv.is_owned = ptr_is_owned(msg);
25932         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25933         msg_conv = ClosingSigned_clone(&msg_conv);
25934         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25935         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
25936         int64_t ret_ref = tag_ptr(ret_copy, true);
25937         return ret_ref;
25938 }
25939
25940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25941         LDKPublicKey node_id_ref;
25942         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25943         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25944         LDKShutdown msg_conv;
25945         msg_conv.inner = untag_ptr(msg);
25946         msg_conv.is_owned = ptr_is_owned(msg);
25947         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25948         msg_conv = Shutdown_clone(&msg_conv);
25949         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25950         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
25951         int64_t ret_ref = tag_ptr(ret_copy, true);
25952         return ret_ref;
25953 }
25954
25955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25956         LDKPublicKey node_id_ref;
25957         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25958         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25959         LDKChannelReestablish msg_conv;
25960         msg_conv.inner = untag_ptr(msg);
25961         msg_conv.is_owned = ptr_is_owned(msg);
25962         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25963         msg_conv = ChannelReestablish_clone(&msg_conv);
25964         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25965         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
25966         int64_t ret_ref = tag_ptr(ret_copy, true);
25967         return ret_ref;
25968 }
25969
25970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1announcement(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg, int64_t update_msg) {
25971         LDKPublicKey node_id_ref;
25972         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25973         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25974         LDKChannelAnnouncement msg_conv;
25975         msg_conv.inner = untag_ptr(msg);
25976         msg_conv.is_owned = ptr_is_owned(msg);
25977         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25978         msg_conv = ChannelAnnouncement_clone(&msg_conv);
25979         LDKChannelUpdate update_msg_conv;
25980         update_msg_conv.inner = untag_ptr(update_msg);
25981         update_msg_conv.is_owned = ptr_is_owned(update_msg);
25982         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
25983         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
25984         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25985         *ret_copy = MessageSendEvent_send_channel_announcement(node_id_ref, msg_conv, update_msg_conv);
25986         int64_t ret_ref = tag_ptr(ret_copy, true);
25987         return ret_ref;
25988 }
25989
25990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
25991         LDKChannelAnnouncement msg_conv;
25992         msg_conv.inner = untag_ptr(msg);
25993         msg_conv.is_owned = ptr_is_owned(msg);
25994         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25995         msg_conv = ChannelAnnouncement_clone(&msg_conv);
25996         LDKChannelUpdate update_msg_conv;
25997         update_msg_conv.inner = untag_ptr(update_msg);
25998         update_msg_conv.is_owned = ptr_is_owned(update_msg);
25999         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
26000         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
26001         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26002         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
26003         int64_t ret_ref = tag_ptr(ret_copy, true);
26004         return ret_ref;
26005 }
26006
26007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
26008         LDKChannelUpdate msg_conv;
26009         msg_conv.inner = untag_ptr(msg);
26010         msg_conv.is_owned = ptr_is_owned(msg);
26011         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26012         msg_conv = ChannelUpdate_clone(&msg_conv);
26013         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26014         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
26015         int64_t ret_ref = tag_ptr(ret_copy, true);
26016         return ret_ref;
26017 }
26018
26019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
26020         LDKPublicKey node_id_ref;
26021         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26022         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26023         LDKChannelUpdate msg_conv;
26024         msg_conv.inner = untag_ptr(msg);
26025         msg_conv.is_owned = ptr_is_owned(msg);
26026         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26027         msg_conv = ChannelUpdate_clone(&msg_conv);
26028         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26029         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
26030         int64_t ret_ref = tag_ptr(ret_copy, true);
26031         return ret_ref;
26032 }
26033
26034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
26035         LDKPublicKey node_id_ref;
26036         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26037         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26038         void* action_ptr = untag_ptr(action);
26039         CHECK_ACCESS(action_ptr);
26040         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
26041         action_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(action));
26042         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26043         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
26044         int64_t ret_ref = tag_ptr(ret_copy, true);
26045         return ret_ref;
26046 }
26047
26048 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) {
26049         LDKPublicKey node_id_ref;
26050         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26051         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26052         LDKQueryChannelRange msg_conv;
26053         msg_conv.inner = untag_ptr(msg);
26054         msg_conv.is_owned = ptr_is_owned(msg);
26055         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26056         msg_conv = QueryChannelRange_clone(&msg_conv);
26057         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26058         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
26059         int64_t ret_ref = tag_ptr(ret_copy, true);
26060         return ret_ref;
26061 }
26062
26063 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) {
26064         LDKPublicKey node_id_ref;
26065         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26066         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26067         LDKQueryShortChannelIds msg_conv;
26068         msg_conv.inner = untag_ptr(msg);
26069         msg_conv.is_owned = ptr_is_owned(msg);
26070         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26071         msg_conv = QueryShortChannelIds_clone(&msg_conv);
26072         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26073         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
26074         int64_t ret_ref = tag_ptr(ret_copy, true);
26075         return ret_ref;
26076 }
26077
26078 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) {
26079         LDKPublicKey node_id_ref;
26080         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26081         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26082         LDKReplyChannelRange msg_conv;
26083         msg_conv.inner = untag_ptr(msg);
26084         msg_conv.is_owned = ptr_is_owned(msg);
26085         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26086         msg_conv = ReplyChannelRange_clone(&msg_conv);
26087         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26088         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
26089         int64_t ret_ref = tag_ptr(ret_copy, true);
26090         return ret_ref;
26091 }
26092
26093 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) {
26094         LDKPublicKey node_id_ref;
26095         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26096         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26097         LDKGossipTimestampFilter msg_conv;
26098         msg_conv.inner = untag_ptr(msg);
26099         msg_conv.is_owned = ptr_is_owned(msg);
26100         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26101         msg_conv = GossipTimestampFilter_clone(&msg_conv);
26102         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26103         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
26104         int64_t ret_ref = tag_ptr(ret_copy, true);
26105         return ret_ref;
26106 }
26107
26108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26109         if (!ptr_is_owned(this_ptr)) return;
26110         void* this_ptr_ptr = untag_ptr(this_ptr);
26111         CHECK_ACCESS(this_ptr_ptr);
26112         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
26113         FREE(untag_ptr(this_ptr));
26114         MessageSendEventsProvider_free(this_ptr_conv);
26115 }
26116
26117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26118         if (!ptr_is_owned(this_ptr)) return;
26119         void* this_ptr_ptr = untag_ptr(this_ptr);
26120         CHECK_ACCESS(this_ptr_ptr);
26121         LDKOnionMessageProvider this_ptr_conv = *(LDKOnionMessageProvider*)(this_ptr_ptr);
26122         FREE(untag_ptr(this_ptr));
26123         OnionMessageProvider_free(this_ptr_conv);
26124 }
26125
26126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26127         if (!ptr_is_owned(this_ptr)) return;
26128         void* this_ptr_ptr = untag_ptr(this_ptr);
26129         CHECK_ACCESS(this_ptr_ptr);
26130         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
26131         FREE(untag_ptr(this_ptr));
26132         EventsProvider_free(this_ptr_conv);
26133 }
26134
26135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26136         if (!ptr_is_owned(this_ptr)) return;
26137         void* this_ptr_ptr = untag_ptr(this_ptr);
26138         CHECK_ACCESS(this_ptr_ptr);
26139         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
26140         FREE(untag_ptr(this_ptr));
26141         EventHandler_free(this_ptr_conv);
26142 }
26143
26144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26145         if (!ptr_is_owned(this_ptr)) return;
26146         void* this_ptr_ptr = untag_ptr(this_ptr);
26147         CHECK_ACCESS(this_ptr_ptr);
26148         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
26149         FREE(untag_ptr(this_ptr));
26150         APIError_free(this_ptr_conv);
26151 }
26152
26153 static inline uint64_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
26154         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
26155         *ret_copy = APIError_clone(arg);
26156         int64_t ret_ref = tag_ptr(ret_copy, true);
26157         return ret_ref;
26158 }
26159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26160         LDKAPIError* arg_conv = (LDKAPIError*)untag_ptr(arg);
26161         int64_t ret_conv = APIError_clone_ptr(arg_conv);
26162         return ret_conv;
26163 }
26164
26165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26166         LDKAPIError* orig_conv = (LDKAPIError*)untag_ptr(orig);
26167         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
26168         *ret_copy = APIError_clone(orig_conv);
26169         int64_t ret_ref = tag_ptr(ret_copy, true);
26170         return ret_ref;
26171 }
26172
26173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
26174         LDKStr err_conv = java_to_owned_str(env, err);
26175         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
26176         *ret_copy = APIError_apimisuse_error(err_conv);
26177         int64_t ret_ref = tag_ptr(ret_copy, true);
26178         return ret_ref;
26179 }
26180
26181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
26182         LDKStr err_conv = java_to_owned_str(env, err);
26183         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
26184         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
26185         int64_t ret_ref = tag_ptr(ret_copy, true);
26186         return ret_ref;
26187 }
26188
26189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1route_1error(JNIEnv *env, jclass clz, jstring err) {
26190         LDKStr err_conv = java_to_owned_str(env, err);
26191         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
26192         *ret_copy = APIError_route_error(err_conv);
26193         int64_t ret_ref = tag_ptr(ret_copy, true);
26194         return ret_ref;
26195 }
26196
26197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
26198         LDKStr err_conv = java_to_owned_str(env, err);
26199         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
26200         *ret_copy = APIError_channel_unavailable(err_conv);
26201         int64_t ret_ref = tag_ptr(ret_copy, true);
26202         return ret_ref;
26203 }
26204
26205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1in_1progress(JNIEnv *env, jclass clz) {
26206         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
26207         *ret_copy = APIError_monitor_update_in_progress();
26208         int64_t ret_ref = tag_ptr(ret_copy, true);
26209         return ret_ref;
26210 }
26211
26212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
26213         LDKShutdownScript script_conv;
26214         script_conv.inner = untag_ptr(script);
26215         script_conv.is_owned = ptr_is_owned(script);
26216         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
26217         script_conv = ShutdownScript_clone(&script_conv);
26218         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
26219         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
26220         int64_t ret_ref = tag_ptr(ret_copy, true);
26221         return ret_ref;
26222 }
26223
26224 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_APIError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26225         LDKAPIError* a_conv = (LDKAPIError*)untag_ptr(a);
26226         LDKAPIError* b_conv = (LDKAPIError*)untag_ptr(b);
26227         jboolean ret_conv = APIError_eq(a_conv, b_conv);
26228         return ret_conv;
26229 }
26230
26231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26232         LDKBigSize this_obj_conv;
26233         this_obj_conv.inner = untag_ptr(this_obj);
26234         this_obj_conv.is_owned = ptr_is_owned(this_obj);
26235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26236         BigSize_free(this_obj_conv);
26237 }
26238
26239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
26240         LDKBigSize this_ptr_conv;
26241         this_ptr_conv.inner = untag_ptr(this_ptr);
26242         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26244         this_ptr_conv.is_owned = false;
26245         int64_t ret_conv = BigSize_get_a(&this_ptr_conv);
26246         return ret_conv;
26247 }
26248
26249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26250         LDKBigSize this_ptr_conv;
26251         this_ptr_conv.inner = untag_ptr(this_ptr);
26252         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26254         this_ptr_conv.is_owned = false;
26255         BigSize_set_a(&this_ptr_conv, val);
26256 }
26257
26258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
26259         LDKBigSize ret_var = BigSize_new(a_arg);
26260         int64_t ret_ref = 0;
26261         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26262         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26263         return ret_ref;
26264 }
26265
26266 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Hostname_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26267         LDKHostname this_obj_conv;
26268         this_obj_conv.inner = untag_ptr(this_obj);
26269         this_obj_conv.is_owned = ptr_is_owned(this_obj);
26270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26271         Hostname_free(this_obj_conv);
26272 }
26273
26274 static inline uint64_t Hostname_clone_ptr(LDKHostname *NONNULL_PTR arg) {
26275         LDKHostname ret_var = Hostname_clone(arg);
26276         int64_t ret_ref = 0;
26277         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26278         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26279         return ret_ref;
26280 }
26281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hostname_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26282         LDKHostname arg_conv;
26283         arg_conv.inner = untag_ptr(arg);
26284         arg_conv.is_owned = ptr_is_owned(arg);
26285         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26286         arg_conv.is_owned = false;
26287         int64_t ret_conv = Hostname_clone_ptr(&arg_conv);
26288         return ret_conv;
26289 }
26290
26291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hostname_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26292         LDKHostname orig_conv;
26293         orig_conv.inner = untag_ptr(orig);
26294         orig_conv.is_owned = ptr_is_owned(orig);
26295         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26296         orig_conv.is_owned = false;
26297         LDKHostname ret_var = Hostname_clone(&orig_conv);
26298         int64_t ret_ref = 0;
26299         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26300         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26301         return ret_ref;
26302 }
26303
26304 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Hostname_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26305         LDKHostname a_conv;
26306         a_conv.inner = untag_ptr(a);
26307         a_conv.is_owned = ptr_is_owned(a);
26308         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26309         a_conv.is_owned = false;
26310         LDKHostname b_conv;
26311         b_conv.inner = untag_ptr(b);
26312         b_conv.is_owned = ptr_is_owned(b);
26313         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
26314         b_conv.is_owned = false;
26315         jboolean ret_conv = Hostname_eq(&a_conv, &b_conv);
26316         return ret_conv;
26317 }
26318
26319 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_Hostname_1len(JNIEnv *env, jclass clz, int64_t this_arg) {
26320         LDKHostname 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_t ret_conv = Hostname_len(&this_arg_conv);
26326         return ret_conv;
26327 }
26328
26329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
26330         LDKu8slice msg_ref;
26331         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
26332         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
26333         unsigned char sk_arr[32];
26334         CHECK((*env)->GetArrayLength(env, sk) == 32);
26335         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
26336         unsigned char (*sk_ref)[32] = &sk_arr;
26337         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
26338         *ret_conv = sign(msg_ref, sk_ref);
26339         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
26340         return tag_ptr(ret_conv, true);
26341 }
26342
26343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
26344         LDKu8slice msg_ref;
26345         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
26346         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
26347         LDKStr sig_conv = java_to_owned_str(env, sig);
26348         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
26349         *ret_conv = recover_pk(msg_ref, sig_conv);
26350         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
26351         return tag_ptr(ret_conv, true);
26352 }
26353
26354 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
26355         LDKu8slice msg_ref;
26356         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
26357         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
26358         LDKStr sig_conv = java_to_owned_str(env, sig);
26359         LDKPublicKey pk_ref;
26360         CHECK((*env)->GetArrayLength(env, pk) == 33);
26361         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
26362         jboolean ret_conv = verify(msg_ref, sig_conv, pk_ref);
26363         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
26364         return ret_conv;
26365 }
26366
26367 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_construct_1invoice_1preimage(JNIEnv *env, jclass clz, int8_tArray hrp_bytes, jobjectArray data_without_signature) {
26368         LDKu8slice hrp_bytes_ref;
26369         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
26370         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
26371         LDKCVec_u5Z data_without_signature_constr;
26372         data_without_signature_constr.datalen = (*env)->GetArrayLength(env, data_without_signature);
26373         if (data_without_signature_constr.datalen > 0)
26374                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
26375         else
26376                 data_without_signature_constr.data = NULL;
26377         int8_t* data_without_signature_vals = (*env)->GetByteArrayElements (env, data_without_signature, NULL);
26378         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
26379                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
26380                 
26381                 data_without_signature_constr.data[h] = (LDKu5){ ._0 = data_without_signature_conv_7 };
26382         }
26383         (*env)->ReleaseByteArrayElements(env, data_without_signature, data_without_signature_vals, 0);
26384         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
26385         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26386         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26387         CVec_u8Z_free(ret_var);
26388         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
26389         return ret_arr;
26390 }
26391
26392 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26393         if (!ptr_is_owned(this_ptr)) return;
26394         void* this_ptr_ptr = untag_ptr(this_ptr);
26395         CHECK_ACCESS(this_ptr_ptr);
26396         LDKPersister this_ptr_conv = *(LDKPersister*)(this_ptr_ptr);
26397         FREE(untag_ptr(this_ptr));
26398         Persister_free(this_ptr_conv);
26399 }
26400
26401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FutureCallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26402         if (!ptr_is_owned(this_ptr)) return;
26403         void* this_ptr_ptr = untag_ptr(this_ptr);
26404         CHECK_ACCESS(this_ptr_ptr);
26405         LDKFutureCallback this_ptr_conv = *(LDKFutureCallback*)(this_ptr_ptr);
26406         FREE(untag_ptr(this_ptr));
26407         FutureCallback_free(this_ptr_conv);
26408 }
26409
26410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Future_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26411         LDKFuture this_obj_conv;
26412         this_obj_conv.inner = untag_ptr(this_obj);
26413         this_obj_conv.is_owned = ptr_is_owned(this_obj);
26414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26415         Future_free(this_obj_conv);
26416 }
26417
26418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Future_1register_1callback_1fn(JNIEnv *env, jclass clz, int64_t this_arg, int64_t callback) {
26419         LDKFuture this_arg_conv;
26420         this_arg_conv.inner = untag_ptr(this_arg);
26421         this_arg_conv.is_owned = ptr_is_owned(this_arg);
26422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26423         this_arg_conv.is_owned = false;
26424         void* callback_ptr = untag_ptr(callback);
26425         CHECK_ACCESS(callback_ptr);
26426         LDKFutureCallback callback_conv = *(LDKFutureCallback*)(callback_ptr);
26427         if (callback_conv.free == LDKFutureCallback_JCalls_free) {
26428                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26429                 LDKFutureCallback_JCalls_cloned(&callback_conv);
26430         }
26431         Future_register_callback_fn(&this_arg_conv, callback_conv);
26432 }
26433
26434 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26435         LDKLevel* orig_conv = (LDKLevel*)untag_ptr(orig);
26436         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
26437         return ret_conv;
26438 }
26439
26440 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1gossip(JNIEnv *env, jclass clz) {
26441         jclass ret_conv = LDKLevel_to_java(env, Level_gossip());
26442         return ret_conv;
26443 }
26444
26445 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
26446         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
26447         return ret_conv;
26448 }
26449
26450 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
26451         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
26452         return ret_conv;
26453 }
26454
26455 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
26456         jclass ret_conv = LDKLevel_to_java(env, Level_info());
26457         return ret_conv;
26458 }
26459
26460 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
26461         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
26462         return ret_conv;
26463 }
26464
26465 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
26466         jclass ret_conv = LDKLevel_to_java(env, Level_error());
26467         return ret_conv;
26468 }
26469
26470 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26471         LDKLevel* a_conv = (LDKLevel*)untag_ptr(a);
26472         LDKLevel* b_conv = (LDKLevel*)untag_ptr(b);
26473         jboolean ret_conv = Level_eq(a_conv, b_conv);
26474         return ret_conv;
26475 }
26476
26477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
26478         LDKLevel* o_conv = (LDKLevel*)untag_ptr(o);
26479         int64_t ret_conv = Level_hash(o_conv);
26480         return ret_conv;
26481 }
26482
26483 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
26484         jclass ret_conv = LDKLevel_to_java(env, Level_max());
26485         return ret_conv;
26486 }
26487
26488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26489         LDKRecord this_obj_conv;
26490         this_obj_conv.inner = untag_ptr(this_obj);
26491         this_obj_conv.is_owned = ptr_is_owned(this_obj);
26492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26493         Record_free(this_obj_conv);
26494 }
26495
26496 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Record_1get_1level(JNIEnv *env, jclass clz, int64_t this_ptr) {
26497         LDKRecord this_ptr_conv;
26498         this_ptr_conv.inner = untag_ptr(this_ptr);
26499         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26501         this_ptr_conv.is_owned = false;
26502         jclass ret_conv = LDKLevel_to_java(env, Record_get_level(&this_ptr_conv));
26503         return ret_conv;
26504 }
26505
26506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1level(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
26507         LDKRecord this_ptr_conv;
26508         this_ptr_conv.inner = untag_ptr(this_ptr);
26509         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26511         this_ptr_conv.is_owned = false;
26512         LDKLevel val_conv = LDKLevel_from_java(env, val);
26513         Record_set_level(&this_ptr_conv, val_conv);
26514 }
26515
26516 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1args(JNIEnv *env, jclass clz, int64_t this_ptr) {
26517         LDKRecord this_ptr_conv;
26518         this_ptr_conv.inner = untag_ptr(this_ptr);
26519         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26521         this_ptr_conv.is_owned = false;
26522         LDKStr ret_str = Record_get_args(&this_ptr_conv);
26523         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26524         Str_free(ret_str);
26525         return ret_conv;
26526 }
26527
26528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1args(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
26529         LDKRecord this_ptr_conv;
26530         this_ptr_conv.inner = untag_ptr(this_ptr);
26531         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26533         this_ptr_conv.is_owned = false;
26534         LDKStr val_conv = java_to_owned_str(env, val);
26535         Record_set_args(&this_ptr_conv, val_conv);
26536 }
26537
26538 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr) {
26539         LDKRecord this_ptr_conv;
26540         this_ptr_conv.inner = untag_ptr(this_ptr);
26541         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26543         this_ptr_conv.is_owned = false;
26544         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
26545         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26546         Str_free(ret_str);
26547         return ret_conv;
26548 }
26549
26550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
26551         LDKRecord this_ptr_conv;
26552         this_ptr_conv.inner = untag_ptr(this_ptr);
26553         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26555         this_ptr_conv.is_owned = false;
26556         LDKStr val_conv = java_to_owned_str(env, val);
26557         Record_set_module_path(&this_ptr_conv, val_conv);
26558 }
26559
26560 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1file(JNIEnv *env, jclass clz, int64_t this_ptr) {
26561         LDKRecord this_ptr_conv;
26562         this_ptr_conv.inner = untag_ptr(this_ptr);
26563         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26565         this_ptr_conv.is_owned = false;
26566         LDKStr ret_str = Record_get_file(&this_ptr_conv);
26567         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26568         Str_free(ret_str);
26569         return ret_conv;
26570 }
26571
26572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1file(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
26573         LDKRecord this_ptr_conv;
26574         this_ptr_conv.inner = untag_ptr(this_ptr);
26575         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26577         this_ptr_conv.is_owned = false;
26578         LDKStr val_conv = java_to_owned_str(env, val);
26579         Record_set_file(&this_ptr_conv, val_conv);
26580 }
26581
26582 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_Record_1get_1line(JNIEnv *env, jclass clz, int64_t this_ptr) {
26583         LDKRecord this_ptr_conv;
26584         this_ptr_conv.inner = untag_ptr(this_ptr);
26585         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26587         this_ptr_conv.is_owned = false;
26588         int32_t ret_conv = Record_get_line(&this_ptr_conv);
26589         return ret_conv;
26590 }
26591
26592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1line(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
26593         LDKRecord this_ptr_conv;
26594         this_ptr_conv.inner = untag_ptr(this_ptr);
26595         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26597         this_ptr_conv.is_owned = false;
26598         Record_set_line(&this_ptr_conv, val);
26599 }
26600
26601 static inline uint64_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
26602         LDKRecord ret_var = Record_clone(arg);
26603         int64_t ret_ref = 0;
26604         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26605         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26606         return ret_ref;
26607 }
26608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26609         LDKRecord arg_conv;
26610         arg_conv.inner = untag_ptr(arg);
26611         arg_conv.is_owned = ptr_is_owned(arg);
26612         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26613         arg_conv.is_owned = false;
26614         int64_t ret_conv = Record_clone_ptr(&arg_conv);
26615         return ret_conv;
26616 }
26617
26618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26619         LDKRecord orig_conv;
26620         orig_conv.inner = untag_ptr(orig);
26621         orig_conv.is_owned = ptr_is_owned(orig);
26622         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26623         orig_conv.is_owned = false;
26624         LDKRecord ret_var = Record_clone(&orig_conv);
26625         int64_t ret_ref = 0;
26626         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26627         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26628         return ret_ref;
26629 }
26630
26631 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26632         if (!ptr_is_owned(this_ptr)) return;
26633         void* this_ptr_ptr = untag_ptr(this_ptr);
26634         CHECK_ACCESS(this_ptr_ptr);
26635         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
26636         FREE(untag_ptr(this_ptr));
26637         Logger_free(this_ptr_conv);
26638 }
26639
26640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26641         LDKChannelHandshakeConfig this_obj_conv;
26642         this_obj_conv.inner = untag_ptr(this_obj);
26643         this_obj_conv.is_owned = ptr_is_owned(this_obj);
26644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26645         ChannelHandshakeConfig_free(this_obj_conv);
26646 }
26647
26648 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
26649         LDKChannelHandshakeConfig this_ptr_conv;
26650         this_ptr_conv.inner = untag_ptr(this_ptr);
26651         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26653         this_ptr_conv.is_owned = false;
26654         int32_t ret_conv = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
26655         return ret_conv;
26656 }
26657
26658 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
26659         LDKChannelHandshakeConfig this_ptr_conv;
26660         this_ptr_conv.inner = untag_ptr(this_ptr);
26661         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26663         this_ptr_conv.is_owned = false;
26664         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
26665 }
26666
26667 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
26668         LDKChannelHandshakeConfig this_ptr_conv;
26669         this_ptr_conv.inner = untag_ptr(this_ptr);
26670         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26672         this_ptr_conv.is_owned = false;
26673         int16_t ret_conv = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
26674         return ret_conv;
26675 }
26676
26677 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) {
26678         LDKChannelHandshakeConfig this_ptr_conv;
26679         this_ptr_conv.inner = untag_ptr(this_ptr);
26680         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26682         this_ptr_conv.is_owned = false;
26683         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
26684 }
26685
26686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
26687         LDKChannelHandshakeConfig this_ptr_conv;
26688         this_ptr_conv.inner = untag_ptr(this_ptr);
26689         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26691         this_ptr_conv.is_owned = false;
26692         int64_t ret_conv = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
26693         return ret_conv;
26694 }
26695
26696 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) {
26697         LDKChannelHandshakeConfig this_ptr_conv;
26698         this_ptr_conv.inner = untag_ptr(this_ptr);
26699         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26701         this_ptr_conv.is_owned = false;
26702         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
26703 }
26704
26705 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) {
26706         LDKChannelHandshakeConfig this_ptr_conv;
26707         this_ptr_conv.inner = untag_ptr(this_ptr);
26708         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26710         this_ptr_conv.is_owned = false;
26711         int8_t ret_conv = ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv);
26712         return ret_conv;
26713 }
26714
26715 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) {
26716         LDKChannelHandshakeConfig this_ptr_conv;
26717         this_ptr_conv.inner = untag_ptr(this_ptr);
26718         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26720         this_ptr_conv.is_owned = false;
26721         ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv, val);
26722 }
26723
26724 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr) {
26725         LDKChannelHandshakeConfig this_ptr_conv;
26726         this_ptr_conv.inner = untag_ptr(this_ptr);
26727         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26729         this_ptr_conv.is_owned = false;
26730         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
26731         return ret_conv;
26732 }
26733
26734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26735         LDKChannelHandshakeConfig this_ptr_conv;
26736         this_ptr_conv.inner = untag_ptr(this_ptr);
26737         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26739         this_ptr_conv.is_owned = false;
26740         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
26741 }
26742
26743 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
26744         LDKChannelHandshakeConfig this_ptr_conv;
26745         this_ptr_conv.inner = untag_ptr(this_ptr);
26746         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26748         this_ptr_conv.is_owned = false;
26749         jboolean ret_conv = ChannelHandshakeConfig_get_announced_channel(&this_ptr_conv);
26750         return ret_conv;
26751 }
26752
26753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26754         LDKChannelHandshakeConfig this_ptr_conv;
26755         this_ptr_conv.inner = untag_ptr(this_ptr);
26756         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26758         this_ptr_conv.is_owned = false;
26759         ChannelHandshakeConfig_set_announced_channel(&this_ptr_conv, val);
26760 }
26761
26762 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
26763         LDKChannelHandshakeConfig this_ptr_conv;
26764         this_ptr_conv.inner = untag_ptr(this_ptr);
26765         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26767         this_ptr_conv.is_owned = false;
26768         jboolean ret_conv = ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
26769         return ret_conv;
26770 }
26771
26772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26773         LDKChannelHandshakeConfig this_ptr_conv;
26774         this_ptr_conv.inner = untag_ptr(this_ptr);
26775         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26777         this_ptr_conv.is_owned = false;
26778         ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
26779 }
26780
26781 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1their_1channel_1reserve_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
26782         LDKChannelHandshakeConfig this_ptr_conv;
26783         this_ptr_conv.inner = untag_ptr(this_ptr);
26784         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26786         this_ptr_conv.is_owned = false;
26787         int32_t ret_conv = ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths(&this_ptr_conv);
26788         return ret_conv;
26789 }
26790
26791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1their_1channel_1reserve_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
26792         LDKChannelHandshakeConfig this_ptr_conv;
26793         this_ptr_conv.inner = untag_ptr(this_ptr);
26794         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26796         this_ptr_conv.is_owned = false;
26797         ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(&this_ptr_conv, val);
26798 }
26799
26800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1new(JNIEnv *env, jclass clz, int32_t minimum_depth_arg, int16_t our_to_self_delay_arg, int64_t our_htlc_minimum_msat_arg, int8_t max_inbound_htlc_value_in_flight_percent_of_channel_arg, jboolean negotiate_scid_privacy_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg, int32_t their_channel_reserve_proportional_millionths_arg) {
26801         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg, max_inbound_htlc_value_in_flight_percent_of_channel_arg, negotiate_scid_privacy_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg, their_channel_reserve_proportional_millionths_arg);
26802         int64_t ret_ref = 0;
26803         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26804         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26805         return ret_ref;
26806 }
26807
26808 static inline uint64_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
26809         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
26810         int64_t ret_ref = 0;
26811         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26812         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26813         return ret_ref;
26814 }
26815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26816         LDKChannelHandshakeConfig arg_conv;
26817         arg_conv.inner = untag_ptr(arg);
26818         arg_conv.is_owned = ptr_is_owned(arg);
26819         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26820         arg_conv.is_owned = false;
26821         int64_t ret_conv = ChannelHandshakeConfig_clone_ptr(&arg_conv);
26822         return ret_conv;
26823 }
26824
26825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26826         LDKChannelHandshakeConfig orig_conv;
26827         orig_conv.inner = untag_ptr(orig);
26828         orig_conv.is_owned = ptr_is_owned(orig);
26829         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26830         orig_conv.is_owned = false;
26831         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
26832         int64_t ret_ref = 0;
26833         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26834         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26835         return ret_ref;
26836 }
26837
26838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
26839         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
26840         int64_t ret_ref = 0;
26841         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26842         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26843         return ret_ref;
26844 }
26845
26846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26847         LDKChannelHandshakeLimits this_obj_conv;
26848         this_obj_conv.inner = untag_ptr(this_obj);
26849         this_obj_conv.is_owned = ptr_is_owned(this_obj);
26850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26851         ChannelHandshakeLimits_free(this_obj_conv);
26852 }
26853
26854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26855         LDKChannelHandshakeLimits this_ptr_conv;
26856         this_ptr_conv.inner = untag_ptr(this_ptr);
26857         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26859         this_ptr_conv.is_owned = false;
26860         int64_t ret_conv = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
26861         return ret_conv;
26862 }
26863
26864 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26865         LDKChannelHandshakeLimits this_ptr_conv;
26866         this_ptr_conv.inner = untag_ptr(this_ptr);
26867         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26869         this_ptr_conv.is_owned = false;
26870         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
26871 }
26872
26873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26874         LDKChannelHandshakeLimits this_ptr_conv;
26875         this_ptr_conv.inner = untag_ptr(this_ptr);
26876         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26878         this_ptr_conv.is_owned = false;
26879         int64_t ret_conv = ChannelHandshakeLimits_get_max_funding_satoshis(&this_ptr_conv);
26880         return ret_conv;
26881 }
26882
26883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26884         LDKChannelHandshakeLimits this_ptr_conv;
26885         this_ptr_conv.inner = untag_ptr(this_ptr);
26886         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26888         this_ptr_conv.is_owned = false;
26889         ChannelHandshakeLimits_set_max_funding_satoshis(&this_ptr_conv, val);
26890 }
26891
26892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
26893         LDKChannelHandshakeLimits this_ptr_conv;
26894         this_ptr_conv.inner = untag_ptr(this_ptr);
26895         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26897         this_ptr_conv.is_owned = false;
26898         int64_t ret_conv = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
26899         return ret_conv;
26900 }
26901
26902 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) {
26903         LDKChannelHandshakeLimits this_ptr_conv;
26904         this_ptr_conv.inner = untag_ptr(this_ptr);
26905         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26907         this_ptr_conv.is_owned = false;
26908         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
26909 }
26910
26911 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) {
26912         LDKChannelHandshakeLimits this_ptr_conv;
26913         this_ptr_conv.inner = untag_ptr(this_ptr);
26914         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26916         this_ptr_conv.is_owned = false;
26917         int64_t ret_conv = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
26918         return ret_conv;
26919 }
26920
26921 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) {
26922         LDKChannelHandshakeLimits this_ptr_conv;
26923         this_ptr_conv.inner = untag_ptr(this_ptr);
26924         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26926         this_ptr_conv.is_owned = false;
26927         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
26928 }
26929
26930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26931         LDKChannelHandshakeLimits this_ptr_conv;
26932         this_ptr_conv.inner = untag_ptr(this_ptr);
26933         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26935         this_ptr_conv.is_owned = false;
26936         int64_t ret_conv = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
26937         return ret_conv;
26938 }
26939
26940 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) {
26941         LDKChannelHandshakeLimits this_ptr_conv;
26942         this_ptr_conv.inner = untag_ptr(this_ptr);
26943         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26945         this_ptr_conv.is_owned = false;
26946         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
26947 }
26948
26949 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
26950         LDKChannelHandshakeLimits this_ptr_conv;
26951         this_ptr_conv.inner = untag_ptr(this_ptr);
26952         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26954         this_ptr_conv.is_owned = false;
26955         int16_t ret_conv = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
26956         return ret_conv;
26957 }
26958
26959 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) {
26960         LDKChannelHandshakeLimits this_ptr_conv;
26961         this_ptr_conv.inner = untag_ptr(this_ptr);
26962         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26964         this_ptr_conv.is_owned = false;
26965         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
26966 }
26967
26968 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
26969         LDKChannelHandshakeLimits this_ptr_conv;
26970         this_ptr_conv.inner = untag_ptr(this_ptr);
26971         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26973         this_ptr_conv.is_owned = false;
26974         int32_t ret_conv = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
26975         return ret_conv;
26976 }
26977
26978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
26979         LDKChannelHandshakeLimits this_ptr_conv;
26980         this_ptr_conv.inner = untag_ptr(this_ptr);
26981         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26983         this_ptr_conv.is_owned = false;
26984         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
26985 }
26986
26987 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr) {
26988         LDKChannelHandshakeLimits this_ptr_conv;
26989         this_ptr_conv.inner = untag_ptr(this_ptr);
26990         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26992         this_ptr_conv.is_owned = false;
26993         jboolean ret_conv = ChannelHandshakeLimits_get_trust_own_funding_0conf(&this_ptr_conv);
26994         return ret_conv;
26995 }
26996
26997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26998         LDKChannelHandshakeLimits this_ptr_conv;
26999         this_ptr_conv.inner = untag_ptr(this_ptr);
27000         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27002         this_ptr_conv.is_owned = false;
27003         ChannelHandshakeLimits_set_trust_own_funding_0conf(&this_ptr_conv, val);
27004 }
27005
27006 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
27007         LDKChannelHandshakeLimits this_ptr_conv;
27008         this_ptr_conv.inner = untag_ptr(this_ptr);
27009         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27011         this_ptr_conv.is_owned = false;
27012         jboolean ret_conv = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
27013         return ret_conv;
27014 }
27015
27016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27017         LDKChannelHandshakeLimits this_ptr_conv;
27018         this_ptr_conv.inner = untag_ptr(this_ptr);
27019         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27021         this_ptr_conv.is_owned = false;
27022         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
27023 }
27024
27025 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
27026         LDKChannelHandshakeLimits this_ptr_conv;
27027         this_ptr_conv.inner = untag_ptr(this_ptr);
27028         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27030         this_ptr_conv.is_owned = false;
27031         int16_t ret_conv = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
27032         return ret_conv;
27033 }
27034
27035 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) {
27036         LDKChannelHandshakeLimits this_ptr_conv;
27037         this_ptr_conv.inner = untag_ptr(this_ptr);
27038         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27040         this_ptr_conv.is_owned = false;
27041         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
27042 }
27043
27044 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) {
27045         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);
27046         int64_t ret_ref = 0;
27047         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27048         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27049         return ret_ref;
27050 }
27051
27052 static inline uint64_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
27053         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
27054         int64_t ret_ref = 0;
27055         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27056         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27057         return ret_ref;
27058 }
27059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27060         LDKChannelHandshakeLimits arg_conv;
27061         arg_conv.inner = untag_ptr(arg);
27062         arg_conv.is_owned = ptr_is_owned(arg);
27063         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27064         arg_conv.is_owned = false;
27065         int64_t ret_conv = ChannelHandshakeLimits_clone_ptr(&arg_conv);
27066         return ret_conv;
27067 }
27068
27069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27070         LDKChannelHandshakeLimits orig_conv;
27071         orig_conv.inner = untag_ptr(orig);
27072         orig_conv.is_owned = ptr_is_owned(orig);
27073         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27074         orig_conv.is_owned = false;
27075         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
27076         int64_t ret_ref = 0;
27077         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27078         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27079         return ret_ref;
27080 }
27081
27082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
27083         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
27084         int64_t ret_ref = 0;
27085         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27086         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27087         return ret_ref;
27088 }
27089
27090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27091         LDKChannelConfig this_obj_conv;
27092         this_obj_conv.inner = untag_ptr(this_obj);
27093         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27095         ChannelConfig_free(this_obj_conv);
27096 }
27097
27098 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
27099         LDKChannelConfig 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         int32_t ret_conv = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
27105         return ret_conv;
27106 }
27107
27108 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) {
27109         LDKChannelConfig this_ptr_conv;
27110         this_ptr_conv.inner = untag_ptr(this_ptr);
27111         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27113         this_ptr_conv.is_owned = false;
27114         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
27115 }
27116
27117 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27118         LDKChannelConfig this_ptr_conv;
27119         this_ptr_conv.inner = untag_ptr(this_ptr);
27120         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27122         this_ptr_conv.is_owned = false;
27123         int32_t ret_conv = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
27124         return ret_conv;
27125 }
27126
27127 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) {
27128         LDKChannelConfig this_ptr_conv;
27129         this_ptr_conv.inner = untag_ptr(this_ptr);
27130         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27132         this_ptr_conv.is_owned = false;
27133         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
27134 }
27135
27136 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
27137         LDKChannelConfig this_ptr_conv;
27138         this_ptr_conv.inner = untag_ptr(this_ptr);
27139         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27141         this_ptr_conv.is_owned = false;
27142         int16_t ret_conv = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
27143         return ret_conv;
27144 }
27145
27146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
27147         LDKChannelConfig this_ptr_conv;
27148         this_ptr_conv.inner = untag_ptr(this_ptr);
27149         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27151         this_ptr_conv.is_owned = false;
27152         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
27153 }
27154
27155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27156         LDKChannelConfig this_ptr_conv;
27157         this_ptr_conv.inner = untag_ptr(this_ptr);
27158         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27160         this_ptr_conv.is_owned = false;
27161         int64_t ret_conv = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
27162         return ret_conv;
27163 }
27164
27165 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) {
27166         LDKChannelConfig this_ptr_conv;
27167         this_ptr_conv.inner = untag_ptr(this_ptr);
27168         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27170         this_ptr_conv.is_owned = false;
27171         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
27172 }
27173
27174 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) {
27175         LDKChannelConfig this_ptr_conv;
27176         this_ptr_conv.inner = untag_ptr(this_ptr);
27177         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27179         this_ptr_conv.is_owned = false;
27180         int64_t ret_conv = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
27181         return ret_conv;
27182 }
27183
27184 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) {
27185         LDKChannelConfig this_ptr_conv;
27186         this_ptr_conv.inner = untag_ptr(this_ptr);
27187         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27189         this_ptr_conv.is_owned = false;
27190         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
27191 }
27192
27193 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) {
27194         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);
27195         int64_t ret_ref = 0;
27196         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27197         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27198         return ret_ref;
27199 }
27200
27201 static inline uint64_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
27202         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
27203         int64_t ret_ref = 0;
27204         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27205         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27206         return ret_ref;
27207 }
27208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27209         LDKChannelConfig arg_conv;
27210         arg_conv.inner = untag_ptr(arg);
27211         arg_conv.is_owned = ptr_is_owned(arg);
27212         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27213         arg_conv.is_owned = false;
27214         int64_t ret_conv = ChannelConfig_clone_ptr(&arg_conv);
27215         return ret_conv;
27216 }
27217
27218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27219         LDKChannelConfig orig_conv;
27220         orig_conv.inner = untag_ptr(orig);
27221         orig_conv.is_owned = ptr_is_owned(orig);
27222         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27223         orig_conv.is_owned = false;
27224         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
27225         int64_t ret_ref = 0;
27226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27227         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27228         return ret_ref;
27229 }
27230
27231 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27232         LDKChannelConfig a_conv;
27233         a_conv.inner = untag_ptr(a);
27234         a_conv.is_owned = ptr_is_owned(a);
27235         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27236         a_conv.is_owned = false;
27237         LDKChannelConfig b_conv;
27238         b_conv.inner = untag_ptr(b);
27239         b_conv.is_owned = ptr_is_owned(b);
27240         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
27241         b_conv.is_owned = false;
27242         jboolean ret_conv = ChannelConfig_eq(&a_conv, &b_conv);
27243         return ret_conv;
27244 }
27245
27246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
27247         LDKChannelConfig ret_var = ChannelConfig_default();
27248         int64_t ret_ref = 0;
27249         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27250         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27251         return ret_ref;
27252 }
27253
27254 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
27255         LDKChannelConfig obj_conv;
27256         obj_conv.inner = untag_ptr(obj);
27257         obj_conv.is_owned = ptr_is_owned(obj);
27258         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27259         obj_conv.is_owned = false;
27260         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
27261         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27262         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27263         CVec_u8Z_free(ret_var);
27264         return ret_arr;
27265 }
27266
27267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27268         LDKu8slice ser_ref;
27269         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27270         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27271         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
27272         *ret_conv = ChannelConfig_read(ser_ref);
27273         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27274         return tag_ptr(ret_conv, true);
27275 }
27276
27277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27278         LDKUserConfig this_obj_conv;
27279         this_obj_conv.inner = untag_ptr(this_obj);
27280         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27282         UserConfig_free(this_obj_conv);
27283 }
27284
27285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
27286         LDKUserConfig this_ptr_conv;
27287         this_ptr_conv.inner = untag_ptr(this_ptr);
27288         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27290         this_ptr_conv.is_owned = false;
27291         LDKChannelHandshakeConfig ret_var = UserConfig_get_channel_handshake_config(&this_ptr_conv);
27292         int64_t ret_ref = 0;
27293         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27294         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27295         return ret_ref;
27296 }
27297
27298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27299         LDKUserConfig this_ptr_conv;
27300         this_ptr_conv.inner = untag_ptr(this_ptr);
27301         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27303         this_ptr_conv.is_owned = false;
27304         LDKChannelHandshakeConfig val_conv;
27305         val_conv.inner = untag_ptr(val);
27306         val_conv.is_owned = ptr_is_owned(val);
27307         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27308         val_conv = ChannelHandshakeConfig_clone(&val_conv);
27309         UserConfig_set_channel_handshake_config(&this_ptr_conv, val_conv);
27310 }
27311
27312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
27313         LDKUserConfig this_ptr_conv;
27314         this_ptr_conv.inner = untag_ptr(this_ptr);
27315         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27317         this_ptr_conv.is_owned = false;
27318         LDKChannelHandshakeLimits ret_var = UserConfig_get_channel_handshake_limits(&this_ptr_conv);
27319         int64_t ret_ref = 0;
27320         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27321         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27322         return ret_ref;
27323 }
27324
27325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27326         LDKUserConfig this_ptr_conv;
27327         this_ptr_conv.inner = untag_ptr(this_ptr);
27328         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27330         this_ptr_conv.is_owned = false;
27331         LDKChannelHandshakeLimits val_conv;
27332         val_conv.inner = untag_ptr(val);
27333         val_conv.is_owned = ptr_is_owned(val);
27334         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27335         val_conv = ChannelHandshakeLimits_clone(&val_conv);
27336         UserConfig_set_channel_handshake_limits(&this_ptr_conv, val_conv);
27337 }
27338
27339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
27340         LDKUserConfig this_ptr_conv;
27341         this_ptr_conv.inner = untag_ptr(this_ptr);
27342         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27344         this_ptr_conv.is_owned = false;
27345         LDKChannelConfig ret_var = UserConfig_get_channel_config(&this_ptr_conv);
27346         int64_t ret_ref = 0;
27347         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27348         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27349         return ret_ref;
27350 }
27351
27352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27353         LDKUserConfig this_ptr_conv;
27354         this_ptr_conv.inner = untag_ptr(this_ptr);
27355         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27357         this_ptr_conv.is_owned = false;
27358         LDKChannelConfig val_conv;
27359         val_conv.inner = untag_ptr(val);
27360         val_conv.is_owned = ptr_is_owned(val);
27361         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27362         val_conv = ChannelConfig_clone(&val_conv);
27363         UserConfig_set_channel_config(&this_ptr_conv, val_conv);
27364 }
27365
27366 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
27367         LDKUserConfig this_ptr_conv;
27368         this_ptr_conv.inner = untag_ptr(this_ptr);
27369         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27371         this_ptr_conv.is_owned = false;
27372         jboolean ret_conv = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
27373         return ret_conv;
27374 }
27375
27376 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) {
27377         LDKUserConfig this_ptr_conv;
27378         this_ptr_conv.inner = untag_ptr(this_ptr);
27379         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27381         this_ptr_conv.is_owned = false;
27382         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
27383 }
27384
27385 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
27386         LDKUserConfig this_ptr_conv;
27387         this_ptr_conv.inner = untag_ptr(this_ptr);
27388         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27390         this_ptr_conv.is_owned = false;
27391         jboolean ret_conv = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
27392         return ret_conv;
27393 }
27394
27395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27396         LDKUserConfig this_ptr_conv;
27397         this_ptr_conv.inner = untag_ptr(this_ptr);
27398         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27400         this_ptr_conv.is_owned = false;
27401         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
27402 }
27403
27404 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
27405         LDKUserConfig this_ptr_conv;
27406         this_ptr_conv.inner = untag_ptr(this_ptr);
27407         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27409         this_ptr_conv.is_owned = false;
27410         jboolean ret_conv = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
27411         return ret_conv;
27412 }
27413
27414 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27415         LDKUserConfig this_ptr_conv;
27416         this_ptr_conv.inner = untag_ptr(this_ptr);
27417         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27419         this_ptr_conv.is_owned = false;
27420         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
27421 }
27422
27423 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) {
27424         LDKChannelHandshakeConfig channel_handshake_config_arg_conv;
27425         channel_handshake_config_arg_conv.inner = untag_ptr(channel_handshake_config_arg);
27426         channel_handshake_config_arg_conv.is_owned = ptr_is_owned(channel_handshake_config_arg);
27427         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_config_arg_conv);
27428         channel_handshake_config_arg_conv = ChannelHandshakeConfig_clone(&channel_handshake_config_arg_conv);
27429         LDKChannelHandshakeLimits channel_handshake_limits_arg_conv;
27430         channel_handshake_limits_arg_conv.inner = untag_ptr(channel_handshake_limits_arg);
27431         channel_handshake_limits_arg_conv.is_owned = ptr_is_owned(channel_handshake_limits_arg);
27432         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_limits_arg_conv);
27433         channel_handshake_limits_arg_conv = ChannelHandshakeLimits_clone(&channel_handshake_limits_arg_conv);
27434         LDKChannelConfig channel_config_arg_conv;
27435         channel_config_arg_conv.inner = untag_ptr(channel_config_arg);
27436         channel_config_arg_conv.is_owned = ptr_is_owned(channel_config_arg);
27437         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_config_arg_conv);
27438         channel_config_arg_conv = ChannelConfig_clone(&channel_config_arg_conv);
27439         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);
27440         int64_t ret_ref = 0;
27441         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27442         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27443         return ret_ref;
27444 }
27445
27446 static inline uint64_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
27447         LDKUserConfig ret_var = UserConfig_clone(arg);
27448         int64_t ret_ref = 0;
27449         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27450         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27451         return ret_ref;
27452 }
27453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27454         LDKUserConfig arg_conv;
27455         arg_conv.inner = untag_ptr(arg);
27456         arg_conv.is_owned = ptr_is_owned(arg);
27457         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27458         arg_conv.is_owned = false;
27459         int64_t ret_conv = UserConfig_clone_ptr(&arg_conv);
27460         return ret_conv;
27461 }
27462
27463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27464         LDKUserConfig orig_conv;
27465         orig_conv.inner = untag_ptr(orig);
27466         orig_conv.is_owned = ptr_is_owned(orig);
27467         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27468         orig_conv.is_owned = false;
27469         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
27470         int64_t ret_ref = 0;
27471         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27472         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27473         return ret_ref;
27474 }
27475
27476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
27477         LDKUserConfig ret_var = UserConfig_default();
27478         int64_t ret_ref = 0;
27479         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27480         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27481         return ret_ref;
27482 }
27483
27484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27485         LDKBestBlock this_obj_conv;
27486         this_obj_conv.inner = untag_ptr(this_obj);
27487         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27489         BestBlock_free(this_obj_conv);
27490 }
27491
27492 static inline uint64_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
27493         LDKBestBlock ret_var = BestBlock_clone(arg);
27494         int64_t ret_ref = 0;
27495         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27496         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27497         return ret_ref;
27498 }
27499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27500         LDKBestBlock arg_conv;
27501         arg_conv.inner = untag_ptr(arg);
27502         arg_conv.is_owned = ptr_is_owned(arg);
27503         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27504         arg_conv.is_owned = false;
27505         int64_t ret_conv = BestBlock_clone_ptr(&arg_conv);
27506         return ret_conv;
27507 }
27508
27509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27510         LDKBestBlock orig_conv;
27511         orig_conv.inner = untag_ptr(orig);
27512         orig_conv.is_owned = ptr_is_owned(orig);
27513         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27514         orig_conv.is_owned = false;
27515         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
27516         int64_t ret_ref = 0;
27517         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27518         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27519         return ret_ref;
27520 }
27521
27522 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BestBlock_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27523         LDKBestBlock a_conv;
27524         a_conv.inner = untag_ptr(a);
27525         a_conv.is_owned = ptr_is_owned(a);
27526         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27527         a_conv.is_owned = false;
27528         LDKBestBlock b_conv;
27529         b_conv.inner = untag_ptr(b);
27530         b_conv.is_owned = ptr_is_owned(b);
27531         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
27532         b_conv.is_owned = false;
27533         jboolean ret_conv = BestBlock_eq(&a_conv, &b_conv);
27534         return ret_conv;
27535 }
27536
27537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
27538         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
27539         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
27540         int64_t ret_ref = 0;
27541         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27542         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27543         return ret_ref;
27544 }
27545
27546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
27547         LDKThirtyTwoBytes block_hash_ref;
27548         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
27549         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
27550         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
27551         int64_t ret_ref = 0;
27552         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27553         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27554         return ret_ref;
27555 }
27556
27557 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
27558         LDKBestBlock this_arg_conv;
27559         this_arg_conv.inner = untag_ptr(this_arg);
27560         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27562         this_arg_conv.is_owned = false;
27563         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27564         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
27565         return ret_arr;
27566 }
27567
27568 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
27569         LDKBestBlock this_arg_conv;
27570         this_arg_conv.inner = untag_ptr(this_arg);
27571         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27573         this_arg_conv.is_owned = false;
27574         int32_t ret_conv = BestBlock_height(&this_arg_conv);
27575         return ret_conv;
27576 }
27577
27578 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27579         LDKAccessError* orig_conv = (LDKAccessError*)untag_ptr(orig);
27580         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
27581         return ret_conv;
27582 }
27583
27584 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1chain(JNIEnv *env, jclass clz) {
27585         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_chain());
27586         return ret_conv;
27587 }
27588
27589 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1tx(JNIEnv *env, jclass clz) {
27590         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_tx());
27591         return ret_conv;
27592 }
27593
27594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27595         if (!ptr_is_owned(this_ptr)) return;
27596         void* this_ptr_ptr = untag_ptr(this_ptr);
27597         CHECK_ACCESS(this_ptr_ptr);
27598         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
27599         FREE(untag_ptr(this_ptr));
27600         Access_free(this_ptr_conv);
27601 }
27602
27603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27604         if (!ptr_is_owned(this_ptr)) return;
27605         void* this_ptr_ptr = untag_ptr(this_ptr);
27606         CHECK_ACCESS(this_ptr_ptr);
27607         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
27608         FREE(untag_ptr(this_ptr));
27609         Listen_free(this_ptr_conv);
27610 }
27611
27612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27613         if (!ptr_is_owned(this_ptr)) return;
27614         void* this_ptr_ptr = untag_ptr(this_ptr);
27615         CHECK_ACCESS(this_ptr_ptr);
27616         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
27617         FREE(untag_ptr(this_ptr));
27618         Confirm_free(this_ptr_conv);
27619 }
27620
27621 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27622         LDKChannelMonitorUpdateStatus* orig_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(orig);
27623         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_clone(orig_conv));
27624         return ret_conv;
27625 }
27626
27627 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1completed(JNIEnv *env, jclass clz) {
27628         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_completed());
27629         return ret_conv;
27630 }
27631
27632 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1in_1progress(JNIEnv *env, jclass clz) {
27633         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_in_progress());
27634         return ret_conv;
27635 }
27636
27637 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1permanent_1failure(JNIEnv *env, jclass clz) {
27638         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_permanent_failure());
27639         return ret_conv;
27640 }
27641
27642 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27643         LDKChannelMonitorUpdateStatus* a_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(a);
27644         LDKChannelMonitorUpdateStatus* b_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(b);
27645         jboolean ret_conv = ChannelMonitorUpdateStatus_eq(a_conv, b_conv);
27646         return ret_conv;
27647 }
27648
27649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27650         if (!ptr_is_owned(this_ptr)) return;
27651         void* this_ptr_ptr = untag_ptr(this_ptr);
27652         CHECK_ACCESS(this_ptr_ptr);
27653         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
27654         FREE(untag_ptr(this_ptr));
27655         Watch_free(this_ptr_conv);
27656 }
27657
27658 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27659         if (!ptr_is_owned(this_ptr)) return;
27660         void* this_ptr_ptr = untag_ptr(this_ptr);
27661         CHECK_ACCESS(this_ptr_ptr);
27662         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
27663         FREE(untag_ptr(this_ptr));
27664         Filter_free(this_ptr_conv);
27665 }
27666
27667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27668         LDKWatchedOutput this_obj_conv;
27669         this_obj_conv.inner = untag_ptr(this_obj);
27670         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27672         WatchedOutput_free(this_obj_conv);
27673 }
27674
27675 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
27676         LDKWatchedOutput this_ptr_conv;
27677         this_ptr_conv.inner = untag_ptr(this_ptr);
27678         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27680         this_ptr_conv.is_owned = false;
27681         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27682         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
27683         return ret_arr;
27684 }
27685
27686 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27687         LDKWatchedOutput this_ptr_conv;
27688         this_ptr_conv.inner = untag_ptr(this_ptr);
27689         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27691         this_ptr_conv.is_owned = false;
27692         LDKThirtyTwoBytes val_ref;
27693         CHECK((*env)->GetArrayLength(env, val) == 32);
27694         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27695         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
27696 }
27697
27698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
27699         LDKWatchedOutput this_ptr_conv;
27700         this_ptr_conv.inner = untag_ptr(this_ptr);
27701         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27703         this_ptr_conv.is_owned = false;
27704         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
27705         int64_t ret_ref = 0;
27706         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27707         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27708         return ret_ref;
27709 }
27710
27711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27712         LDKWatchedOutput this_ptr_conv;
27713         this_ptr_conv.inner = untag_ptr(this_ptr);
27714         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27716         this_ptr_conv.is_owned = false;
27717         LDKOutPoint val_conv;
27718         val_conv.inner = untag_ptr(val);
27719         val_conv.is_owned = ptr_is_owned(val);
27720         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27721         val_conv = OutPoint_clone(&val_conv);
27722         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
27723 }
27724
27725 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
27726         LDKWatchedOutput this_ptr_conv;
27727         this_ptr_conv.inner = untag_ptr(this_ptr);
27728         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27730         this_ptr_conv.is_owned = false;
27731         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
27732         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27733         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27734         return ret_arr;
27735 }
27736
27737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27738         LDKWatchedOutput this_ptr_conv;
27739         this_ptr_conv.inner = untag_ptr(this_ptr);
27740         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27742         this_ptr_conv.is_owned = false;
27743         LDKCVec_u8Z val_ref;
27744         val_ref.datalen = (*env)->GetArrayLength(env, val);
27745         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
27746         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
27747         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
27748 }
27749
27750 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) {
27751         LDKThirtyTwoBytes block_hash_arg_ref;
27752         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
27753         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
27754         LDKOutPoint outpoint_arg_conv;
27755         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
27756         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
27757         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
27758         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
27759         LDKCVec_u8Z script_pubkey_arg_ref;
27760         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
27761         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
27762         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
27763         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
27764         int64_t ret_ref = 0;
27765         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27766         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27767         return ret_ref;
27768 }
27769
27770 static inline uint64_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
27771         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
27772         int64_t ret_ref = 0;
27773         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27774         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27775         return ret_ref;
27776 }
27777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27778         LDKWatchedOutput arg_conv;
27779         arg_conv.inner = untag_ptr(arg);
27780         arg_conv.is_owned = ptr_is_owned(arg);
27781         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27782         arg_conv.is_owned = false;
27783         int64_t ret_conv = WatchedOutput_clone_ptr(&arg_conv);
27784         return ret_conv;
27785 }
27786
27787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27788         LDKWatchedOutput orig_conv;
27789         orig_conv.inner = untag_ptr(orig);
27790         orig_conv.is_owned = ptr_is_owned(orig);
27791         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27792         orig_conv.is_owned = false;
27793         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
27794         int64_t ret_ref = 0;
27795         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27796         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27797         return ret_ref;
27798 }
27799
27800 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27801         LDKWatchedOutput a_conv;
27802         a_conv.inner = untag_ptr(a);
27803         a_conv.is_owned = ptr_is_owned(a);
27804         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27805         a_conv.is_owned = false;
27806         LDKWatchedOutput b_conv;
27807         b_conv.inner = untag_ptr(b);
27808         b_conv.is_owned = ptr_is_owned(b);
27809         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
27810         b_conv.is_owned = false;
27811         jboolean ret_conv = WatchedOutput_eq(&a_conv, &b_conv);
27812         return ret_conv;
27813 }
27814
27815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
27816         LDKWatchedOutput o_conv;
27817         o_conv.inner = untag_ptr(o);
27818         o_conv.is_owned = ptr_is_owned(o);
27819         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
27820         o_conv.is_owned = false;
27821         int64_t ret_conv = WatchedOutput_hash(&o_conv);
27822         return ret_conv;
27823 }
27824
27825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27826         if (!ptr_is_owned(this_ptr)) return;
27827         void* this_ptr_ptr = untag_ptr(this_ptr);
27828         CHECK_ACCESS(this_ptr_ptr);
27829         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
27830         FREE(untag_ptr(this_ptr));
27831         BroadcasterInterface_free(this_ptr_conv);
27832 }
27833
27834 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27835         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)untag_ptr(orig);
27836         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
27837         return ret_conv;
27838 }
27839
27840 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
27841         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
27842         return ret_conv;
27843 }
27844
27845 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
27846         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
27847         return ret_conv;
27848 }
27849
27850 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
27851         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
27852         return ret_conv;
27853 }
27854
27855 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27856         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)untag_ptr(a);
27857         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)untag_ptr(b);
27858         jboolean ret_conv = ConfirmationTarget_eq(a_conv, b_conv);
27859         return ret_conv;
27860 }
27861
27862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27863         if (!ptr_is_owned(this_ptr)) return;
27864         void* this_ptr_ptr = untag_ptr(this_ptr);
27865         CHECK_ACCESS(this_ptr_ptr);
27866         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
27867         FREE(untag_ptr(this_ptr));
27868         FeeEstimator_free(this_ptr_conv);
27869 }
27870
27871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27872         LDKMonitorUpdateId this_obj_conv;
27873         this_obj_conv.inner = untag_ptr(this_obj);
27874         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27876         MonitorUpdateId_free(this_obj_conv);
27877 }
27878
27879 static inline uint64_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
27880         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
27881         int64_t ret_ref = 0;
27882         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27883         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27884         return ret_ref;
27885 }
27886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27887         LDKMonitorUpdateId arg_conv;
27888         arg_conv.inner = untag_ptr(arg);
27889         arg_conv.is_owned = ptr_is_owned(arg);
27890         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27891         arg_conv.is_owned = false;
27892         int64_t ret_conv = MonitorUpdateId_clone_ptr(&arg_conv);
27893         return ret_conv;
27894 }
27895
27896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27897         LDKMonitorUpdateId orig_conv;
27898         orig_conv.inner = untag_ptr(orig);
27899         orig_conv.is_owned = ptr_is_owned(orig);
27900         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27901         orig_conv.is_owned = false;
27902         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
27903         int64_t ret_ref = 0;
27904         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27905         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27906         return ret_ref;
27907 }
27908
27909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1hash(JNIEnv *env, jclass clz, int64_t o) {
27910         LDKMonitorUpdateId o_conv;
27911         o_conv.inner = untag_ptr(o);
27912         o_conv.is_owned = ptr_is_owned(o);
27913         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
27914         o_conv.is_owned = false;
27915         int64_t ret_conv = MonitorUpdateId_hash(&o_conv);
27916         return ret_conv;
27917 }
27918
27919 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27920         LDKMonitorUpdateId a_conv;
27921         a_conv.inner = untag_ptr(a);
27922         a_conv.is_owned = ptr_is_owned(a);
27923         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27924         a_conv.is_owned = false;
27925         LDKMonitorUpdateId b_conv;
27926         b_conv.inner = untag_ptr(b);
27927         b_conv.is_owned = ptr_is_owned(b);
27928         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
27929         b_conv.is_owned = false;
27930         jboolean ret_conv = MonitorUpdateId_eq(&a_conv, &b_conv);
27931         return ret_conv;
27932 }
27933
27934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27935         if (!ptr_is_owned(this_ptr)) return;
27936         void* this_ptr_ptr = untag_ptr(this_ptr);
27937         CHECK_ACCESS(this_ptr_ptr);
27938         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
27939         FREE(untag_ptr(this_ptr));
27940         Persist_free(this_ptr_conv);
27941 }
27942
27943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27944         LDKLockedChannelMonitor this_obj_conv;
27945         this_obj_conv.inner = untag_ptr(this_obj);
27946         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27948         LockedChannelMonitor_free(this_obj_conv);
27949 }
27950
27951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27952         LDKChainMonitor this_obj_conv;
27953         this_obj_conv.inner = untag_ptr(this_obj);
27954         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27956         ChainMonitor_free(this_obj_conv);
27957 }
27958
27959 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) {
27960         void* chain_source_ptr = untag_ptr(chain_source);
27961         CHECK_ACCESS(chain_source_ptr);
27962         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
27963         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
27964         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
27965                 // Manually implement clone for Java trait instances
27966                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
27967                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27968                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
27969                 }
27970         }
27971         void* broadcaster_ptr = untag_ptr(broadcaster);
27972         CHECK_ACCESS(broadcaster_ptr);
27973         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
27974         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27975                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27976                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
27977         }
27978         void* logger_ptr = untag_ptr(logger);
27979         CHECK_ACCESS(logger_ptr);
27980         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27981         if (logger_conv.free == LDKLogger_JCalls_free) {
27982                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27983                 LDKLogger_JCalls_cloned(&logger_conv);
27984         }
27985         void* feeest_ptr = untag_ptr(feeest);
27986         CHECK_ACCESS(feeest_ptr);
27987         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
27988         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
27989                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27990                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
27991         }
27992         void* persister_ptr = untag_ptr(persister);
27993         CHECK_ACCESS(persister_ptr);
27994         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
27995         if (persister_conv.free == LDKPersist_JCalls_free) {
27996                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27997                 LDKPersist_JCalls_cloned(&persister_conv);
27998         }
27999         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
28000         int64_t ret_ref = 0;
28001         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28002         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28003         return ret_ref;
28004 }
28005
28006 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) {
28007         LDKChainMonitor this_arg_conv;
28008         this_arg_conv.inner = untag_ptr(this_arg);
28009         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28011         this_arg_conv.is_owned = false;
28012         LDKCVec_ChannelDetailsZ ignored_channels_constr;
28013         ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels);
28014         if (ignored_channels_constr.datalen > 0)
28015                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
28016         else
28017                 ignored_channels_constr.data = NULL;
28018         int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL);
28019         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
28020                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
28021                 LDKChannelDetails ignored_channels_conv_16_conv;
28022                 ignored_channels_conv_16_conv.inner = untag_ptr(ignored_channels_conv_16);
28023                 ignored_channels_conv_16_conv.is_owned = ptr_is_owned(ignored_channels_conv_16);
28024                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
28025                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
28026                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
28027         }
28028         (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0);
28029         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
28030         int64_tArray ret_arr = NULL;
28031         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28032         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28033         for (size_t j = 0; j < ret_var.datalen; j++) {
28034                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28035                 *ret_conv_9_copy = ret_var.data[j];
28036                 int64_t ret_conv_9_ref = tag_ptr(ret_conv_9_copy, true);
28037                 ret_arr_ptr[j] = ret_conv_9_ref;
28038         }
28039         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28040         FREE(ret_var.data);
28041         return ret_arr;
28042 }
28043
28044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1monitor(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo) {
28045         LDKChainMonitor this_arg_conv;
28046         this_arg_conv.inner = untag_ptr(this_arg);
28047         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28049         this_arg_conv.is_owned = false;
28050         LDKOutPoint funding_txo_conv;
28051         funding_txo_conv.inner = untag_ptr(funding_txo);
28052         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
28053         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
28054         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
28055         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
28056         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
28057         return tag_ptr(ret_conv, true);
28058 }
28059
28060 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1monitors(JNIEnv *env, jclass clz, int64_t this_arg) {
28061         LDKChainMonitor this_arg_conv;
28062         this_arg_conv.inner = untag_ptr(this_arg);
28063         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28065         this_arg_conv.is_owned = false;
28066         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
28067         int64_tArray ret_arr = NULL;
28068         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28069         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28070         for (size_t k = 0; k < ret_var.datalen; k++) {
28071                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
28072                 int64_t ret_conv_10_ref = 0;
28073                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
28074                 ret_conv_10_ref = tag_ptr(ret_conv_10_var.inner, ret_conv_10_var.is_owned);
28075                 ret_arr_ptr[k] = ret_conv_10_ref;
28076         }
28077         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28078         FREE(ret_var.data);
28079         return ret_arr;
28080 }
28081
28082 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) {
28083         LDKChainMonitor this_arg_conv;
28084         this_arg_conv.inner = untag_ptr(this_arg);
28085         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28087         this_arg_conv.is_owned = false;
28088         LDKOutPoint funding_txo_conv;
28089         funding_txo_conv.inner = untag_ptr(funding_txo);
28090         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
28091         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
28092         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
28093         LDKMonitorUpdateId completed_update_id_conv;
28094         completed_update_id_conv.inner = untag_ptr(completed_update_id);
28095         completed_update_id_conv.is_owned = ptr_is_owned(completed_update_id);
28096         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
28097         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
28098         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
28099         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
28100         return tag_ptr(ret_conv, true);
28101 }
28102
28103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
28104         LDKChainMonitor this_arg_conv;
28105         this_arg_conv.inner = untag_ptr(this_arg);
28106         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28108         this_arg_conv.is_owned = false;
28109         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
28110         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
28111         return tag_ptr(ret_ret, true);
28112 }
28113
28114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
28115         LDKChainMonitor this_arg_conv;
28116         this_arg_conv.inner = untag_ptr(this_arg);
28117         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28119         this_arg_conv.is_owned = false;
28120         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
28121         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
28122         return tag_ptr(ret_ret, true);
28123 }
28124
28125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
28126         LDKChainMonitor this_arg_conv;
28127         this_arg_conv.inner = untag_ptr(this_arg);
28128         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28130         this_arg_conv.is_owned = false;
28131         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
28132         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
28133         return tag_ptr(ret_ret, true);
28134 }
28135
28136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
28137         LDKChainMonitor this_arg_conv;
28138         this_arg_conv.inner = untag_ptr(this_arg);
28139         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28141         this_arg_conv.is_owned = false;
28142         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
28143         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
28144         return tag_ptr(ret_ret, true);
28145 }
28146
28147 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28148         LDKChannelMonitorUpdate this_obj_conv;
28149         this_obj_conv.inner = untag_ptr(this_obj);
28150         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28152         ChannelMonitorUpdate_free(this_obj_conv);
28153 }
28154
28155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28156         LDKChannelMonitorUpdate this_ptr_conv;
28157         this_ptr_conv.inner = untag_ptr(this_ptr);
28158         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28160         this_ptr_conv.is_owned = false;
28161         int64_t ret_conv = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
28162         return ret_conv;
28163 }
28164
28165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28166         LDKChannelMonitorUpdate this_ptr_conv;
28167         this_ptr_conv.inner = untag_ptr(this_ptr);
28168         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28170         this_ptr_conv.is_owned = false;
28171         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
28172 }
28173
28174 static inline uint64_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
28175         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
28176         int64_t ret_ref = 0;
28177         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28178         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28179         return ret_ref;
28180 }
28181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28182         LDKChannelMonitorUpdate arg_conv;
28183         arg_conv.inner = untag_ptr(arg);
28184         arg_conv.is_owned = ptr_is_owned(arg);
28185         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28186         arg_conv.is_owned = false;
28187         int64_t ret_conv = ChannelMonitorUpdate_clone_ptr(&arg_conv);
28188         return ret_conv;
28189 }
28190
28191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28192         LDKChannelMonitorUpdate orig_conv;
28193         orig_conv.inner = untag_ptr(orig);
28194         orig_conv.is_owned = ptr_is_owned(orig);
28195         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28196         orig_conv.is_owned = false;
28197         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_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 int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
28205         LDKChannelMonitorUpdate obj_conv;
28206         obj_conv.inner = untag_ptr(obj);
28207         obj_conv.is_owned = ptr_is_owned(obj);
28208         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28209         obj_conv.is_owned = false;
28210         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
28211         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28212         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28213         CVec_u8Z_free(ret_var);
28214         return ret_arr;
28215 }
28216
28217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28218         LDKu8slice ser_ref;
28219         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28220         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28221         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
28222         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
28223         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28224         return tag_ptr(ret_conv, true);
28225 }
28226
28227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28228         if (!ptr_is_owned(this_ptr)) return;
28229         void* this_ptr_ptr = untag_ptr(this_ptr);
28230         CHECK_ACCESS(this_ptr_ptr);
28231         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
28232         FREE(untag_ptr(this_ptr));
28233         MonitorEvent_free(this_ptr_conv);
28234 }
28235
28236 static inline uint64_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
28237         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
28238         *ret_copy = MonitorEvent_clone(arg);
28239         int64_t ret_ref = tag_ptr(ret_copy, true);
28240         return ret_ref;
28241 }
28242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28243         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)untag_ptr(arg);
28244         int64_t ret_conv = MonitorEvent_clone_ptr(arg_conv);
28245         return ret_conv;
28246 }
28247
28248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28249         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)untag_ptr(orig);
28250         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
28251         *ret_copy = MonitorEvent_clone(orig_conv);
28252         int64_t ret_ref = tag_ptr(ret_copy, true);
28253         return ret_ref;
28254 }
28255
28256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
28257         LDKHTLCUpdate a_conv;
28258         a_conv.inner = untag_ptr(a);
28259         a_conv.is_owned = ptr_is_owned(a);
28260         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28261         a_conv = HTLCUpdate_clone(&a_conv);
28262         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
28263         *ret_copy = MonitorEvent_htlcevent(a_conv);
28264         int64_t ret_ref = tag_ptr(ret_copy, true);
28265         return ret_ref;
28266 }
28267
28268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) {
28269         LDKOutPoint a_conv;
28270         a_conv.inner = untag_ptr(a);
28271         a_conv.is_owned = ptr_is_owned(a);
28272         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28273         a_conv = OutPoint_clone(&a_conv);
28274         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
28275         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
28276         int64_t ret_ref = tag_ptr(ret_copy, true);
28277         return ret_ref;
28278 }
28279
28280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1completed(JNIEnv *env, jclass clz, int64_t funding_txo, int64_t monitor_update_id) {
28281         LDKOutPoint funding_txo_conv;
28282         funding_txo_conv.inner = untag_ptr(funding_txo);
28283         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
28284         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
28285         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
28286         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
28287         *ret_copy = MonitorEvent_completed(funding_txo_conv, monitor_update_id);
28288         int64_t ret_ref = tag_ptr(ret_copy, true);
28289         return ret_ref;
28290 }
28291
28292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1failed(JNIEnv *env, jclass clz, int64_t a) {
28293         LDKOutPoint a_conv;
28294         a_conv.inner = untag_ptr(a);
28295         a_conv.is_owned = ptr_is_owned(a);
28296         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28297         a_conv = OutPoint_clone(&a_conv);
28298         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
28299         *ret_copy = MonitorEvent_update_failed(a_conv);
28300         int64_t ret_ref = tag_ptr(ret_copy, true);
28301         return ret_ref;
28302 }
28303
28304 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28305         LDKMonitorEvent* a_conv = (LDKMonitorEvent*)untag_ptr(a);
28306         LDKMonitorEvent* b_conv = (LDKMonitorEvent*)untag_ptr(b);
28307         jboolean ret_conv = MonitorEvent_eq(a_conv, b_conv);
28308         return ret_conv;
28309 }
28310
28311 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1write(JNIEnv *env, jclass clz, int64_t obj) {
28312         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)untag_ptr(obj);
28313         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
28314         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28315         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28316         CVec_u8Z_free(ret_var);
28317         return ret_arr;
28318 }
28319
28320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28321         LDKu8slice ser_ref;
28322         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28323         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28324         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
28325         *ret_conv = MonitorEvent_read(ser_ref);
28326         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28327         return tag_ptr(ret_conv, true);
28328 }
28329
28330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28331         LDKHTLCUpdate this_obj_conv;
28332         this_obj_conv.inner = untag_ptr(this_obj);
28333         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28335         HTLCUpdate_free(this_obj_conv);
28336 }
28337
28338 static inline uint64_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
28339         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
28340         int64_t ret_ref = 0;
28341         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28342         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28343         return ret_ref;
28344 }
28345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28346         LDKHTLCUpdate arg_conv;
28347         arg_conv.inner = untag_ptr(arg);
28348         arg_conv.is_owned = ptr_is_owned(arg);
28349         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28350         arg_conv.is_owned = false;
28351         int64_t ret_conv = HTLCUpdate_clone_ptr(&arg_conv);
28352         return ret_conv;
28353 }
28354
28355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28356         LDKHTLCUpdate orig_conv;
28357         orig_conv.inner = untag_ptr(orig);
28358         orig_conv.is_owned = ptr_is_owned(orig);
28359         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28360         orig_conv.is_owned = false;
28361         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
28362         int64_t ret_ref = 0;
28363         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28364         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28365         return ret_ref;
28366 }
28367
28368 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28369         LDKHTLCUpdate a_conv;
28370         a_conv.inner = untag_ptr(a);
28371         a_conv.is_owned = ptr_is_owned(a);
28372         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28373         a_conv.is_owned = false;
28374         LDKHTLCUpdate b_conv;
28375         b_conv.inner = untag_ptr(b);
28376         b_conv.is_owned = ptr_is_owned(b);
28377         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
28378         b_conv.is_owned = false;
28379         jboolean ret_conv = HTLCUpdate_eq(&a_conv, &b_conv);
28380         return ret_conv;
28381 }
28382
28383 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
28384         LDKHTLCUpdate obj_conv;
28385         obj_conv.inner = untag_ptr(obj);
28386         obj_conv.is_owned = ptr_is_owned(obj);
28387         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28388         obj_conv.is_owned = false;
28389         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
28390         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28391         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28392         CVec_u8Z_free(ret_var);
28393         return ret_arr;
28394 }
28395
28396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28397         LDKu8slice ser_ref;
28398         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28399         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28400         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
28401         *ret_conv = HTLCUpdate_read(ser_ref);
28402         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28403         return tag_ptr(ret_conv, true);
28404 }
28405
28406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28407         if (!ptr_is_owned(this_ptr)) return;
28408         void* this_ptr_ptr = untag_ptr(this_ptr);
28409         CHECK_ACCESS(this_ptr_ptr);
28410         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
28411         FREE(untag_ptr(this_ptr));
28412         Balance_free(this_ptr_conv);
28413 }
28414
28415 static inline uint64_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
28416         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28417         *ret_copy = Balance_clone(arg);
28418         int64_t ret_ref = tag_ptr(ret_copy, true);
28419         return ret_ref;
28420 }
28421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28422         LDKBalance* arg_conv = (LDKBalance*)untag_ptr(arg);
28423         int64_t ret_conv = Balance_clone_ptr(arg_conv);
28424         return ret_conv;
28425 }
28426
28427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28428         LDKBalance* orig_conv = (LDKBalance*)untag_ptr(orig);
28429         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28430         *ret_copy = Balance_clone(orig_conv);
28431         int64_t ret_ref = tag_ptr(ret_copy, true);
28432         return ret_ref;
28433 }
28434
28435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
28436         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28437         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
28438         int64_t ret_ref = tag_ptr(ret_copy, true);
28439         return ret_ref;
28440 }
28441
28442 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) {
28443         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28444         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
28445         int64_t ret_ref = tag_ptr(ret_copy, true);
28446         return ret_ref;
28447 }
28448
28449 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) {
28450         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28451         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
28452         int64_t ret_ref = tag_ptr(ret_copy, true);
28453         return ret_ref;
28454 }
28455
28456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1maybe_1timeout_1claimable_1htlc(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis, int32_t claimable_height) {
28457         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28458         *ret_copy = Balance_maybe_timeout_claimable_htlc(claimable_amount_satoshis, claimable_height);
28459         int64_t ret_ref = tag_ptr(ret_copy, true);
28460         return ret_ref;
28461 }
28462
28463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1maybe_1preimage_1claimable_1htlc(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis, int32_t expiry_height) {
28464         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28465         *ret_copy = Balance_maybe_preimage_claimable_htlc(claimable_amount_satoshis, expiry_height);
28466         int64_t ret_ref = tag_ptr(ret_copy, true);
28467         return ret_ref;
28468 }
28469
28470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1counterparty_1revoked_1output_1claimable(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
28471         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28472         *ret_copy = Balance_counterparty_revoked_output_claimable(claimable_amount_satoshis);
28473         int64_t ret_ref = tag_ptr(ret_copy, true);
28474         return ret_ref;
28475 }
28476
28477 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28478         LDKBalance* a_conv = (LDKBalance*)untag_ptr(a);
28479         LDKBalance* b_conv = (LDKBalance*)untag_ptr(b);
28480         jboolean ret_conv = Balance_eq(a_conv, b_conv);
28481         return ret_conv;
28482 }
28483
28484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28485         LDKChannelMonitor this_obj_conv;
28486         this_obj_conv.inner = untag_ptr(this_obj);
28487         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28489         ChannelMonitor_free(this_obj_conv);
28490 }
28491
28492 static inline uint64_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
28493         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
28494         int64_t ret_ref = 0;
28495         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28496         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28497         return ret_ref;
28498 }
28499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28500         LDKChannelMonitor arg_conv;
28501         arg_conv.inner = untag_ptr(arg);
28502         arg_conv.is_owned = ptr_is_owned(arg);
28503         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28504         arg_conv.is_owned = false;
28505         int64_t ret_conv = ChannelMonitor_clone_ptr(&arg_conv);
28506         return ret_conv;
28507 }
28508
28509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28510         LDKChannelMonitor orig_conv;
28511         orig_conv.inner = untag_ptr(orig);
28512         orig_conv.is_owned = ptr_is_owned(orig);
28513         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28514         orig_conv.is_owned = false;
28515         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
28516         int64_t ret_ref = 0;
28517         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28518         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28519         return ret_ref;
28520 }
28521
28522 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
28523         LDKChannelMonitor obj_conv;
28524         obj_conv.inner = untag_ptr(obj);
28525         obj_conv.is_owned = ptr_is_owned(obj);
28526         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28527         obj_conv.is_owned = false;
28528         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
28529         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28530         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28531         CVec_u8Z_free(ret_var);
28532         return ret_arr;
28533 }
28534
28535 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) {
28536         LDKChannelMonitor this_arg_conv;
28537         this_arg_conv.inner = untag_ptr(this_arg);
28538         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28540         this_arg_conv.is_owned = false;
28541         LDKChannelMonitorUpdate updates_conv;
28542         updates_conv.inner = untag_ptr(updates);
28543         updates_conv.is_owned = ptr_is_owned(updates);
28544         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
28545         updates_conv.is_owned = false;
28546         void* broadcaster_ptr = untag_ptr(broadcaster);
28547         if (ptr_is_owned(broadcaster)) { CHECK_ACCESS(broadcaster_ptr); }
28548         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
28549         void* fee_estimator_ptr = untag_ptr(fee_estimator);
28550         CHECK_ACCESS(fee_estimator_ptr);
28551         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
28552         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
28553                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28554                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
28555         }
28556         void* logger_ptr = untag_ptr(logger);
28557         if (ptr_is_owned(logger)) { CHECK_ACCESS(logger_ptr); }
28558         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
28559         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
28560         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
28561         return tag_ptr(ret_conv, true);
28562 }
28563
28564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
28565         LDKChannelMonitor this_arg_conv;
28566         this_arg_conv.inner = untag_ptr(this_arg);
28567         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28569         this_arg_conv.is_owned = false;
28570         int64_t ret_conv = ChannelMonitor_get_latest_update_id(&this_arg_conv);
28571         return ret_conv;
28572 }
28573
28574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
28575         LDKChannelMonitor this_arg_conv;
28576         this_arg_conv.inner = untag_ptr(this_arg);
28577         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28579         this_arg_conv.is_owned = false;
28580         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
28581         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
28582         return tag_ptr(ret_conv, true);
28583 }
28584
28585 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
28586         LDKChannelMonitor this_arg_conv;
28587         this_arg_conv.inner = untag_ptr(this_arg);
28588         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28590         this_arg_conv.is_owned = false;
28591         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
28592         int64_tArray ret_arr = NULL;
28593         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28594         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28595         for (size_t o = 0; o < ret_var.datalen; o++) {
28596                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
28597                 *ret_conv_40_conv = ret_var.data[o];
28598                 ret_arr_ptr[o] = tag_ptr(ret_conv_40_conv, true);
28599         }
28600         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28601         FREE(ret_var.data);
28602         return ret_arr;
28603 }
28604
28605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
28606         LDKChannelMonitor this_arg_conv;
28607         this_arg_conv.inner = untag_ptr(this_arg);
28608         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28610         this_arg_conv.is_owned = false;
28611         void* filter_ptr = untag_ptr(filter);
28612         if (ptr_is_owned(filter)) { CHECK_ACCESS(filter_ptr); }
28613         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
28614         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
28615 }
28616
28617 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
28618         LDKChannelMonitor this_arg_conv;
28619         this_arg_conv.inner = untag_ptr(this_arg);
28620         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28622         this_arg_conv.is_owned = false;
28623         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
28624         int64_tArray ret_arr = NULL;
28625         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28626         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28627         for (size_t o = 0; o < ret_var.datalen; o++) {
28628                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
28629                 *ret_conv_14_copy = ret_var.data[o];
28630                 int64_t ret_conv_14_ref = tag_ptr(ret_conv_14_copy, true);
28631                 ret_arr_ptr[o] = ret_conv_14_ref;
28632         }
28633         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28634         FREE(ret_var.data);
28635         return ret_arr;
28636 }
28637
28638 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
28639         LDKChannelMonitor this_arg_conv;
28640         this_arg_conv.inner = untag_ptr(this_arg);
28641         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28643         this_arg_conv.is_owned = false;
28644         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
28645         int64_tArray ret_arr = NULL;
28646         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28647         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28648         for (size_t h = 0; h < ret_var.datalen; h++) {
28649                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
28650                 *ret_conv_7_copy = ret_var.data[h];
28651                 int64_t ret_conv_7_ref = tag_ptr(ret_conv_7_copy, true);
28652                 ret_arr_ptr[h] = ret_conv_7_ref;
28653         }
28654         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28655         FREE(ret_var.data);
28656         return ret_arr;
28657 }
28658
28659 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1counterparty_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
28660         LDKChannelMonitor this_arg_conv;
28661         this_arg_conv.inner = untag_ptr(this_arg);
28662         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28664         this_arg_conv.is_owned = false;
28665         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28666         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelMonitor_get_counterparty_node_id(&this_arg_conv).compressed_form);
28667         return ret_arr;
28668 }
28669
28670 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) {
28671         LDKChannelMonitor this_arg_conv;
28672         this_arg_conv.inner = untag_ptr(this_arg);
28673         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28675         this_arg_conv.is_owned = false;
28676         void* logger_ptr = untag_ptr(logger);
28677         if (ptr_is_owned(logger)) { CHECK_ACCESS(logger_ptr); }
28678         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
28679         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
28680         jobjectArray ret_arr = NULL;
28681         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
28682         ;
28683         for (size_t i = 0; i < ret_var.datalen; i++) {
28684                 LDKTransaction ret_conv_8_var = ret_var.data[i];
28685                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
28686                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
28687                 Transaction_free(ret_conv_8_var);
28688                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
28689         }
28690         
28691         FREE(ret_var.data);
28692         return ret_arr;
28693 }
28694
28695 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) {
28696         LDKChannelMonitor this_arg_conv;
28697         this_arg_conv.inner = untag_ptr(this_arg);
28698         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28700         this_arg_conv.is_owned = false;
28701         unsigned char header_arr[80];
28702         CHECK((*env)->GetArrayLength(env, header) == 80);
28703         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
28704         unsigned char (*header_ref)[80] = &header_arr;
28705         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
28706         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
28707         if (txdata_constr.datalen > 0)
28708                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
28709         else
28710                 txdata_constr.data = NULL;
28711         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
28712         for (size_t c = 0; c < txdata_constr.datalen; c++) {
28713                 int64_t txdata_conv_28 = txdata_vals[c];
28714                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
28715                 CHECK_ACCESS(txdata_conv_28_ptr);
28716                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
28717                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
28718                 txdata_constr.data[c] = txdata_conv_28_conv;
28719         }
28720         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
28721         void* broadcaster_ptr = untag_ptr(broadcaster);
28722         CHECK_ACCESS(broadcaster_ptr);
28723         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
28724         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
28725                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28726                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
28727         }
28728         void* fee_estimator_ptr = untag_ptr(fee_estimator);
28729         CHECK_ACCESS(fee_estimator_ptr);
28730         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
28731         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
28732                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28733                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
28734         }
28735         void* logger_ptr = untag_ptr(logger);
28736         CHECK_ACCESS(logger_ptr);
28737         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28738         if (logger_conv.free == LDKLogger_JCalls_free) {
28739                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28740                 LDKLogger_JCalls_cloned(&logger_conv);
28741         }
28742         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);
28743         int64_tArray ret_arr = NULL;
28744         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28745         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28746         for (size_t n = 0; n < ret_var.datalen; n++) {
28747                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
28748                 *ret_conv_39_conv = ret_var.data[n];
28749                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
28750         }
28751         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28752         FREE(ret_var.data);
28753         return ret_arr;
28754 }
28755
28756 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) {
28757         LDKChannelMonitor this_arg_conv;
28758         this_arg_conv.inner = untag_ptr(this_arg);
28759         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28761         this_arg_conv.is_owned = false;
28762         unsigned char header_arr[80];
28763         CHECK((*env)->GetArrayLength(env, header) == 80);
28764         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
28765         unsigned char (*header_ref)[80] = &header_arr;
28766         void* broadcaster_ptr = untag_ptr(broadcaster);
28767         CHECK_ACCESS(broadcaster_ptr);
28768         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
28769         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
28770                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28771                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
28772         }
28773         void* fee_estimator_ptr = untag_ptr(fee_estimator);
28774         CHECK_ACCESS(fee_estimator_ptr);
28775         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
28776         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
28777                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28778                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
28779         }
28780         void* logger_ptr = untag_ptr(logger);
28781         CHECK_ACCESS(logger_ptr);
28782         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28783         if (logger_conv.free == LDKLogger_JCalls_free) {
28784                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28785                 LDKLogger_JCalls_cloned(&logger_conv);
28786         }
28787         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
28788 }
28789
28790 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) {
28791         LDKChannelMonitor this_arg_conv;
28792         this_arg_conv.inner = untag_ptr(this_arg);
28793         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28795         this_arg_conv.is_owned = false;
28796         unsigned char header_arr[80];
28797         CHECK((*env)->GetArrayLength(env, header) == 80);
28798         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
28799         unsigned char (*header_ref)[80] = &header_arr;
28800         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
28801         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
28802         if (txdata_constr.datalen > 0)
28803                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
28804         else
28805                 txdata_constr.data = NULL;
28806         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
28807         for (size_t c = 0; c < txdata_constr.datalen; c++) {
28808                 int64_t txdata_conv_28 = txdata_vals[c];
28809                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
28810                 CHECK_ACCESS(txdata_conv_28_ptr);
28811                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
28812                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
28813                 txdata_constr.data[c] = txdata_conv_28_conv;
28814         }
28815         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
28816         void* broadcaster_ptr = untag_ptr(broadcaster);
28817         CHECK_ACCESS(broadcaster_ptr);
28818         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
28819         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
28820                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28821                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
28822         }
28823         void* fee_estimator_ptr = untag_ptr(fee_estimator);
28824         CHECK_ACCESS(fee_estimator_ptr);
28825         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
28826         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
28827                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28828                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
28829         }
28830         void* logger_ptr = untag_ptr(logger);
28831         CHECK_ACCESS(logger_ptr);
28832         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28833         if (logger_conv.free == LDKLogger_JCalls_free) {
28834                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28835                 LDKLogger_JCalls_cloned(&logger_conv);
28836         }
28837         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);
28838         int64_tArray ret_arr = NULL;
28839         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28840         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28841         for (size_t n = 0; n < ret_var.datalen; n++) {
28842                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
28843                 *ret_conv_39_conv = ret_var.data[n];
28844                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
28845         }
28846         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28847         FREE(ret_var.data);
28848         return ret_arr;
28849 }
28850
28851 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) {
28852         LDKChannelMonitor this_arg_conv;
28853         this_arg_conv.inner = untag_ptr(this_arg);
28854         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28856         this_arg_conv.is_owned = false;
28857         unsigned char txid_arr[32];
28858         CHECK((*env)->GetArrayLength(env, txid) == 32);
28859         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
28860         unsigned char (*txid_ref)[32] = &txid_arr;
28861         void* broadcaster_ptr = untag_ptr(broadcaster);
28862         CHECK_ACCESS(broadcaster_ptr);
28863         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
28864         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
28865                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28866                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
28867         }
28868         void* fee_estimator_ptr = untag_ptr(fee_estimator);
28869         CHECK_ACCESS(fee_estimator_ptr);
28870         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
28871         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
28872                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28873                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
28874         }
28875         void* logger_ptr = untag_ptr(logger);
28876         CHECK_ACCESS(logger_ptr);
28877         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28878         if (logger_conv.free == LDKLogger_JCalls_free) {
28879                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28880                 LDKLogger_JCalls_cloned(&logger_conv);
28881         }
28882         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
28883 }
28884
28885 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) {
28886         LDKChannelMonitor this_arg_conv;
28887         this_arg_conv.inner = untag_ptr(this_arg);
28888         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28890         this_arg_conv.is_owned = false;
28891         unsigned char header_arr[80];
28892         CHECK((*env)->GetArrayLength(env, header) == 80);
28893         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
28894         unsigned char (*header_ref)[80] = &header_arr;
28895         void* broadcaster_ptr = untag_ptr(broadcaster);
28896         CHECK_ACCESS(broadcaster_ptr);
28897         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
28898         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
28899                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28900                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
28901         }
28902         void* fee_estimator_ptr = untag_ptr(fee_estimator);
28903         CHECK_ACCESS(fee_estimator_ptr);
28904         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
28905         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
28906                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28907                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
28908         }
28909         void* logger_ptr = untag_ptr(logger);
28910         CHECK_ACCESS(logger_ptr);
28911         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28912         if (logger_conv.free == LDKLogger_JCalls_free) {
28913                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28914                 LDKLogger_JCalls_cloned(&logger_conv);
28915         }
28916         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
28917         int64_tArray ret_arr = NULL;
28918         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28919         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28920         for (size_t n = 0; n < ret_var.datalen; n++) {
28921                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
28922                 *ret_conv_39_conv = ret_var.data[n];
28923                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
28924         }
28925         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28926         FREE(ret_var.data);
28927         return ret_arr;
28928 }
28929
28930 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
28931         LDKChannelMonitor this_arg_conv;
28932         this_arg_conv.inner = untag_ptr(this_arg);
28933         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28935         this_arg_conv.is_owned = false;
28936         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
28937         jobjectArray ret_arr = NULL;
28938         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
28939         ;
28940         for (size_t i = 0; i < ret_var.datalen; i++) {
28941                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
28942                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
28943                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
28944         }
28945         
28946         FREE(ret_var.data);
28947         return ret_arr;
28948 }
28949
28950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
28951         LDKChannelMonitor this_arg_conv;
28952         this_arg_conv.inner = untag_ptr(this_arg);
28953         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28955         this_arg_conv.is_owned = false;
28956         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
28957         int64_t ret_ref = 0;
28958         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28959         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28960         return ret_ref;
28961 }
28962
28963 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) {
28964         LDKChannelMonitor this_arg_conv;
28965         this_arg_conv.inner = untag_ptr(this_arg);
28966         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28968         this_arg_conv.is_owned = false;
28969         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
28970         int64_tArray ret_arr = NULL;
28971         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28972         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28973         for (size_t j = 0; j < ret_var.datalen; j++) {
28974                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28975                 *ret_conv_9_copy = ret_var.data[j];
28976                 int64_t ret_conv_9_ref = tag_ptr(ret_conv_9_copy, true);
28977                 ret_arr_ptr[j] = ret_conv_9_ref;
28978         }
28979         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28980         FREE(ret_var.data);
28981         return ret_arr;
28982 }
28983
28984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
28985         LDKu8slice ser_ref;
28986         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28987         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28988         void* arg_ptr = untag_ptr(arg);
28989         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
28990         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
28991         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
28992         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
28993         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28994         return tag_ptr(ret_conv, true);
28995 }
28996
28997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28998         LDKOutPoint this_obj_conv;
28999         this_obj_conv.inner = untag_ptr(this_obj);
29000         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29002         OutPoint_free(this_obj_conv);
29003 }
29004
29005 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
29006         LDKOutPoint this_ptr_conv;
29007         this_ptr_conv.inner = untag_ptr(this_ptr);
29008         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29010         this_ptr_conv.is_owned = false;
29011         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29012         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
29013         return ret_arr;
29014 }
29015
29016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29017         LDKOutPoint this_ptr_conv;
29018         this_ptr_conv.inner = untag_ptr(this_ptr);
29019         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29021         this_ptr_conv.is_owned = false;
29022         LDKThirtyTwoBytes val_ref;
29023         CHECK((*env)->GetArrayLength(env, val) == 32);
29024         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29025         OutPoint_set_txid(&this_ptr_conv, val_ref);
29026 }
29027
29028 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
29029         LDKOutPoint this_ptr_conv;
29030         this_ptr_conv.inner = untag_ptr(this_ptr);
29031         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29033         this_ptr_conv.is_owned = false;
29034         int16_t ret_conv = OutPoint_get_index(&this_ptr_conv);
29035         return ret_conv;
29036 }
29037
29038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
29039         LDKOutPoint this_ptr_conv;
29040         this_ptr_conv.inner = untag_ptr(this_ptr);
29041         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29043         this_ptr_conv.is_owned = false;
29044         OutPoint_set_index(&this_ptr_conv, val);
29045 }
29046
29047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
29048         LDKThirtyTwoBytes txid_arg_ref;
29049         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
29050         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
29051         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
29052         int64_t ret_ref = 0;
29053         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29054         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29055         return ret_ref;
29056 }
29057
29058 static inline uint64_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
29059         LDKOutPoint ret_var = OutPoint_clone(arg);
29060         int64_t ret_ref = 0;
29061         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29062         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29063         return ret_ref;
29064 }
29065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29066         LDKOutPoint arg_conv;
29067         arg_conv.inner = untag_ptr(arg);
29068         arg_conv.is_owned = ptr_is_owned(arg);
29069         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29070         arg_conv.is_owned = false;
29071         int64_t ret_conv = OutPoint_clone_ptr(&arg_conv);
29072         return ret_conv;
29073 }
29074
29075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29076         LDKOutPoint orig_conv;
29077         orig_conv.inner = untag_ptr(orig);
29078         orig_conv.is_owned = ptr_is_owned(orig);
29079         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29080         orig_conv.is_owned = false;
29081         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
29082         int64_t ret_ref = 0;
29083         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29084         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29085         return ret_ref;
29086 }
29087
29088 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29089         LDKOutPoint a_conv;
29090         a_conv.inner = untag_ptr(a);
29091         a_conv.is_owned = ptr_is_owned(a);
29092         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29093         a_conv.is_owned = false;
29094         LDKOutPoint b_conv;
29095         b_conv.inner = untag_ptr(b);
29096         b_conv.is_owned = ptr_is_owned(b);
29097         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
29098         b_conv.is_owned = false;
29099         jboolean ret_conv = OutPoint_eq(&a_conv, &b_conv);
29100         return ret_conv;
29101 }
29102
29103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
29104         LDKOutPoint o_conv;
29105         o_conv.inner = untag_ptr(o);
29106         o_conv.is_owned = ptr_is_owned(o);
29107         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
29108         o_conv.is_owned = false;
29109         int64_t ret_conv = OutPoint_hash(&o_conv);
29110         return ret_conv;
29111 }
29112
29113 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
29114         LDKOutPoint this_arg_conv;
29115         this_arg_conv.inner = untag_ptr(this_arg);
29116         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29118         this_arg_conv.is_owned = false;
29119         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29120         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
29121         return ret_arr;
29122 }
29123
29124 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
29125         LDKOutPoint obj_conv;
29126         obj_conv.inner = untag_ptr(obj);
29127         obj_conv.is_owned = ptr_is_owned(obj);
29128         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29129         obj_conv.is_owned = false;
29130         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
29131         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29132         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29133         CVec_u8Z_free(ret_var);
29134         return ret_arr;
29135 }
29136
29137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29138         LDKu8slice ser_ref;
29139         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29140         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29141         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
29142         *ret_conv = OutPoint_read(ser_ref);
29143         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29144         return tag_ptr(ret_conv, true);
29145 }
29146
29147 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29148         LDKDelayedPaymentOutputDescriptor this_obj_conv;
29149         this_obj_conv.inner = untag_ptr(this_obj);
29150         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29152         DelayedPaymentOutputDescriptor_free(this_obj_conv);
29153 }
29154
29155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
29156         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
29157         this_ptr_conv.inner = untag_ptr(this_ptr);
29158         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29160         this_ptr_conv.is_owned = false;
29161         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
29162         int64_t ret_ref = 0;
29163         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29164         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29165         return ret_ref;
29166 }
29167
29168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29169         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
29170         this_ptr_conv.inner = untag_ptr(this_ptr);
29171         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29173         this_ptr_conv.is_owned = false;
29174         LDKOutPoint val_conv;
29175         val_conv.inner = untag_ptr(val);
29176         val_conv.is_owned = ptr_is_owned(val);
29177         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29178         val_conv = OutPoint_clone(&val_conv);
29179         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
29180 }
29181
29182 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
29183         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
29184         this_ptr_conv.inner = untag_ptr(this_ptr);
29185         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29187         this_ptr_conv.is_owned = false;
29188         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29189         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
29190         return ret_arr;
29191 }
29192
29193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29194         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
29195         this_ptr_conv.inner = untag_ptr(this_ptr);
29196         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29198         this_ptr_conv.is_owned = false;
29199         LDKPublicKey val_ref;
29200         CHECK((*env)->GetArrayLength(env, val) == 33);
29201         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
29202         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
29203 }
29204
29205 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
29206         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
29207         this_ptr_conv.inner = untag_ptr(this_ptr);
29208         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29210         this_ptr_conv.is_owned = false;
29211         int16_t ret_conv = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
29212         return ret_conv;
29213 }
29214
29215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
29216         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
29217         this_ptr_conv.inner = untag_ptr(this_ptr);
29218         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29220         this_ptr_conv.is_owned = false;
29221         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
29222 }
29223
29224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1output(JNIEnv *env, jclass clz, int64_t this_ptr) {
29225         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
29226         this_ptr_conv.inner = untag_ptr(this_ptr);
29227         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29229         this_ptr_conv.is_owned = false;
29230         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
29231         *ret_ref = DelayedPaymentOutputDescriptor_get_output(&this_ptr_conv);
29232         return tag_ptr(ret_ref, true);
29233 }
29234
29235 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29236         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
29237         this_ptr_conv.inner = untag_ptr(this_ptr);
29238         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29240         this_ptr_conv.is_owned = false;
29241         void* val_ptr = untag_ptr(val);
29242         CHECK_ACCESS(val_ptr);
29243         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
29244         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
29245         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
29246 }
29247
29248 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
29249         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
29250         this_ptr_conv.inner = untag_ptr(this_ptr);
29251         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29253         this_ptr_conv.is_owned = false;
29254         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29255         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
29256         return ret_arr;
29257 }
29258
29259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29260         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
29261         this_ptr_conv.inner = untag_ptr(this_ptr);
29262         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29264         this_ptr_conv.is_owned = false;
29265         LDKPublicKey val_ref;
29266         CHECK((*env)->GetArrayLength(env, val) == 33);
29267         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
29268         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
29269 }
29270
29271 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29272         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
29273         this_ptr_conv.inner = untag_ptr(this_ptr);
29274         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29276         this_ptr_conv.is_owned = false;
29277         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29278         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
29279         return ret_arr;
29280 }
29281
29282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29283         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
29284         this_ptr_conv.inner = untag_ptr(this_ptr);
29285         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29287         this_ptr_conv.is_owned = false;
29288         LDKThirtyTwoBytes val_ref;
29289         CHECK((*env)->GetArrayLength(env, val) == 32);
29290         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29291         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
29292 }
29293
29294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
29295         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
29296         this_ptr_conv.inner = untag_ptr(this_ptr);
29297         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29299         this_ptr_conv.is_owned = false;
29300         int64_t ret_conv = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
29301         return ret_conv;
29302 }
29303
29304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29305         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
29306         this_ptr_conv.inner = untag_ptr(this_ptr);
29307         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29309         this_ptr_conv.is_owned = false;
29310         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
29311 }
29312
29313 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) {
29314         LDKOutPoint outpoint_arg_conv;
29315         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
29316         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
29317         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
29318         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
29319         LDKPublicKey per_commitment_point_arg_ref;
29320         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
29321         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
29322         void* output_arg_ptr = untag_ptr(output_arg);
29323         CHECK_ACCESS(output_arg_ptr);
29324         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
29325         output_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(output_arg));
29326         LDKPublicKey revocation_pubkey_arg_ref;
29327         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
29328         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
29329         LDKThirtyTwoBytes channel_keys_id_arg_ref;
29330         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
29331         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
29332         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);
29333         int64_t ret_ref = 0;
29334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29335         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29336         return ret_ref;
29337 }
29338
29339 static inline uint64_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
29340         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
29341         int64_t ret_ref = 0;
29342         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29343         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29344         return ret_ref;
29345 }
29346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29347         LDKDelayedPaymentOutputDescriptor arg_conv;
29348         arg_conv.inner = untag_ptr(arg);
29349         arg_conv.is_owned = ptr_is_owned(arg);
29350         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29351         arg_conv.is_owned = false;
29352         int64_t ret_conv = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
29353         return ret_conv;
29354 }
29355
29356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29357         LDKDelayedPaymentOutputDescriptor orig_conv;
29358         orig_conv.inner = untag_ptr(orig);
29359         orig_conv.is_owned = ptr_is_owned(orig);
29360         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29361         orig_conv.is_owned = false;
29362         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
29363         int64_t ret_ref = 0;
29364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29365         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29366         return ret_ref;
29367 }
29368
29369 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29370         LDKDelayedPaymentOutputDescriptor a_conv;
29371         a_conv.inner = untag_ptr(a);
29372         a_conv.is_owned = ptr_is_owned(a);
29373         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29374         a_conv.is_owned = false;
29375         LDKDelayedPaymentOutputDescriptor b_conv;
29376         b_conv.inner = untag_ptr(b);
29377         b_conv.is_owned = ptr_is_owned(b);
29378         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
29379         b_conv.is_owned = false;
29380         jboolean ret_conv = DelayedPaymentOutputDescriptor_eq(&a_conv, &b_conv);
29381         return ret_conv;
29382 }
29383
29384 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
29385         LDKDelayedPaymentOutputDescriptor obj_conv;
29386         obj_conv.inner = untag_ptr(obj);
29387         obj_conv.is_owned = ptr_is_owned(obj);
29388         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29389         obj_conv.is_owned = false;
29390         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
29391         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29392         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29393         CVec_u8Z_free(ret_var);
29394         return ret_arr;
29395 }
29396
29397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29398         LDKu8slice ser_ref;
29399         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29400         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29401         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
29402         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
29403         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29404         return tag_ptr(ret_conv, true);
29405 }
29406
29407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29408         LDKStaticPaymentOutputDescriptor this_obj_conv;
29409         this_obj_conv.inner = untag_ptr(this_obj);
29410         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29412         StaticPaymentOutputDescriptor_free(this_obj_conv);
29413 }
29414
29415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
29416         LDKStaticPaymentOutputDescriptor this_ptr_conv;
29417         this_ptr_conv.inner = untag_ptr(this_ptr);
29418         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29420         this_ptr_conv.is_owned = false;
29421         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
29422         int64_t ret_ref = 0;
29423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29424         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29425         return ret_ref;
29426 }
29427
29428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29429         LDKStaticPaymentOutputDescriptor this_ptr_conv;
29430         this_ptr_conv.inner = untag_ptr(this_ptr);
29431         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29433         this_ptr_conv.is_owned = false;
29434         LDKOutPoint val_conv;
29435         val_conv.inner = untag_ptr(val);
29436         val_conv.is_owned = ptr_is_owned(val);
29437         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29438         val_conv = OutPoint_clone(&val_conv);
29439         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
29440 }
29441
29442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1output(JNIEnv *env, jclass clz, int64_t this_ptr) {
29443         LDKStaticPaymentOutputDescriptor this_ptr_conv;
29444         this_ptr_conv.inner = untag_ptr(this_ptr);
29445         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29447         this_ptr_conv.is_owned = false;
29448         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
29449         *ret_ref = StaticPaymentOutputDescriptor_get_output(&this_ptr_conv);
29450         return tag_ptr(ret_ref, true);
29451 }
29452
29453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29454         LDKStaticPaymentOutputDescriptor this_ptr_conv;
29455         this_ptr_conv.inner = untag_ptr(this_ptr);
29456         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29458         this_ptr_conv.is_owned = false;
29459         void* val_ptr = untag_ptr(val);
29460         CHECK_ACCESS(val_ptr);
29461         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
29462         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
29463         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
29464 }
29465
29466 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29467         LDKStaticPaymentOutputDescriptor this_ptr_conv;
29468         this_ptr_conv.inner = untag_ptr(this_ptr);
29469         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29471         this_ptr_conv.is_owned = false;
29472         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29473         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
29474         return ret_arr;
29475 }
29476
29477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29478         LDKStaticPaymentOutputDescriptor this_ptr_conv;
29479         this_ptr_conv.inner = untag_ptr(this_ptr);
29480         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29482         this_ptr_conv.is_owned = false;
29483         LDKThirtyTwoBytes val_ref;
29484         CHECK((*env)->GetArrayLength(env, val) == 32);
29485         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29486         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
29487 }
29488
29489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
29490         LDKStaticPaymentOutputDescriptor this_ptr_conv;
29491         this_ptr_conv.inner = untag_ptr(this_ptr);
29492         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29494         this_ptr_conv.is_owned = false;
29495         int64_t ret_conv = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
29496         return ret_conv;
29497 }
29498
29499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29500         LDKStaticPaymentOutputDescriptor this_ptr_conv;
29501         this_ptr_conv.inner = untag_ptr(this_ptr);
29502         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29504         this_ptr_conv.is_owned = false;
29505         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
29506 }
29507
29508 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) {
29509         LDKOutPoint outpoint_arg_conv;
29510         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
29511         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
29512         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
29513         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
29514         void* output_arg_ptr = untag_ptr(output_arg);
29515         CHECK_ACCESS(output_arg_ptr);
29516         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
29517         output_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(output_arg));
29518         LDKThirtyTwoBytes channel_keys_id_arg_ref;
29519         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
29520         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
29521         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
29522         int64_t ret_ref = 0;
29523         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29524         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29525         return ret_ref;
29526 }
29527
29528 static inline uint64_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
29529         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
29530         int64_t ret_ref = 0;
29531         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29532         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29533         return ret_ref;
29534 }
29535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29536         LDKStaticPaymentOutputDescriptor arg_conv;
29537         arg_conv.inner = untag_ptr(arg);
29538         arg_conv.is_owned = ptr_is_owned(arg);
29539         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29540         arg_conv.is_owned = false;
29541         int64_t ret_conv = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
29542         return ret_conv;
29543 }
29544
29545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29546         LDKStaticPaymentOutputDescriptor orig_conv;
29547         orig_conv.inner = untag_ptr(orig);
29548         orig_conv.is_owned = ptr_is_owned(orig);
29549         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29550         orig_conv.is_owned = false;
29551         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
29552         int64_t ret_ref = 0;
29553         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29554         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29555         return ret_ref;
29556 }
29557
29558 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29559         LDKStaticPaymentOutputDescriptor a_conv;
29560         a_conv.inner = untag_ptr(a);
29561         a_conv.is_owned = ptr_is_owned(a);
29562         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29563         a_conv.is_owned = false;
29564         LDKStaticPaymentOutputDescriptor b_conv;
29565         b_conv.inner = untag_ptr(b);
29566         b_conv.is_owned = ptr_is_owned(b);
29567         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
29568         b_conv.is_owned = false;
29569         jboolean ret_conv = StaticPaymentOutputDescriptor_eq(&a_conv, &b_conv);
29570         return ret_conv;
29571 }
29572
29573 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
29574         LDKStaticPaymentOutputDescriptor obj_conv;
29575         obj_conv.inner = untag_ptr(obj);
29576         obj_conv.is_owned = ptr_is_owned(obj);
29577         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29578         obj_conv.is_owned = false;
29579         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
29580         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29581         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29582         CVec_u8Z_free(ret_var);
29583         return ret_arr;
29584 }
29585
29586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29587         LDKu8slice ser_ref;
29588         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29589         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29590         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
29591         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
29592         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29593         return tag_ptr(ret_conv, true);
29594 }
29595
29596 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29597         if (!ptr_is_owned(this_ptr)) return;
29598         void* this_ptr_ptr = untag_ptr(this_ptr);
29599         CHECK_ACCESS(this_ptr_ptr);
29600         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
29601         FREE(untag_ptr(this_ptr));
29602         SpendableOutputDescriptor_free(this_ptr_conv);
29603 }
29604
29605 static inline uint64_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
29606         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
29607         *ret_copy = SpendableOutputDescriptor_clone(arg);
29608         int64_t ret_ref = tag_ptr(ret_copy, true);
29609         return ret_ref;
29610 }
29611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29612         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)untag_ptr(arg);
29613         int64_t ret_conv = SpendableOutputDescriptor_clone_ptr(arg_conv);
29614         return ret_conv;
29615 }
29616
29617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29618         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)untag_ptr(orig);
29619         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
29620         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
29621         int64_t ret_ref = tag_ptr(ret_copy, true);
29622         return ret_ref;
29623 }
29624
29625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
29626         LDKOutPoint outpoint_conv;
29627         outpoint_conv.inner = untag_ptr(outpoint);
29628         outpoint_conv.is_owned = ptr_is_owned(outpoint);
29629         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
29630         outpoint_conv = OutPoint_clone(&outpoint_conv);
29631         void* output_ptr = untag_ptr(output);
29632         CHECK_ACCESS(output_ptr);
29633         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
29634         output_conv = TxOut_clone((LDKTxOut*)untag_ptr(output));
29635         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
29636         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
29637         int64_t ret_ref = tag_ptr(ret_copy, true);
29638         return ret_ref;
29639 }
29640
29641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
29642         LDKDelayedPaymentOutputDescriptor a_conv;
29643         a_conv.inner = untag_ptr(a);
29644         a_conv.is_owned = ptr_is_owned(a);
29645         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29646         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
29647         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
29648         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
29649         int64_t ret_ref = tag_ptr(ret_copy, true);
29650         return ret_ref;
29651 }
29652
29653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
29654         LDKStaticPaymentOutputDescriptor a_conv;
29655         a_conv.inner = untag_ptr(a);
29656         a_conv.is_owned = ptr_is_owned(a);
29657         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29658         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
29659         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
29660         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
29661         int64_t ret_ref = tag_ptr(ret_copy, true);
29662         return ret_ref;
29663 }
29664
29665 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29666         LDKSpendableOutputDescriptor* a_conv = (LDKSpendableOutputDescriptor*)untag_ptr(a);
29667         LDKSpendableOutputDescriptor* b_conv = (LDKSpendableOutputDescriptor*)untag_ptr(b);
29668         jboolean ret_conv = SpendableOutputDescriptor_eq(a_conv, b_conv);
29669         return ret_conv;
29670 }
29671
29672 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
29673         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)untag_ptr(obj);
29674         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
29675         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29676         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29677         CVec_u8Z_free(ret_var);
29678         return ret_arr;
29679 }
29680
29681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29682         LDKu8slice ser_ref;
29683         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29684         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29685         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
29686         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
29687         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29688         return tag_ptr(ret_conv, true);
29689 }
29690
29691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29692         if (!ptr_is_owned(this_ptr)) return;
29693         void* this_ptr_ptr = untag_ptr(this_ptr);
29694         CHECK_ACCESS(this_ptr_ptr);
29695         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
29696         FREE(untag_ptr(this_ptr));
29697         BaseSign_free(this_ptr_conv);
29698 }
29699
29700 static inline uint64_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
29701         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
29702         *ret_ret = Sign_clone(arg);
29703         return tag_ptr(ret_ret, true);
29704 }
29705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29706         void* arg_ptr = untag_ptr(arg);
29707         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
29708         LDKSign* arg_conv = (LDKSign*)arg_ptr;
29709         int64_t ret_conv = Sign_clone_ptr(arg_conv);
29710         return ret_conv;
29711 }
29712
29713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29714         void* orig_ptr = untag_ptr(orig);
29715         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
29716         LDKSign* orig_conv = (LDKSign*)orig_ptr;
29717         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
29718         *ret_ret = Sign_clone(orig_conv);
29719         return tag_ptr(ret_ret, true);
29720 }
29721
29722 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29723         if (!ptr_is_owned(this_ptr)) return;
29724         void* this_ptr_ptr = untag_ptr(this_ptr);
29725         CHECK_ACCESS(this_ptr_ptr);
29726         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
29727         FREE(untag_ptr(this_ptr));
29728         Sign_free(this_ptr_conv);
29729 }
29730
29731 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29732         LDKRecipient* orig_conv = (LDKRecipient*)untag_ptr(orig);
29733         jclass ret_conv = LDKRecipient_to_java(env, Recipient_clone(orig_conv));
29734         return ret_conv;
29735 }
29736
29737 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1node(JNIEnv *env, jclass clz) {
29738         jclass ret_conv = LDKRecipient_to_java(env, Recipient_node());
29739         return ret_conv;
29740 }
29741
29742 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1phantom_1node(JNIEnv *env, jclass clz) {
29743         jclass ret_conv = LDKRecipient_to_java(env, Recipient_phantom_node());
29744         return ret_conv;
29745 }
29746
29747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29748         if (!ptr_is_owned(this_ptr)) return;
29749         void* this_ptr_ptr = untag_ptr(this_ptr);
29750         CHECK_ACCESS(this_ptr_ptr);
29751         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
29752         FREE(untag_ptr(this_ptr));
29753         KeysInterface_free(this_ptr_conv);
29754 }
29755
29756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29757         LDKInMemorySigner this_obj_conv;
29758         this_obj_conv.inner = untag_ptr(this_obj);
29759         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29761         InMemorySigner_free(this_obj_conv);
29762 }
29763
29764 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
29765         LDKInMemorySigner this_ptr_conv;
29766         this_ptr_conv.inner = untag_ptr(this_ptr);
29767         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29769         this_ptr_conv.is_owned = false;
29770         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29771         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
29772         return ret_arr;
29773 }
29774
29775 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29776         LDKInMemorySigner this_ptr_conv;
29777         this_ptr_conv.inner = untag_ptr(this_ptr);
29778         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29780         this_ptr_conv.is_owned = false;
29781         LDKSecretKey val_ref;
29782         CHECK((*env)->GetArrayLength(env, val) == 32);
29783         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
29784         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
29785 }
29786
29787 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
29788         LDKInMemorySigner this_ptr_conv;
29789         this_ptr_conv.inner = untag_ptr(this_ptr);
29790         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29792         this_ptr_conv.is_owned = false;
29793         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29794         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
29795         return ret_arr;
29796 }
29797
29798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29799         LDKInMemorySigner this_ptr_conv;
29800         this_ptr_conv.inner = untag_ptr(this_ptr);
29801         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29803         this_ptr_conv.is_owned = false;
29804         LDKSecretKey val_ref;
29805         CHECK((*env)->GetArrayLength(env, val) == 32);
29806         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
29807         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
29808 }
29809
29810 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
29811         LDKInMemorySigner this_ptr_conv;
29812         this_ptr_conv.inner = untag_ptr(this_ptr);
29813         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29815         this_ptr_conv.is_owned = false;
29816         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29817         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
29818         return ret_arr;
29819 }
29820
29821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29822         LDKInMemorySigner this_ptr_conv;
29823         this_ptr_conv.inner = untag_ptr(this_ptr);
29824         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29826         this_ptr_conv.is_owned = false;
29827         LDKSecretKey val_ref;
29828         CHECK((*env)->GetArrayLength(env, val) == 32);
29829         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
29830         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
29831 }
29832
29833 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
29834         LDKInMemorySigner this_ptr_conv;
29835         this_ptr_conv.inner = untag_ptr(this_ptr);
29836         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29838         this_ptr_conv.is_owned = false;
29839         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29840         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
29841         return ret_arr;
29842 }
29843
29844 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) {
29845         LDKInMemorySigner this_ptr_conv;
29846         this_ptr_conv.inner = untag_ptr(this_ptr);
29847         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29849         this_ptr_conv.is_owned = false;
29850         LDKSecretKey val_ref;
29851         CHECK((*env)->GetArrayLength(env, val) == 32);
29852         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
29853         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
29854 }
29855
29856 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
29857         LDKInMemorySigner this_ptr_conv;
29858         this_ptr_conv.inner = untag_ptr(this_ptr);
29859         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29861         this_ptr_conv.is_owned = false;
29862         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29863         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
29864         return ret_arr;
29865 }
29866
29867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29868         LDKInMemorySigner this_ptr_conv;
29869         this_ptr_conv.inner = untag_ptr(this_ptr);
29870         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29872         this_ptr_conv.is_owned = false;
29873         LDKSecretKey val_ref;
29874         CHECK((*env)->GetArrayLength(env, val) == 32);
29875         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
29876         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
29877 }
29878
29879 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
29880         LDKInMemorySigner this_ptr_conv;
29881         this_ptr_conv.inner = untag_ptr(this_ptr);
29882         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29884         this_ptr_conv.is_owned = false;
29885         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29886         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
29887         return ret_arr;
29888 }
29889
29890 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29891         LDKInMemorySigner this_ptr_conv;
29892         this_ptr_conv.inner = untag_ptr(this_ptr);
29893         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29895         this_ptr_conv.is_owned = false;
29896         LDKThirtyTwoBytes val_ref;
29897         CHECK((*env)->GetArrayLength(env, val) == 32);
29898         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29899         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
29900 }
29901
29902 static inline uint64_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
29903         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
29904         int64_t ret_ref = 0;
29905         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29906         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29907         return ret_ref;
29908 }
29909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29910         LDKInMemorySigner arg_conv;
29911         arg_conv.inner = untag_ptr(arg);
29912         arg_conv.is_owned = ptr_is_owned(arg);
29913         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29914         arg_conv.is_owned = false;
29915         int64_t ret_conv = InMemorySigner_clone_ptr(&arg_conv);
29916         return ret_conv;
29917 }
29918
29919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29920         LDKInMemorySigner orig_conv;
29921         orig_conv.inner = untag_ptr(orig);
29922         orig_conv.is_owned = ptr_is_owned(orig);
29923         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29924         orig_conv.is_owned = false;
29925         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
29926         int64_t ret_ref = 0;
29927         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29928         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29929         return ret_ref;
29930 }
29931
29932 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) {
29933         LDKSecretKey node_secret_ref;
29934         CHECK((*env)->GetArrayLength(env, node_secret) == 32);
29935         (*env)->GetByteArrayRegion(env, node_secret, 0, 32, node_secret_ref.bytes);
29936         LDKSecretKey funding_key_ref;
29937         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
29938         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
29939         LDKSecretKey revocation_base_key_ref;
29940         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
29941         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
29942         LDKSecretKey payment_key_ref;
29943         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
29944         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
29945         LDKSecretKey delayed_payment_base_key_ref;
29946         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
29947         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
29948         LDKSecretKey htlc_base_key_ref;
29949         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
29950         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
29951         LDKThirtyTwoBytes commitment_seed_ref;
29952         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
29953         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
29954         LDKThirtyTwoBytes channel_keys_id_ref;
29955         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
29956         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
29957         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);
29958         int64_t ret_ref = 0;
29959         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29960         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29961         return ret_ref;
29962 }
29963
29964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
29965         LDKInMemorySigner this_arg_conv;
29966         this_arg_conv.inner = untag_ptr(this_arg);
29967         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29969         this_arg_conv.is_owned = false;
29970         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
29971         int64_t ret_ref = 0;
29972         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29973         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29974         return ret_ref;
29975 }
29976
29977 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
29978         LDKInMemorySigner this_arg_conv;
29979         this_arg_conv.inner = untag_ptr(this_arg);
29980         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29982         this_arg_conv.is_owned = false;
29983         int16_t ret_conv = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
29984         return ret_conv;
29985 }
29986
29987 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
29988         LDKInMemorySigner this_arg_conv;
29989         this_arg_conv.inner = untag_ptr(this_arg);
29990         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29992         this_arg_conv.is_owned = false;
29993         int16_t ret_conv = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
29994         return ret_conv;
29995 }
29996
29997 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
29998         LDKInMemorySigner this_arg_conv;
29999         this_arg_conv.inner = untag_ptr(this_arg);
30000         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30002         this_arg_conv.is_owned = false;
30003         jboolean ret_conv = InMemorySigner_is_outbound(&this_arg_conv);
30004         return ret_conv;
30005 }
30006
30007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
30008         LDKInMemorySigner this_arg_conv;
30009         this_arg_conv.inner = untag_ptr(this_arg);
30010         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30012         this_arg_conv.is_owned = false;
30013         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
30014         int64_t ret_ref = 0;
30015         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30016         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30017         return ret_ref;
30018 }
30019
30020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
30021         LDKInMemorySigner this_arg_conv;
30022         this_arg_conv.inner = untag_ptr(this_arg);
30023         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30025         this_arg_conv.is_owned = false;
30026         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
30027         int64_t ret_ref = 0;
30028         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30029         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30030         return ret_ref;
30031 }
30032
30033 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
30034         LDKInMemorySigner this_arg_conv;
30035         this_arg_conv.inner = untag_ptr(this_arg);
30036         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30038         this_arg_conv.is_owned = false;
30039         jboolean ret_conv = InMemorySigner_opt_anchors(&this_arg_conv);
30040         return ret_conv;
30041 }
30042
30043 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) {
30044         LDKInMemorySigner this_arg_conv;
30045         this_arg_conv.inner = untag_ptr(this_arg);
30046         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30048         this_arg_conv.is_owned = false;
30049         LDKTransaction spend_tx_ref;
30050         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
30051         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
30052         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
30053         spend_tx_ref.data_is_owned = true;
30054         LDKStaticPaymentOutputDescriptor descriptor_conv;
30055         descriptor_conv.inner = untag_ptr(descriptor);
30056         descriptor_conv.is_owned = ptr_is_owned(descriptor);
30057         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
30058         descriptor_conv.is_owned = false;
30059         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
30060         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
30061         return tag_ptr(ret_conv, true);
30062 }
30063
30064 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) {
30065         LDKInMemorySigner this_arg_conv;
30066         this_arg_conv.inner = untag_ptr(this_arg);
30067         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30069         this_arg_conv.is_owned = false;
30070         LDKTransaction spend_tx_ref;
30071         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
30072         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
30073         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
30074         spend_tx_ref.data_is_owned = true;
30075         LDKDelayedPaymentOutputDescriptor descriptor_conv;
30076         descriptor_conv.inner = untag_ptr(descriptor);
30077         descriptor_conv.is_owned = ptr_is_owned(descriptor);
30078         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
30079         descriptor_conv.is_owned = false;
30080         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
30081         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
30082         return tag_ptr(ret_conv, true);
30083 }
30084
30085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
30086         LDKInMemorySigner this_arg_conv;
30087         this_arg_conv.inner = untag_ptr(this_arg);
30088         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30090         this_arg_conv.is_owned = false;
30091         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
30092         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
30093         return tag_ptr(ret_ret, true);
30094 }
30095
30096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
30097         LDKInMemorySigner this_arg_conv;
30098         this_arg_conv.inner = untag_ptr(this_arg);
30099         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30101         this_arg_conv.is_owned = false;
30102         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
30103         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
30104         return tag_ptr(ret_ret, true);
30105 }
30106
30107 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
30108         LDKInMemorySigner obj_conv;
30109         obj_conv.inner = untag_ptr(obj);
30110         obj_conv.is_owned = ptr_is_owned(obj);
30111         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30112         obj_conv.is_owned = false;
30113         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
30114         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30115         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30116         CVec_u8Z_free(ret_var);
30117         return ret_arr;
30118 }
30119
30120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser, int8_tArray arg) {
30121         LDKu8slice ser_ref;
30122         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30123         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30124         LDKSecretKey arg_ref;
30125         CHECK((*env)->GetArrayLength(env, arg) == 32);
30126         (*env)->GetByteArrayRegion(env, arg, 0, 32, arg_ref.bytes);
30127         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
30128         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
30129         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30130         return tag_ptr(ret_conv, true);
30131 }
30132
30133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30134         LDKKeysManager this_obj_conv;
30135         this_obj_conv.inner = untag_ptr(this_obj);
30136         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30138         KeysManager_free(this_obj_conv);
30139 }
30140
30141 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) {
30142         unsigned char seed_arr[32];
30143         CHECK((*env)->GetArrayLength(env, seed) == 32);
30144         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
30145         unsigned char (*seed_ref)[32] = &seed_arr;
30146         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
30147         int64_t ret_ref = 0;
30148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30149         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30150         return ret_ref;
30151 }
30152
30153 JNIEXPORT 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) {
30154         LDKKeysManager this_arg_conv;
30155         this_arg_conv.inner = untag_ptr(this_arg);
30156         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30158         this_arg_conv.is_owned = false;
30159         unsigned char params_arr[32];
30160         CHECK((*env)->GetArrayLength(env, params) == 32);
30161         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
30162         unsigned char (*params_ref)[32] = &params_arr;
30163         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
30164         int64_t ret_ref = 0;
30165         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30166         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30167         return ret_ref;
30168 }
30169
30170 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) {
30171         LDKKeysManager this_arg_conv;
30172         this_arg_conv.inner = untag_ptr(this_arg);
30173         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30175         this_arg_conv.is_owned = false;
30176         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
30177         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
30178         if (descriptors_constr.datalen > 0)
30179                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
30180         else
30181                 descriptors_constr.data = NULL;
30182         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
30183         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
30184                 int64_t descriptors_conv_27 = descriptors_vals[b];
30185                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
30186                 CHECK_ACCESS(descriptors_conv_27_ptr);
30187                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
30188                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
30189                 descriptors_constr.data[b] = descriptors_conv_27_conv;
30190         }
30191         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
30192         LDKCVec_TxOutZ outputs_constr;
30193         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
30194         if (outputs_constr.datalen > 0)
30195                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
30196         else
30197                 outputs_constr.data = NULL;
30198         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
30199         for (size_t h = 0; h < outputs_constr.datalen; h++) {
30200                 int64_t outputs_conv_7 = outputs_vals[h];
30201                 void* outputs_conv_7_ptr = untag_ptr(outputs_conv_7);
30202                 CHECK_ACCESS(outputs_conv_7_ptr);
30203                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
30204                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(outputs_conv_7));
30205                 outputs_constr.data[h] = outputs_conv_7_conv;
30206         }
30207         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
30208         LDKCVec_u8Z change_destination_script_ref;
30209         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
30210         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
30211         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
30212         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
30213         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
30214         return tag_ptr(ret_conv, true);
30215 }
30216
30217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
30218         LDKKeysManager this_arg_conv;
30219         this_arg_conv.inner = untag_ptr(this_arg);
30220         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30222         this_arg_conv.is_owned = false;
30223         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
30224         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
30225         return tag_ptr(ret_ret, true);
30226 }
30227
30228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30229         LDKPhantomKeysManager this_obj_conv;
30230         this_obj_conv.inner = untag_ptr(this_obj);
30231         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30233         PhantomKeysManager_free(this_obj_conv);
30234 }
30235
30236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
30237         LDKPhantomKeysManager this_arg_conv;
30238         this_arg_conv.inner = untag_ptr(this_arg);
30239         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30241         this_arg_conv.is_owned = false;
30242         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
30243         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
30244         return tag_ptr(ret_ret, true);
30245 }
30246
30247 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) {
30248         unsigned char seed_arr[32];
30249         CHECK((*env)->GetArrayLength(env, seed) == 32);
30250         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
30251         unsigned char (*seed_ref)[32] = &seed_arr;
30252         unsigned char cross_node_seed_arr[32];
30253         CHECK((*env)->GetArrayLength(env, cross_node_seed) == 32);
30254         (*env)->GetByteArrayRegion(env, cross_node_seed, 0, 32, cross_node_seed_arr);
30255         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
30256         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
30257         int64_t ret_ref = 0;
30258         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30259         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30260         return ret_ref;
30261 }
30262
30263 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) {
30264         LDKPhantomKeysManager this_arg_conv;
30265         this_arg_conv.inner = untag_ptr(this_arg);
30266         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30268         this_arg_conv.is_owned = false;
30269         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
30270         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
30271         if (descriptors_constr.datalen > 0)
30272                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
30273         else
30274                 descriptors_constr.data = NULL;
30275         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
30276         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
30277                 int64_t descriptors_conv_27 = descriptors_vals[b];
30278                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
30279                 CHECK_ACCESS(descriptors_conv_27_ptr);
30280                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
30281                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
30282                 descriptors_constr.data[b] = descriptors_conv_27_conv;
30283         }
30284         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
30285         LDKCVec_TxOutZ outputs_constr;
30286         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
30287         if (outputs_constr.datalen > 0)
30288                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
30289         else
30290                 outputs_constr.data = NULL;
30291         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
30292         for (size_t h = 0; h < outputs_constr.datalen; h++) {
30293                 int64_t outputs_conv_7 = outputs_vals[h];
30294                 void* outputs_conv_7_ptr = untag_ptr(outputs_conv_7);
30295                 CHECK_ACCESS(outputs_conv_7_ptr);
30296                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
30297                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(outputs_conv_7));
30298                 outputs_constr.data[h] = outputs_conv_7_conv;
30299         }
30300         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
30301         LDKCVec_u8Z change_destination_script_ref;
30302         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
30303         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
30304         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
30305         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
30306         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
30307         return tag_ptr(ret_conv, true);
30308 }
30309
30310 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) {
30311         LDKPhantomKeysManager this_arg_conv;
30312         this_arg_conv.inner = untag_ptr(this_arg);
30313         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30315         this_arg_conv.is_owned = false;
30316         unsigned char params_arr[32];
30317         CHECK((*env)->GetArrayLength(env, params) == 32);
30318         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
30319         unsigned char (*params_ref)[32] = &params_arr;
30320         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
30321         int64_t ret_ref = 0;
30322         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30323         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30324         return ret_ref;
30325 }
30326
30327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30328         LDKChannelManager this_obj_conv;
30329         this_obj_conv.inner = untag_ptr(this_obj);
30330         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30332         ChannelManager_free(this_obj_conv);
30333 }
30334
30335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30336         LDKChainParameters this_obj_conv;
30337         this_obj_conv.inner = untag_ptr(this_obj);
30338         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30340         ChainParameters_free(this_obj_conv);
30341 }
30342
30343 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
30344         LDKChainParameters this_ptr_conv;
30345         this_ptr_conv.inner = untag_ptr(this_ptr);
30346         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30348         this_ptr_conv.is_owned = false;
30349         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
30350         return ret_conv;
30351 }
30352
30353 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
30354         LDKChainParameters this_ptr_conv;
30355         this_ptr_conv.inner = untag_ptr(this_ptr);
30356         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30358         this_ptr_conv.is_owned = false;
30359         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
30360         ChainParameters_set_network(&this_ptr_conv, val_conv);
30361 }
30362
30363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
30364         LDKChainParameters this_ptr_conv;
30365         this_ptr_conv.inner = untag_ptr(this_ptr);
30366         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30368         this_ptr_conv.is_owned = false;
30369         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
30370         int64_t ret_ref = 0;
30371         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30372         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30373         return ret_ref;
30374 }
30375
30376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30377         LDKChainParameters this_ptr_conv;
30378         this_ptr_conv.inner = untag_ptr(this_ptr);
30379         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30381         this_ptr_conv.is_owned = false;
30382         LDKBestBlock val_conv;
30383         val_conv.inner = untag_ptr(val);
30384         val_conv.is_owned = ptr_is_owned(val);
30385         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30386         val_conv = BestBlock_clone(&val_conv);
30387         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
30388 }
30389
30390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
30391         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
30392         LDKBestBlock best_block_arg_conv;
30393         best_block_arg_conv.inner = untag_ptr(best_block_arg);
30394         best_block_arg_conv.is_owned = ptr_is_owned(best_block_arg);
30395         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
30396         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
30397         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
30398         int64_t ret_ref = 0;
30399         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30400         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30401         return ret_ref;
30402 }
30403
30404 static inline uint64_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
30405         LDKChainParameters ret_var = ChainParameters_clone(arg);
30406         int64_t ret_ref = 0;
30407         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30408         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30409         return ret_ref;
30410 }
30411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30412         LDKChainParameters arg_conv;
30413         arg_conv.inner = untag_ptr(arg);
30414         arg_conv.is_owned = ptr_is_owned(arg);
30415         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30416         arg_conv.is_owned = false;
30417         int64_t ret_conv = ChainParameters_clone_ptr(&arg_conv);
30418         return ret_conv;
30419 }
30420
30421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30422         LDKChainParameters orig_conv;
30423         orig_conv.inner = untag_ptr(orig);
30424         orig_conv.is_owned = ptr_is_owned(orig);
30425         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30426         orig_conv.is_owned = false;
30427         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
30428         int64_t ret_ref = 0;
30429         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30430         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30431         return ret_ref;
30432 }
30433
30434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30435         LDKCounterpartyForwardingInfo this_obj_conv;
30436         this_obj_conv.inner = untag_ptr(this_obj);
30437         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30439         CounterpartyForwardingInfo_free(this_obj_conv);
30440 }
30441
30442 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30443         LDKCounterpartyForwardingInfo this_ptr_conv;
30444         this_ptr_conv.inner = untag_ptr(this_ptr);
30445         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30447         this_ptr_conv.is_owned = false;
30448         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
30449         return ret_conv;
30450 }
30451
30452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
30453         LDKCounterpartyForwardingInfo this_ptr_conv;
30454         this_ptr_conv.inner = untag_ptr(this_ptr);
30455         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30457         this_ptr_conv.is_owned = false;
30458         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
30459 }
30460
30461 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
30462         LDKCounterpartyForwardingInfo this_ptr_conv;
30463         this_ptr_conv.inner = untag_ptr(this_ptr);
30464         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30466         this_ptr_conv.is_owned = false;
30467         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
30468         return ret_conv;
30469 }
30470
30471 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
30472         LDKCounterpartyForwardingInfo this_ptr_conv;
30473         this_ptr_conv.inner = untag_ptr(this_ptr);
30474         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30476         this_ptr_conv.is_owned = false;
30477         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
30478 }
30479
30480 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
30481         LDKCounterpartyForwardingInfo this_ptr_conv;
30482         this_ptr_conv.inner = untag_ptr(this_ptr);
30483         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30485         this_ptr_conv.is_owned = false;
30486         int16_t ret_conv = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
30487         return ret_conv;
30488 }
30489
30490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30491         LDKCounterpartyForwardingInfo this_ptr_conv;
30492         this_ptr_conv.inner = untag_ptr(this_ptr);
30493         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30495         this_ptr_conv.is_owned = false;
30496         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
30497 }
30498
30499 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) {
30500         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
30501         int64_t ret_ref = 0;
30502         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30503         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30504         return ret_ref;
30505 }
30506
30507 static inline uint64_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
30508         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
30509         int64_t ret_ref = 0;
30510         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30511         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30512         return ret_ref;
30513 }
30514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30515         LDKCounterpartyForwardingInfo arg_conv;
30516         arg_conv.inner = untag_ptr(arg);
30517         arg_conv.is_owned = ptr_is_owned(arg);
30518         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30519         arg_conv.is_owned = false;
30520         int64_t ret_conv = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
30521         return ret_conv;
30522 }
30523
30524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30525         LDKCounterpartyForwardingInfo orig_conv;
30526         orig_conv.inner = untag_ptr(orig);
30527         orig_conv.is_owned = ptr_is_owned(orig);
30528         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30529         orig_conv.is_owned = false;
30530         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
30531         int64_t ret_ref = 0;
30532         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30533         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30534         return ret_ref;
30535 }
30536
30537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30538         LDKChannelCounterparty this_obj_conv;
30539         this_obj_conv.inner = untag_ptr(this_obj);
30540         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30542         ChannelCounterparty_free(this_obj_conv);
30543 }
30544
30545 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30546         LDKChannelCounterparty this_ptr_conv;
30547         this_ptr_conv.inner = untag_ptr(this_ptr);
30548         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30550         this_ptr_conv.is_owned = false;
30551         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30552         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
30553         return ret_arr;
30554 }
30555
30556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30557         LDKChannelCounterparty this_ptr_conv;
30558         this_ptr_conv.inner = untag_ptr(this_ptr);
30559         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30561         this_ptr_conv.is_owned = false;
30562         LDKPublicKey val_ref;
30563         CHECK((*env)->GetArrayLength(env, val) == 33);
30564         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30565         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
30566 }
30567
30568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
30569         LDKChannelCounterparty this_ptr_conv;
30570         this_ptr_conv.inner = untag_ptr(this_ptr);
30571         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30573         this_ptr_conv.is_owned = false;
30574         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
30575         int64_t ret_ref = 0;
30576         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30577         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30578         return ret_ref;
30579 }
30580
30581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30582         LDKChannelCounterparty this_ptr_conv;
30583         this_ptr_conv.inner = untag_ptr(this_ptr);
30584         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30586         this_ptr_conv.is_owned = false;
30587         LDKInitFeatures val_conv;
30588         val_conv.inner = untag_ptr(val);
30589         val_conv.is_owned = ptr_is_owned(val);
30590         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30591         val_conv = InitFeatures_clone(&val_conv);
30592         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
30593 }
30594
30595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
30596         LDKChannelCounterparty this_ptr_conv;
30597         this_ptr_conv.inner = untag_ptr(this_ptr);
30598         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30600         this_ptr_conv.is_owned = false;
30601         int64_t ret_conv = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
30602         return ret_conv;
30603 }
30604
30605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30606         LDKChannelCounterparty this_ptr_conv;
30607         this_ptr_conv.inner = untag_ptr(this_ptr);
30608         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30610         this_ptr_conv.is_owned = false;
30611         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
30612 }
30613
30614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
30615         LDKChannelCounterparty this_ptr_conv;
30616         this_ptr_conv.inner = untag_ptr(this_ptr);
30617         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30619         this_ptr_conv.is_owned = false;
30620         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
30621         int64_t ret_ref = 0;
30622         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30623         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30624         return ret_ref;
30625 }
30626
30627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30628         LDKChannelCounterparty this_ptr_conv;
30629         this_ptr_conv.inner = untag_ptr(this_ptr);
30630         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30632         this_ptr_conv.is_owned = false;
30633         LDKCounterpartyForwardingInfo val_conv;
30634         val_conv.inner = untag_ptr(val);
30635         val_conv.is_owned = ptr_is_owned(val);
30636         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30637         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
30638         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
30639 }
30640
30641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30642         LDKChannelCounterparty this_ptr_conv;
30643         this_ptr_conv.inner = untag_ptr(this_ptr);
30644         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30646         this_ptr_conv.is_owned = false;
30647         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30648         *ret_copy = ChannelCounterparty_get_outbound_htlc_minimum_msat(&this_ptr_conv);
30649         int64_t ret_ref = tag_ptr(ret_copy, true);
30650         return ret_ref;
30651 }
30652
30653 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) {
30654         LDKChannelCounterparty this_ptr_conv;
30655         this_ptr_conv.inner = untag_ptr(this_ptr);
30656         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30658         this_ptr_conv.is_owned = false;
30659         void* val_ptr = untag_ptr(val);
30660         CHECK_ACCESS(val_ptr);
30661         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30662         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
30663         ChannelCounterparty_set_outbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
30664 }
30665
30666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30667         LDKChannelCounterparty this_ptr_conv;
30668         this_ptr_conv.inner = untag_ptr(this_ptr);
30669         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30671         this_ptr_conv.is_owned = false;
30672         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30673         *ret_copy = ChannelCounterparty_get_outbound_htlc_maximum_msat(&this_ptr_conv);
30674         int64_t ret_ref = tag_ptr(ret_copy, true);
30675         return ret_ref;
30676 }
30677
30678 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) {
30679         LDKChannelCounterparty this_ptr_conv;
30680         this_ptr_conv.inner = untag_ptr(this_ptr);
30681         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30683         this_ptr_conv.is_owned = false;
30684         void* val_ptr = untag_ptr(val);
30685         CHECK_ACCESS(val_ptr);
30686         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30687         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
30688         ChannelCounterparty_set_outbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
30689 }
30690
30691 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) {
30692         LDKPublicKey node_id_arg_ref;
30693         CHECK((*env)->GetArrayLength(env, node_id_arg) == 33);
30694         (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form);
30695         LDKInitFeatures features_arg_conv;
30696         features_arg_conv.inner = untag_ptr(features_arg);
30697         features_arg_conv.is_owned = ptr_is_owned(features_arg);
30698         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
30699         features_arg_conv = InitFeatures_clone(&features_arg_conv);
30700         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
30701         forwarding_info_arg_conv.inner = untag_ptr(forwarding_info_arg);
30702         forwarding_info_arg_conv.is_owned = ptr_is_owned(forwarding_info_arg);
30703         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
30704         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
30705         void* outbound_htlc_minimum_msat_arg_ptr = untag_ptr(outbound_htlc_minimum_msat_arg);
30706         CHECK_ACCESS(outbound_htlc_minimum_msat_arg_ptr);
30707         LDKCOption_u64Z outbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_minimum_msat_arg_ptr);
30708         outbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_htlc_minimum_msat_arg));
30709         void* outbound_htlc_maximum_msat_arg_ptr = untag_ptr(outbound_htlc_maximum_msat_arg);
30710         CHECK_ACCESS(outbound_htlc_maximum_msat_arg_ptr);
30711         LDKCOption_u64Z outbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_maximum_msat_arg_ptr);
30712         outbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_htlc_maximum_msat_arg));
30713         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);
30714         int64_t ret_ref = 0;
30715         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30716         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30717         return ret_ref;
30718 }
30719
30720 static inline uint64_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
30721         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
30722         int64_t ret_ref = 0;
30723         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30724         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30725         return ret_ref;
30726 }
30727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30728         LDKChannelCounterparty arg_conv;
30729         arg_conv.inner = untag_ptr(arg);
30730         arg_conv.is_owned = ptr_is_owned(arg);
30731         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30732         arg_conv.is_owned = false;
30733         int64_t ret_conv = ChannelCounterparty_clone_ptr(&arg_conv);
30734         return ret_conv;
30735 }
30736
30737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30738         LDKChannelCounterparty orig_conv;
30739         orig_conv.inner = untag_ptr(orig);
30740         orig_conv.is_owned = ptr_is_owned(orig);
30741         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30742         orig_conv.is_owned = false;
30743         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
30744         int64_t ret_ref = 0;
30745         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30746         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30747         return ret_ref;
30748 }
30749
30750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30751         LDKChannelDetails this_obj_conv;
30752         this_obj_conv.inner = untag_ptr(this_obj);
30753         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30755         ChannelDetails_free(this_obj_conv);
30756 }
30757
30758 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30759         LDKChannelDetails this_ptr_conv;
30760         this_ptr_conv.inner = untag_ptr(this_ptr);
30761         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30763         this_ptr_conv.is_owned = false;
30764         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30765         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
30766         return ret_arr;
30767 }
30768
30769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30770         LDKChannelDetails this_ptr_conv;
30771         this_ptr_conv.inner = untag_ptr(this_ptr);
30772         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30774         this_ptr_conv.is_owned = false;
30775         LDKThirtyTwoBytes val_ref;
30776         CHECK((*env)->GetArrayLength(env, val) == 32);
30777         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30778         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
30779 }
30780
30781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
30782         LDKChannelDetails this_ptr_conv;
30783         this_ptr_conv.inner = untag_ptr(this_ptr);
30784         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30786         this_ptr_conv.is_owned = false;
30787         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
30788         int64_t ret_ref = 0;
30789         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30790         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30791         return ret_ref;
30792 }
30793
30794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30795         LDKChannelDetails this_ptr_conv;
30796         this_ptr_conv.inner = untag_ptr(this_ptr);
30797         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30799         this_ptr_conv.is_owned = false;
30800         LDKChannelCounterparty val_conv;
30801         val_conv.inner = untag_ptr(val);
30802         val_conv.is_owned = ptr_is_owned(val);
30803         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30804         val_conv = ChannelCounterparty_clone(&val_conv);
30805         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
30806 }
30807
30808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
30809         LDKChannelDetails this_ptr_conv;
30810         this_ptr_conv.inner = untag_ptr(this_ptr);
30811         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30813         this_ptr_conv.is_owned = false;
30814         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
30815         int64_t ret_ref = 0;
30816         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30817         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30818         return ret_ref;
30819 }
30820
30821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30822         LDKChannelDetails this_ptr_conv;
30823         this_ptr_conv.inner = untag_ptr(this_ptr);
30824         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30826         this_ptr_conv.is_owned = false;
30827         LDKOutPoint val_conv;
30828         val_conv.inner = untag_ptr(val);
30829         val_conv.is_owned = ptr_is_owned(val);
30830         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30831         val_conv = OutPoint_clone(&val_conv);
30832         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
30833 }
30834
30835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
30836         LDKChannelDetails this_ptr_conv;
30837         this_ptr_conv.inner = untag_ptr(this_ptr);
30838         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30840         this_ptr_conv.is_owned = false;
30841         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
30842         int64_t ret_ref = 0;
30843         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30844         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30845         return ret_ref;
30846 }
30847
30848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30849         LDKChannelDetails this_ptr_conv;
30850         this_ptr_conv.inner = untag_ptr(this_ptr);
30851         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30853         this_ptr_conv.is_owned = false;
30854         LDKChannelTypeFeatures val_conv;
30855         val_conv.inner = untag_ptr(val);
30856         val_conv.is_owned = ptr_is_owned(val);
30857         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30858         val_conv = ChannelTypeFeatures_clone(&val_conv);
30859         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
30860 }
30861
30862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30863         LDKChannelDetails this_ptr_conv;
30864         this_ptr_conv.inner = untag_ptr(this_ptr);
30865         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30867         this_ptr_conv.is_owned = false;
30868         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30869         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
30870         int64_t ret_ref = tag_ptr(ret_copy, true);
30871         return ret_ref;
30872 }
30873
30874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30875         LDKChannelDetails this_ptr_conv;
30876         this_ptr_conv.inner = untag_ptr(this_ptr);
30877         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30879         this_ptr_conv.is_owned = false;
30880         void* val_ptr = untag_ptr(val);
30881         CHECK_ACCESS(val_ptr);
30882         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30883         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
30884         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
30885 }
30886
30887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
30888         LDKChannelDetails this_ptr_conv;
30889         this_ptr_conv.inner = untag_ptr(this_ptr);
30890         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30892         this_ptr_conv.is_owned = false;
30893         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30894         *ret_copy = ChannelDetails_get_outbound_scid_alias(&this_ptr_conv);
30895         int64_t ret_ref = tag_ptr(ret_copy, true);
30896         return ret_ref;
30897 }
30898
30899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30900         LDKChannelDetails this_ptr_conv;
30901         this_ptr_conv.inner = untag_ptr(this_ptr);
30902         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30904         this_ptr_conv.is_owned = false;
30905         void* val_ptr = untag_ptr(val);
30906         CHECK_ACCESS(val_ptr);
30907         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30908         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
30909         ChannelDetails_set_outbound_scid_alias(&this_ptr_conv, val_conv);
30910 }
30911
30912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
30913         LDKChannelDetails this_ptr_conv;
30914         this_ptr_conv.inner = untag_ptr(this_ptr);
30915         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30917         this_ptr_conv.is_owned = false;
30918         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30919         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
30920         int64_t ret_ref = tag_ptr(ret_copy, true);
30921         return ret_ref;
30922 }
30923
30924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30925         LDKChannelDetails this_ptr_conv;
30926         this_ptr_conv.inner = untag_ptr(this_ptr);
30927         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30929         this_ptr_conv.is_owned = false;
30930         void* val_ptr = untag_ptr(val);
30931         CHECK_ACCESS(val_ptr);
30932         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30933         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
30934         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
30935 }
30936
30937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30938         LDKChannelDetails this_ptr_conv;
30939         this_ptr_conv.inner = untag_ptr(this_ptr);
30940         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30942         this_ptr_conv.is_owned = false;
30943         int64_t ret_conv = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
30944         return ret_conv;
30945 }
30946
30947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30948         LDKChannelDetails this_ptr_conv;
30949         this_ptr_conv.inner = untag_ptr(this_ptr);
30950         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30952         this_ptr_conv.is_owned = false;
30953         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
30954 }
30955
30956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
30957         LDKChannelDetails this_ptr_conv;
30958         this_ptr_conv.inner = untag_ptr(this_ptr);
30959         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30961         this_ptr_conv.is_owned = false;
30962         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30963         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
30964         int64_t ret_ref = tag_ptr(ret_copy, true);
30965         return ret_ref;
30966 }
30967
30968 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30969         LDKChannelDetails this_ptr_conv;
30970         this_ptr_conv.inner = untag_ptr(this_ptr);
30971         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30973         this_ptr_conv.is_owned = false;
30974         void* val_ptr = untag_ptr(val);
30975         CHECK_ACCESS(val_ptr);
30976         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30977         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
30978         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
30979 }
30980
30981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30982         LDKChannelDetails this_ptr_conv;
30983         this_ptr_conv.inner = untag_ptr(this_ptr);
30984         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30986         this_ptr_conv.is_owned = false;
30987         int64_t ret_conv = ChannelDetails_get_user_channel_id(&this_ptr_conv);
30988         return ret_conv;
30989 }
30990
30991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30992         LDKChannelDetails this_ptr_conv;
30993         this_ptr_conv.inner = untag_ptr(this_ptr);
30994         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30996         this_ptr_conv.is_owned = false;
30997         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
30998 }
30999
31000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31001         LDKChannelDetails this_ptr_conv;
31002         this_ptr_conv.inner = untag_ptr(this_ptr);
31003         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31005         this_ptr_conv.is_owned = false;
31006         int64_t ret_conv = ChannelDetails_get_balance_msat(&this_ptr_conv);
31007         return ret_conv;
31008 }
31009
31010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31011         LDKChannelDetails this_ptr_conv;
31012         this_ptr_conv.inner = untag_ptr(this_ptr);
31013         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31015         this_ptr_conv.is_owned = false;
31016         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
31017 }
31018
31019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31020         LDKChannelDetails this_ptr_conv;
31021         this_ptr_conv.inner = untag_ptr(this_ptr);
31022         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31024         this_ptr_conv.is_owned = false;
31025         int64_t ret_conv = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
31026         return ret_conv;
31027 }
31028
31029 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31030         LDKChannelDetails this_ptr_conv;
31031         this_ptr_conv.inner = untag_ptr(this_ptr);
31032         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31034         this_ptr_conv.is_owned = false;
31035         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
31036 }
31037
31038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1next_1outbound_1htlc_1limit_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31039         LDKChannelDetails this_ptr_conv;
31040         this_ptr_conv.inner = untag_ptr(this_ptr);
31041         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31043         this_ptr_conv.is_owned = false;
31044         int64_t ret_conv = ChannelDetails_get_next_outbound_htlc_limit_msat(&this_ptr_conv);
31045         return ret_conv;
31046 }
31047
31048 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) {
31049         LDKChannelDetails this_ptr_conv;
31050         this_ptr_conv.inner = untag_ptr(this_ptr);
31051         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31053         this_ptr_conv.is_owned = false;
31054         ChannelDetails_set_next_outbound_htlc_limit_msat(&this_ptr_conv, val);
31055 }
31056
31057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31058         LDKChannelDetails this_ptr_conv;
31059         this_ptr_conv.inner = untag_ptr(this_ptr);
31060         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31062         this_ptr_conv.is_owned = false;
31063         int64_t ret_conv = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
31064         return ret_conv;
31065 }
31066
31067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31068         LDKChannelDetails this_ptr_conv;
31069         this_ptr_conv.inner = untag_ptr(this_ptr);
31070         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31072         this_ptr_conv.is_owned = false;
31073         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
31074 }
31075
31076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
31077         LDKChannelDetails this_ptr_conv;
31078         this_ptr_conv.inner = untag_ptr(this_ptr);
31079         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31081         this_ptr_conv.is_owned = false;
31082         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
31083         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
31084         int64_t ret_ref = tag_ptr(ret_copy, true);
31085         return ret_ref;
31086 }
31087
31088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31089         LDKChannelDetails 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         void* val_ptr = untag_ptr(val);
31095         CHECK_ACCESS(val_ptr);
31096         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
31097         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
31098         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
31099 }
31100
31101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
31102         LDKChannelDetails this_ptr_conv;
31103         this_ptr_conv.inner = untag_ptr(this_ptr);
31104         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31106         this_ptr_conv.is_owned = false;
31107         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
31108         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
31109         int64_t ret_ref = tag_ptr(ret_copy, true);
31110         return ret_ref;
31111 }
31112
31113 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) {
31114         LDKChannelDetails this_ptr_conv;
31115         this_ptr_conv.inner = untag_ptr(this_ptr);
31116         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31118         this_ptr_conv.is_owned = false;
31119         void* val_ptr = untag_ptr(val);
31120         CHECK_ACCESS(val_ptr);
31121         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
31122         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(val));
31123         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
31124 }
31125
31126 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
31127         LDKChannelDetails this_ptr_conv;
31128         this_ptr_conv.inner = untag_ptr(this_ptr);
31129         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31131         this_ptr_conv.is_owned = false;
31132         jboolean ret_conv = ChannelDetails_get_is_outbound(&this_ptr_conv);
31133         return ret_conv;
31134 }
31135
31136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
31137         LDKChannelDetails this_ptr_conv;
31138         this_ptr_conv.inner = untag_ptr(this_ptr);
31139         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31141         this_ptr_conv.is_owned = false;
31142         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
31143 }
31144
31145 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr) {
31146         LDKChannelDetails this_ptr_conv;
31147         this_ptr_conv.inner = untag_ptr(this_ptr);
31148         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31150         this_ptr_conv.is_owned = false;
31151         jboolean ret_conv = ChannelDetails_get_is_channel_ready(&this_ptr_conv);
31152         return ret_conv;
31153 }
31154
31155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
31156         LDKChannelDetails this_ptr_conv;
31157         this_ptr_conv.inner = untag_ptr(this_ptr);
31158         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31160         this_ptr_conv.is_owned = false;
31161         ChannelDetails_set_is_channel_ready(&this_ptr_conv, val);
31162 }
31163
31164 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
31165         LDKChannelDetails this_ptr_conv;
31166         this_ptr_conv.inner = untag_ptr(this_ptr);
31167         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31169         this_ptr_conv.is_owned = false;
31170         jboolean ret_conv = ChannelDetails_get_is_usable(&this_ptr_conv);
31171         return ret_conv;
31172 }
31173
31174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
31175         LDKChannelDetails this_ptr_conv;
31176         this_ptr_conv.inner = untag_ptr(this_ptr);
31177         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31179         this_ptr_conv.is_owned = false;
31180         ChannelDetails_set_is_usable(&this_ptr_conv, val);
31181 }
31182
31183 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
31184         LDKChannelDetails this_ptr_conv;
31185         this_ptr_conv.inner = untag_ptr(this_ptr);
31186         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31188         this_ptr_conv.is_owned = false;
31189         jboolean ret_conv = ChannelDetails_get_is_public(&this_ptr_conv);
31190         return ret_conv;
31191 }
31192
31193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
31194         LDKChannelDetails this_ptr_conv;
31195         this_ptr_conv.inner = untag_ptr(this_ptr);
31196         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31198         this_ptr_conv.is_owned = false;
31199         ChannelDetails_set_is_public(&this_ptr_conv, val);
31200 }
31201
31202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31203         LDKChannelDetails this_ptr_conv;
31204         this_ptr_conv.inner = untag_ptr(this_ptr);
31205         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31207         this_ptr_conv.is_owned = false;
31208         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31209         *ret_copy = ChannelDetails_get_inbound_htlc_minimum_msat(&this_ptr_conv);
31210         int64_t ret_ref = tag_ptr(ret_copy, true);
31211         return ret_ref;
31212 }
31213
31214 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) {
31215         LDKChannelDetails this_ptr_conv;
31216         this_ptr_conv.inner = untag_ptr(this_ptr);
31217         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31219         this_ptr_conv.is_owned = false;
31220         void* val_ptr = untag_ptr(val);
31221         CHECK_ACCESS(val_ptr);
31222         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
31223         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
31224         ChannelDetails_set_inbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
31225 }
31226
31227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31228         LDKChannelDetails this_ptr_conv;
31229         this_ptr_conv.inner = untag_ptr(this_ptr);
31230         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31232         this_ptr_conv.is_owned = false;
31233         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31234         *ret_copy = ChannelDetails_get_inbound_htlc_maximum_msat(&this_ptr_conv);
31235         int64_t ret_ref = tag_ptr(ret_copy, true);
31236         return ret_ref;
31237 }
31238
31239 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) {
31240         LDKChannelDetails this_ptr_conv;
31241         this_ptr_conv.inner = untag_ptr(this_ptr);
31242         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31244         this_ptr_conv.is_owned = false;
31245         void* val_ptr = untag_ptr(val);
31246         CHECK_ACCESS(val_ptr);
31247         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
31248         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
31249         ChannelDetails_set_inbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
31250 }
31251
31252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
31253         LDKChannelDetails this_ptr_conv;
31254         this_ptr_conv.inner = untag_ptr(this_ptr);
31255         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31257         this_ptr_conv.is_owned = false;
31258         LDKChannelConfig ret_var = ChannelDetails_get_config(&this_ptr_conv);
31259         int64_t ret_ref = 0;
31260         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31261         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31262         return ret_ref;
31263 }
31264
31265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31266         LDKChannelDetails this_ptr_conv;
31267         this_ptr_conv.inner = untag_ptr(this_ptr);
31268         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31270         this_ptr_conv.is_owned = false;
31271         LDKChannelConfig val_conv;
31272         val_conv.inner = untag_ptr(val);
31273         val_conv.is_owned = ptr_is_owned(val);
31274         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31275         val_conv = ChannelConfig_clone(&val_conv);
31276         ChannelDetails_set_config(&this_ptr_conv, val_conv);
31277 }
31278
31279 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) {
31280         LDKThirtyTwoBytes channel_id_arg_ref;
31281         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
31282         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
31283         LDKChannelCounterparty counterparty_arg_conv;
31284         counterparty_arg_conv.inner = untag_ptr(counterparty_arg);
31285         counterparty_arg_conv.is_owned = ptr_is_owned(counterparty_arg);
31286         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
31287         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
31288         LDKOutPoint funding_txo_arg_conv;
31289         funding_txo_arg_conv.inner = untag_ptr(funding_txo_arg);
31290         funding_txo_arg_conv.is_owned = ptr_is_owned(funding_txo_arg);
31291         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
31292         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
31293         LDKChannelTypeFeatures channel_type_arg_conv;
31294         channel_type_arg_conv.inner = untag_ptr(channel_type_arg);
31295         channel_type_arg_conv.is_owned = ptr_is_owned(channel_type_arg);
31296         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
31297         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
31298         void* short_channel_id_arg_ptr = untag_ptr(short_channel_id_arg);
31299         CHECK_ACCESS(short_channel_id_arg_ptr);
31300         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
31301         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id_arg));
31302         void* outbound_scid_alias_arg_ptr = untag_ptr(outbound_scid_alias_arg);
31303         CHECK_ACCESS(outbound_scid_alias_arg_ptr);
31304         LDKCOption_u64Z outbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(outbound_scid_alias_arg_ptr);
31305         outbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_scid_alias_arg));
31306         void* inbound_scid_alias_arg_ptr = untag_ptr(inbound_scid_alias_arg);
31307         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
31308         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
31309         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_scid_alias_arg));
31310         void* unspendable_punishment_reserve_arg_ptr = untag_ptr(unspendable_punishment_reserve_arg);
31311         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
31312         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
31313         void* confirmations_required_arg_ptr = untag_ptr(confirmations_required_arg);
31314         CHECK_ACCESS(confirmations_required_arg_ptr);
31315         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
31316         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(confirmations_required_arg));
31317         void* force_close_spend_delay_arg_ptr = untag_ptr(force_close_spend_delay_arg);
31318         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
31319         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
31320         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(force_close_spend_delay_arg));
31321         void* inbound_htlc_minimum_msat_arg_ptr = untag_ptr(inbound_htlc_minimum_msat_arg);
31322         CHECK_ACCESS(inbound_htlc_minimum_msat_arg_ptr);
31323         LDKCOption_u64Z inbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_minimum_msat_arg_ptr);
31324         inbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_htlc_minimum_msat_arg));
31325         void* inbound_htlc_maximum_msat_arg_ptr = untag_ptr(inbound_htlc_maximum_msat_arg);
31326         CHECK_ACCESS(inbound_htlc_maximum_msat_arg_ptr);
31327         LDKCOption_u64Z inbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_maximum_msat_arg_ptr);
31328         inbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_htlc_maximum_msat_arg));
31329         LDKChannelConfig config_arg_conv;
31330         config_arg_conv.inner = untag_ptr(config_arg);
31331         config_arg_conv.is_owned = ptr_is_owned(config_arg);
31332         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_arg_conv);
31333         config_arg_conv = ChannelConfig_clone(&config_arg_conv);
31334         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);
31335         int64_t ret_ref = 0;
31336         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31337         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31338         return ret_ref;
31339 }
31340
31341 static inline uint64_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
31342         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
31343         int64_t ret_ref = 0;
31344         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31345         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31346         return ret_ref;
31347 }
31348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31349         LDKChannelDetails arg_conv;
31350         arg_conv.inner = untag_ptr(arg);
31351         arg_conv.is_owned = ptr_is_owned(arg);
31352         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31353         arg_conv.is_owned = false;
31354         int64_t ret_conv = ChannelDetails_clone_ptr(&arg_conv);
31355         return ret_conv;
31356 }
31357
31358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31359         LDKChannelDetails orig_conv;
31360         orig_conv.inner = untag_ptr(orig);
31361         orig_conv.is_owned = ptr_is_owned(orig);
31362         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31363         orig_conv.is_owned = false;
31364         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
31365         int64_t ret_ref = 0;
31366         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31367         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31368         return ret_ref;
31369 }
31370
31371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
31372         LDKChannelDetails this_arg_conv;
31373         this_arg_conv.inner = untag_ptr(this_arg);
31374         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31376         this_arg_conv.is_owned = false;
31377         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31378         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
31379         int64_t ret_ref = tag_ptr(ret_copy, true);
31380         return ret_ref;
31381 }
31382
31383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
31384         LDKChannelDetails this_arg_conv;
31385         this_arg_conv.inner = untag_ptr(this_arg);
31386         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31388         this_arg_conv.is_owned = false;
31389         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31390         *ret_copy = ChannelDetails_get_outbound_payment_scid(&this_arg_conv);
31391         int64_t ret_ref = tag_ptr(ret_copy, true);
31392         return ret_ref;
31393 }
31394
31395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31396         if (!ptr_is_owned(this_ptr)) return;
31397         void* this_ptr_ptr = untag_ptr(this_ptr);
31398         CHECK_ACCESS(this_ptr_ptr);
31399         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
31400         FREE(untag_ptr(this_ptr));
31401         PaymentSendFailure_free(this_ptr_conv);
31402 }
31403
31404 static inline uint64_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
31405         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
31406         *ret_copy = PaymentSendFailure_clone(arg);
31407         int64_t ret_ref = tag_ptr(ret_copy, true);
31408         return ret_ref;
31409 }
31410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31411         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)untag_ptr(arg);
31412         int64_t ret_conv = PaymentSendFailure_clone_ptr(arg_conv);
31413         return ret_conv;
31414 }
31415
31416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31417         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)untag_ptr(orig);
31418         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
31419         *ret_copy = PaymentSendFailure_clone(orig_conv);
31420         int64_t ret_ref = tag_ptr(ret_copy, true);
31421         return ret_ref;
31422 }
31423
31424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
31425         void* a_ptr = untag_ptr(a);
31426         CHECK_ACCESS(a_ptr);
31427         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
31428         a_conv = APIError_clone((LDKAPIError*)untag_ptr(a));
31429         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
31430         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
31431         int64_t ret_ref = tag_ptr(ret_copy, true);
31432         return ret_ref;
31433 }
31434
31435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
31436         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
31437         a_constr.datalen = (*env)->GetArrayLength(env, a);
31438         if (a_constr.datalen > 0)
31439                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
31440         else
31441                 a_constr.data = NULL;
31442         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
31443         for (size_t w = 0; w < a_constr.datalen; w++) {
31444                 int64_t a_conv_22 = a_vals[w];
31445                 void* a_conv_22_ptr = untag_ptr(a_conv_22);
31446                 CHECK_ACCESS(a_conv_22_ptr);
31447                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
31448                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)untag_ptr(a_conv_22));
31449                 a_constr.data[w] = a_conv_22_conv;
31450         }
31451         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
31452         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
31453         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
31454         int64_t ret_ref = tag_ptr(ret_copy, true);
31455         return ret_ref;
31456 }
31457
31458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1retry_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
31459         LDKCVec_APIErrorZ a_constr;
31460         a_constr.datalen = (*env)->GetArrayLength(env, a);
31461         if (a_constr.datalen > 0)
31462                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
31463         else
31464                 a_constr.data = NULL;
31465         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
31466         for (size_t k = 0; k < a_constr.datalen; k++) {
31467                 int64_t a_conv_10 = a_vals[k];
31468                 void* a_conv_10_ptr = untag_ptr(a_conv_10);
31469                 CHECK_ACCESS(a_conv_10_ptr);
31470                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
31471                 a_conv_10_conv = APIError_clone((LDKAPIError*)untag_ptr(a_conv_10));
31472                 a_constr.data[k] = a_conv_10_conv;
31473         }
31474         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
31475         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
31476         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
31477         int64_t ret_ref = tag_ptr(ret_copy, true);
31478         return ret_ref;
31479 }
31480
31481 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) {
31482         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
31483         results_constr.datalen = (*env)->GetArrayLength(env, results);
31484         if (results_constr.datalen > 0)
31485                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
31486         else
31487                 results_constr.data = NULL;
31488         int64_t* results_vals = (*env)->GetLongArrayElements (env, results, NULL);
31489         for (size_t w = 0; w < results_constr.datalen; w++) {
31490                 int64_t results_conv_22 = results_vals[w];
31491                 void* results_conv_22_ptr = untag_ptr(results_conv_22);
31492                 CHECK_ACCESS(results_conv_22_ptr);
31493                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
31494                 results_constr.data[w] = results_conv_22_conv;
31495         }
31496         (*env)->ReleaseLongArrayElements(env, results, results_vals, 0);
31497         LDKRouteParameters failed_paths_retry_conv;
31498         failed_paths_retry_conv.inner = untag_ptr(failed_paths_retry);
31499         failed_paths_retry_conv.is_owned = ptr_is_owned(failed_paths_retry);
31500         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
31501         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
31502         LDKThirtyTwoBytes payment_id_ref;
31503         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
31504         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
31505         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
31506         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
31507         int64_t ret_ref = tag_ptr(ret_copy, true);
31508         return ret_ref;
31509 }
31510
31511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31512         LDKPhantomRouteHints this_obj_conv;
31513         this_obj_conv.inner = untag_ptr(this_obj);
31514         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31516         PhantomRouteHints_free(this_obj_conv);
31517 }
31518
31519 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
31520         LDKPhantomRouteHints this_ptr_conv;
31521         this_ptr_conv.inner = untag_ptr(this_ptr);
31522         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31524         this_ptr_conv.is_owned = false;
31525         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
31526         int64_tArray ret_arr = NULL;
31527         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
31528         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
31529         for (size_t q = 0; q < ret_var.datalen; q++) {
31530                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
31531                 int64_t ret_conv_16_ref = 0;
31532                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
31533                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
31534                 ret_arr_ptr[q] = ret_conv_16_ref;
31535         }
31536         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
31537         FREE(ret_var.data);
31538         return ret_arr;
31539 }
31540
31541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
31542         LDKPhantomRouteHints this_ptr_conv;
31543         this_ptr_conv.inner = untag_ptr(this_ptr);
31544         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31546         this_ptr_conv.is_owned = false;
31547         LDKCVec_ChannelDetailsZ val_constr;
31548         val_constr.datalen = (*env)->GetArrayLength(env, val);
31549         if (val_constr.datalen > 0)
31550                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
31551         else
31552                 val_constr.data = NULL;
31553         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
31554         for (size_t q = 0; q < val_constr.datalen; q++) {
31555                 int64_t val_conv_16 = val_vals[q];
31556                 LDKChannelDetails val_conv_16_conv;
31557                 val_conv_16_conv.inner = untag_ptr(val_conv_16);
31558                 val_conv_16_conv.is_owned = ptr_is_owned(val_conv_16);
31559                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
31560                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
31561                 val_constr.data[q] = val_conv_16_conv;
31562         }
31563         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
31564         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
31565 }
31566
31567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr) {
31568         LDKPhantomRouteHints 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         int64_t ret_conv = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
31574         return ret_conv;
31575 }
31576
31577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31578         LDKPhantomRouteHints this_ptr_conv;
31579         this_ptr_conv.inner = untag_ptr(this_ptr);
31580         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31582         this_ptr_conv.is_owned = false;
31583         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
31584 }
31585
31586 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
31587         LDKPhantomRouteHints this_ptr_conv;
31588         this_ptr_conv.inner = untag_ptr(this_ptr);
31589         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31591         this_ptr_conv.is_owned = false;
31592         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31593         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form);
31594         return ret_arr;
31595 }
31596
31597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31598         LDKPhantomRouteHints this_ptr_conv;
31599         this_ptr_conv.inner = untag_ptr(this_ptr);
31600         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31602         this_ptr_conv.is_owned = false;
31603         LDKPublicKey val_ref;
31604         CHECK((*env)->GetArrayLength(env, val) == 33);
31605         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31606         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
31607 }
31608
31609 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) {
31610         LDKCVec_ChannelDetailsZ channels_arg_constr;
31611         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
31612         if (channels_arg_constr.datalen > 0)
31613                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
31614         else
31615                 channels_arg_constr.data = NULL;
31616         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
31617         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
31618                 int64_t channels_arg_conv_16 = channels_arg_vals[q];
31619                 LDKChannelDetails channels_arg_conv_16_conv;
31620                 channels_arg_conv_16_conv.inner = untag_ptr(channels_arg_conv_16);
31621                 channels_arg_conv_16_conv.is_owned = ptr_is_owned(channels_arg_conv_16);
31622                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
31623                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
31624                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
31625         }
31626         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
31627         LDKPublicKey real_node_pubkey_arg_ref;
31628         CHECK((*env)->GetArrayLength(env, real_node_pubkey_arg) == 33);
31629         (*env)->GetByteArrayRegion(env, real_node_pubkey_arg, 0, 33, real_node_pubkey_arg_ref.compressed_form);
31630         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
31631         int64_t ret_ref = 0;
31632         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31633         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31634         return ret_ref;
31635 }
31636
31637 static inline uint64_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
31638         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
31639         int64_t ret_ref = 0;
31640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31641         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31642         return ret_ref;
31643 }
31644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31645         LDKPhantomRouteHints arg_conv;
31646         arg_conv.inner = untag_ptr(arg);
31647         arg_conv.is_owned = ptr_is_owned(arg);
31648         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31649         arg_conv.is_owned = false;
31650         int64_t ret_conv = PhantomRouteHints_clone_ptr(&arg_conv);
31651         return ret_conv;
31652 }
31653
31654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31655         LDKPhantomRouteHints orig_conv;
31656         orig_conv.inner = untag_ptr(orig);
31657         orig_conv.is_owned = ptr_is_owned(orig);
31658         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31659         orig_conv.is_owned = false;
31660         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
31661         int64_t ret_ref = 0;
31662         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31663         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31664         return ret_ref;
31665 }
31666
31667 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) {
31668         void* fee_est_ptr = untag_ptr(fee_est);
31669         CHECK_ACCESS(fee_est_ptr);
31670         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
31671         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
31672                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31673                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
31674         }
31675         void* chain_monitor_ptr = untag_ptr(chain_monitor);
31676         CHECK_ACCESS(chain_monitor_ptr);
31677         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
31678         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
31679                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31680                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
31681         }
31682         void* tx_broadcaster_ptr = untag_ptr(tx_broadcaster);
31683         CHECK_ACCESS(tx_broadcaster_ptr);
31684         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
31685         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
31686                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31687                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
31688         }
31689         void* logger_ptr = untag_ptr(logger);
31690         CHECK_ACCESS(logger_ptr);
31691         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
31692         if (logger_conv.free == LDKLogger_JCalls_free) {
31693                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31694                 LDKLogger_JCalls_cloned(&logger_conv);
31695         }
31696         void* keys_manager_ptr = untag_ptr(keys_manager);
31697         CHECK_ACCESS(keys_manager_ptr);
31698         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
31699         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
31700                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31701                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
31702         }
31703         LDKUserConfig config_conv;
31704         config_conv.inner = untag_ptr(config);
31705         config_conv.is_owned = ptr_is_owned(config);
31706         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
31707         config_conv = UserConfig_clone(&config_conv);
31708         LDKChainParameters params_conv;
31709         params_conv.inner = untag_ptr(params);
31710         params_conv.is_owned = ptr_is_owned(params);
31711         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
31712         params_conv = ChainParameters_clone(&params_conv);
31713         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
31714         int64_t ret_ref = 0;
31715         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31716         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31717         return ret_ref;
31718 }
31719
31720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
31721         LDKChannelManager this_arg_conv;
31722         this_arg_conv.inner = untag_ptr(this_arg);
31723         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31725         this_arg_conv.is_owned = false;
31726         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
31727         int64_t ret_ref = 0;
31728         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31729         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31730         return ret_ref;
31731 }
31732
31733 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) {
31734         LDKChannelManager this_arg_conv;
31735         this_arg_conv.inner = untag_ptr(this_arg);
31736         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31738         this_arg_conv.is_owned = false;
31739         LDKPublicKey their_network_key_ref;
31740         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
31741         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
31742         LDKUserConfig override_config_conv;
31743         override_config_conv.inner = untag_ptr(override_config);
31744         override_config_conv.is_owned = ptr_is_owned(override_config);
31745         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
31746         override_config_conv = UserConfig_clone(&override_config_conv);
31747         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
31748         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
31749         return tag_ptr(ret_conv, true);
31750 }
31751
31752 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
31753         LDKChannelManager this_arg_conv;
31754         this_arg_conv.inner = untag_ptr(this_arg);
31755         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31757         this_arg_conv.is_owned = false;
31758         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
31759         int64_tArray ret_arr = NULL;
31760         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
31761         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
31762         for (size_t q = 0; q < ret_var.datalen; q++) {
31763                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
31764                 int64_t ret_conv_16_ref = 0;
31765                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
31766                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
31767                 ret_arr_ptr[q] = ret_conv_16_ref;
31768         }
31769         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
31770         FREE(ret_var.data);
31771         return ret_arr;
31772 }
31773
31774 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
31775         LDKChannelManager this_arg_conv;
31776         this_arg_conv.inner = untag_ptr(this_arg);
31777         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31779         this_arg_conv.is_owned = false;
31780         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
31781         int64_tArray ret_arr = NULL;
31782         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
31783         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
31784         for (size_t q = 0; q < ret_var.datalen; q++) {
31785                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
31786                 int64_t ret_conv_16_ref = 0;
31787                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
31788                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
31789                 ret_arr_ptr[q] = ret_conv_16_ref;
31790         }
31791         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
31792         FREE(ret_var.data);
31793         return ret_arr;
31794 }
31795
31796 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) {
31797         LDKChannelManager this_arg_conv;
31798         this_arg_conv.inner = untag_ptr(this_arg);
31799         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31801         this_arg_conv.is_owned = false;
31802         unsigned char channel_id_arr[32];
31803         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
31804         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
31805         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
31806         LDKPublicKey counterparty_node_id_ref;
31807         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31808         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31809         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31810         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
31811         return tag_ptr(ret_conv, true);
31812 }
31813
31814 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) {
31815         LDKChannelManager this_arg_conv;
31816         this_arg_conv.inner = untag_ptr(this_arg);
31817         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31819         this_arg_conv.is_owned = false;
31820         unsigned char channel_id_arr[32];
31821         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
31822         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
31823         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
31824         LDKPublicKey counterparty_node_id_ref;
31825         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31826         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31827         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31828         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, counterparty_node_id_ref, target_feerate_sats_per_1000_weight);
31829         return tag_ptr(ret_conv, true);
31830 }
31831
31832 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) {
31833         LDKChannelManager this_arg_conv;
31834         this_arg_conv.inner = untag_ptr(this_arg);
31835         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31837         this_arg_conv.is_owned = false;
31838         unsigned char channel_id_arr[32];
31839         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
31840         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
31841         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
31842         LDKPublicKey counterparty_node_id_ref;
31843         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31844         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31845         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31846         *ret_conv = ChannelManager_force_close_broadcasting_latest_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
31847         return tag_ptr(ret_conv, true);
31848 }
31849
31850 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) {
31851         LDKChannelManager this_arg_conv;
31852         this_arg_conv.inner = untag_ptr(this_arg);
31853         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31855         this_arg_conv.is_owned = false;
31856         unsigned char channel_id_arr[32];
31857         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
31858         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
31859         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
31860         LDKPublicKey counterparty_node_id_ref;
31861         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31862         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31863         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31864         *ret_conv = ChannelManager_force_close_without_broadcasting_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
31865         return tag_ptr(ret_conv, true);
31866 }
31867
31868 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1broadcasting_1latest_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
31869         LDKChannelManager this_arg_conv;
31870         this_arg_conv.inner = untag_ptr(this_arg);
31871         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31873         this_arg_conv.is_owned = false;
31874         ChannelManager_force_close_all_channels_broadcasting_latest_txn(&this_arg_conv);
31875 }
31876
31877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1without_1broadcasting_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
31878         LDKChannelManager this_arg_conv;
31879         this_arg_conv.inner = untag_ptr(this_arg);
31880         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31882         this_arg_conv.is_owned = false;
31883         ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv);
31884 }
31885
31886 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) {
31887         LDKChannelManager this_arg_conv;
31888         this_arg_conv.inner = untag_ptr(this_arg);
31889         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31891         this_arg_conv.is_owned = false;
31892         LDKRoute route_conv;
31893         route_conv.inner = untag_ptr(route);
31894         route_conv.is_owned = ptr_is_owned(route);
31895         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
31896         route_conv.is_owned = false;
31897         LDKThirtyTwoBytes payment_hash_ref;
31898         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
31899         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
31900         LDKThirtyTwoBytes payment_secret_ref;
31901         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
31902         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
31903         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
31904         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
31905         return tag_ptr(ret_conv, true);
31906 }
31907
31908 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) {
31909         LDKChannelManager this_arg_conv;
31910         this_arg_conv.inner = untag_ptr(this_arg);
31911         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31913         this_arg_conv.is_owned = false;
31914         LDKRoute route_conv;
31915         route_conv.inner = untag_ptr(route);
31916         route_conv.is_owned = ptr_is_owned(route);
31917         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
31918         route_conv.is_owned = false;
31919         LDKThirtyTwoBytes payment_id_ref;
31920         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
31921         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
31922         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
31923         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
31924         return tag_ptr(ret_conv, true);
31925 }
31926
31927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
31928         LDKChannelManager this_arg_conv;
31929         this_arg_conv.inner = untag_ptr(this_arg);
31930         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31932         this_arg_conv.is_owned = false;
31933         LDKThirtyTwoBytes payment_id_ref;
31934         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
31935         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
31936         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
31937 }
31938
31939 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) {
31940         LDKChannelManager this_arg_conv;
31941         this_arg_conv.inner = untag_ptr(this_arg);
31942         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31944         this_arg_conv.is_owned = false;
31945         LDKRoute route_conv;
31946         route_conv.inner = untag_ptr(route);
31947         route_conv.is_owned = ptr_is_owned(route);
31948         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
31949         route_conv.is_owned = false;
31950         LDKThirtyTwoBytes payment_preimage_ref;
31951         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
31952         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
31953         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
31954         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
31955         return tag_ptr(ret_conv, true);
31956 }
31957
31958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1probe(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray hops) {
31959         LDKChannelManager this_arg_conv;
31960         this_arg_conv.inner = untag_ptr(this_arg);
31961         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31963         this_arg_conv.is_owned = false;
31964         LDKCVec_RouteHopZ hops_constr;
31965         hops_constr.datalen = (*env)->GetArrayLength(env, hops);
31966         if (hops_constr.datalen > 0)
31967                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
31968         else
31969                 hops_constr.data = NULL;
31970         int64_t* hops_vals = (*env)->GetLongArrayElements (env, hops, NULL);
31971         for (size_t k = 0; k < hops_constr.datalen; k++) {
31972                 int64_t hops_conv_10 = hops_vals[k];
31973                 LDKRouteHop hops_conv_10_conv;
31974                 hops_conv_10_conv.inner = untag_ptr(hops_conv_10);
31975                 hops_conv_10_conv.is_owned = ptr_is_owned(hops_conv_10);
31976                 CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv_10_conv);
31977                 hops_conv_10_conv = RouteHop_clone(&hops_conv_10_conv);
31978                 hops_constr.data[k] = hops_conv_10_conv;
31979         }
31980         (*env)->ReleaseLongArrayElements(env, hops, hops_vals, 0);
31981         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
31982         *ret_conv = ChannelManager_send_probe(&this_arg_conv, hops_constr);
31983         return tag_ptr(ret_conv, true);
31984 }
31985
31986 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) {
31987         LDKChannelManager this_arg_conv;
31988         this_arg_conv.inner = untag_ptr(this_arg);
31989         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31991         this_arg_conv.is_owned = false;
31992         unsigned char temporary_channel_id_arr[32];
31993         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
31994         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
31995         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
31996         LDKPublicKey counterparty_node_id_ref;
31997         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31998         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31999         LDKTransaction funding_transaction_ref;
32000         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
32001         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
32002         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
32003         funding_transaction_ref.data_is_owned = true;
32004         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
32005         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, funding_transaction_ref);
32006         return tag_ptr(ret_conv, true);
32007 }
32008
32009 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) {
32010         LDKChannelManager this_arg_conv;
32011         this_arg_conv.inner = untag_ptr(this_arg);
32012         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32014         this_arg_conv.is_owned = false;
32015         LDKPublicKey counterparty_node_id_ref;
32016         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
32017         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
32018         LDKCVec_ThirtyTwoBytesZ channel_ids_constr;
32019         channel_ids_constr.datalen = (*env)->GetArrayLength(env, channel_ids);
32020         if (channel_ids_constr.datalen > 0)
32021                 channel_ids_constr.data = MALLOC(channel_ids_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
32022         else
32023                 channel_ids_constr.data = NULL;
32024         for (size_t i = 0; i < channel_ids_constr.datalen; i++) {
32025                 int8_tArray channel_ids_conv_8 = (*env)->GetObjectArrayElement(env, channel_ids, i);
32026                 LDKThirtyTwoBytes channel_ids_conv_8_ref;
32027                 CHECK((*env)->GetArrayLength(env, channel_ids_conv_8) == 32);
32028                 (*env)->GetByteArrayRegion(env, channel_ids_conv_8, 0, 32, channel_ids_conv_8_ref.data);
32029                 channel_ids_constr.data[i] = channel_ids_conv_8_ref;
32030         }
32031         LDKChannelConfig config_conv;
32032         config_conv.inner = untag_ptr(config);
32033         config_conv.is_owned = ptr_is_owned(config);
32034         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
32035         config_conv.is_owned = false;
32036         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
32037         *ret_conv = ChannelManager_update_channel_config(&this_arg_conv, counterparty_node_id_ref, channel_ids_constr, &config_conv);
32038         return tag_ptr(ret_conv, true);
32039 }
32040
32041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
32042         LDKChannelManager this_arg_conv;
32043         this_arg_conv.inner = untag_ptr(this_arg);
32044         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32046         this_arg_conv.is_owned = false;
32047         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
32048 }
32049
32050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
32051         LDKChannelManager this_arg_conv;
32052         this_arg_conv.inner = untag_ptr(this_arg);
32053         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32055         this_arg_conv.is_owned = false;
32056         ChannelManager_timer_tick_occurred(&this_arg_conv);
32057 }
32058
32059 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
32060         LDKChannelManager this_arg_conv;
32061         this_arg_conv.inner = untag_ptr(this_arg);
32062         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32064         this_arg_conv.is_owned = false;
32065         unsigned char payment_hash_arr[32];
32066         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
32067         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
32068         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
32069         ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
32070 }
32071
32072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
32073         LDKChannelManager this_arg_conv;
32074         this_arg_conv.inner = untag_ptr(this_arg);
32075         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32077         this_arg_conv.is_owned = false;
32078         LDKThirtyTwoBytes payment_preimage_ref;
32079         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
32080         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
32081         ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
32082 }
32083
32084 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
32085         LDKChannelManager this_arg_conv;
32086         this_arg_conv.inner = untag_ptr(this_arg);
32087         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32089         this_arg_conv.is_owned = false;
32090         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32091         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
32092         return ret_arr;
32093 }
32094
32095 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) {
32096         LDKChannelManager this_arg_conv;
32097         this_arg_conv.inner = untag_ptr(this_arg);
32098         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32100         this_arg_conv.is_owned = false;
32101         unsigned char temporary_channel_id_arr[32];
32102         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
32103         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
32104         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
32105         LDKPublicKey counterparty_node_id_ref;
32106         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
32107         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
32108         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
32109         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
32110         return tag_ptr(ret_conv, true);
32111 }
32112
32113 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) {
32114         LDKChannelManager this_arg_conv;
32115         this_arg_conv.inner = untag_ptr(this_arg);
32116         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32118         this_arg_conv.is_owned = false;
32119         unsigned char temporary_channel_id_arr[32];
32120         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
32121         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
32122         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
32123         LDKPublicKey counterparty_node_id_ref;
32124         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
32125         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
32126         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
32127         *ret_conv = ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
32128         return tag_ptr(ret_conv, true);
32129 }
32130
32131 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) {
32132         LDKChannelManager this_arg_conv;
32133         this_arg_conv.inner = untag_ptr(this_arg);
32134         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32136         this_arg_conv.is_owned = false;
32137         void* min_value_msat_ptr = untag_ptr(min_value_msat);
32138         CHECK_ACCESS(min_value_msat_ptr);
32139         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
32140         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
32141         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
32142         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
32143         return tag_ptr(ret_conv, true);
32144 }
32145
32146 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) {
32147         LDKChannelManager this_arg_conv;
32148         this_arg_conv.inner = untag_ptr(this_arg);
32149         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32151         this_arg_conv.is_owned = false;
32152         void* min_value_msat_ptr = untag_ptr(min_value_msat);
32153         CHECK_ACCESS(min_value_msat_ptr);
32154         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
32155         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
32156         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
32157         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
32158         return tag_ptr(ret_conv, true);
32159 }
32160
32161 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) {
32162         LDKChannelManager this_arg_conv;
32163         this_arg_conv.inner = untag_ptr(this_arg);
32164         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32166         this_arg_conv.is_owned = false;
32167         LDKThirtyTwoBytes payment_hash_ref;
32168         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
32169         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
32170         void* min_value_msat_ptr = untag_ptr(min_value_msat);
32171         CHECK_ACCESS(min_value_msat_ptr);
32172         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
32173         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
32174         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
32175         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
32176         return tag_ptr(ret_conv, true);
32177 }
32178
32179 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) {
32180         LDKChannelManager this_arg_conv;
32181         this_arg_conv.inner = untag_ptr(this_arg);
32182         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32184         this_arg_conv.is_owned = false;
32185         LDKThirtyTwoBytes payment_hash_ref;
32186         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
32187         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
32188         void* min_value_msat_ptr = untag_ptr(min_value_msat);
32189         CHECK_ACCESS(min_value_msat_ptr);
32190         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
32191         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
32192         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
32193         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
32194         return tag_ptr(ret_conv, true);
32195 }
32196
32197 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) {
32198         LDKChannelManager this_arg_conv;
32199         this_arg_conv.inner = untag_ptr(this_arg);
32200         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32202         this_arg_conv.is_owned = false;
32203         LDKThirtyTwoBytes payment_hash_ref;
32204         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
32205         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
32206         LDKThirtyTwoBytes payment_secret_ref;
32207         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
32208         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
32209         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
32210         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
32211         return tag_ptr(ret_conv, true);
32212 }
32213
32214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
32215         LDKChannelManager this_arg_conv;
32216         this_arg_conv.inner = untag_ptr(this_arg);
32217         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32219         this_arg_conv.is_owned = false;
32220         int64_t ret_conv = ChannelManager_get_phantom_scid(&this_arg_conv);
32221         return ret_conv;
32222 }
32223
32224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
32225         LDKChannelManager this_arg_conv;
32226         this_arg_conv.inner = untag_ptr(this_arg);
32227         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32229         this_arg_conv.is_owned = false;
32230         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
32231         int64_t ret_ref = 0;
32232         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32233         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32234         return ret_ref;
32235 }
32236
32237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
32238         LDKChannelManager this_arg_conv;
32239         this_arg_conv.inner = untag_ptr(this_arg);
32240         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32242         this_arg_conv.is_owned = false;
32243         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
32244         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
32245         return tag_ptr(ret_ret, true);
32246 }
32247
32248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
32249         LDKChannelManager this_arg_conv;
32250         this_arg_conv.inner = untag_ptr(this_arg);
32251         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32253         this_arg_conv.is_owned = false;
32254         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
32255         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
32256         return tag_ptr(ret_ret, true);
32257 }
32258
32259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
32260         LDKChannelManager this_arg_conv;
32261         this_arg_conv.inner = untag_ptr(this_arg);
32262         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32264         this_arg_conv.is_owned = false;
32265         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
32266         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
32267         return tag_ptr(ret_ret, true);
32268 }
32269
32270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
32271         LDKChannelManager this_arg_conv;
32272         this_arg_conv.inner = untag_ptr(this_arg);
32273         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32275         this_arg_conv.is_owned = false;
32276         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
32277         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
32278         return tag_ptr(ret_ret, true);
32279 }
32280
32281 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) {
32282         LDKChannelManager this_arg_conv;
32283         this_arg_conv.inner = untag_ptr(this_arg);
32284         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32286         this_arg_conv.is_owned = false;
32287         jboolean ret_conv = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
32288         return ret_conv;
32289 }
32290
32291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
32292         LDKChannelManager this_arg_conv;
32293         this_arg_conv.inner = untag_ptr(this_arg);
32294         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32296         this_arg_conv.is_owned = false;
32297         ChannelManager_await_persistable_update(&this_arg_conv);
32298 }
32299
32300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1persistable_1update_1future(JNIEnv *env, jclass clz, int64_t this_arg) {
32301         LDKChannelManager this_arg_conv;
32302         this_arg_conv.inner = untag_ptr(this_arg);
32303         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32305         this_arg_conv.is_owned = false;
32306         LDKFuture ret_var = ChannelManager_get_persistable_update_future(&this_arg_conv);
32307         int64_t ret_ref = 0;
32308         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32309         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32310         return ret_ref;
32311 }
32312
32313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
32314         LDKChannelManager this_arg_conv;
32315         this_arg_conv.inner = untag_ptr(this_arg);
32316         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32318         this_arg_conv.is_owned = false;
32319         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
32320         int64_t ret_ref = 0;
32321         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32322         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32323         return ret_ref;
32324 }
32325
32326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
32327         LDKChannelManager this_arg_conv;
32328         this_arg_conv.inner = untag_ptr(this_arg);
32329         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32331         this_arg_conv.is_owned = false;
32332         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
32333         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
32334         return tag_ptr(ret_ret, true);
32335 }
32336
32337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_provided_1node_1features(JNIEnv *env, jclass clz) {
32338         LDKNodeFeatures ret_var = provided_node_features();
32339         int64_t ret_ref = 0;
32340         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32341         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32342         return ret_ref;
32343 }
32344
32345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_provided_1channel_1features(JNIEnv *env, jclass clz) {
32346         LDKChannelFeatures ret_var = provided_channel_features();
32347         int64_t ret_ref = 0;
32348         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32349         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32350         return ret_ref;
32351 }
32352
32353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_provided_1init_1features(JNIEnv *env, jclass clz) {
32354         LDKInitFeatures ret_var = provided_init_features();
32355         int64_t ret_ref = 0;
32356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32357         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32358         return ret_ref;
32359 }
32360
32361 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
32362         LDKCounterpartyForwardingInfo obj_conv;
32363         obj_conv.inner = untag_ptr(obj);
32364         obj_conv.is_owned = ptr_is_owned(obj);
32365         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32366         obj_conv.is_owned = false;
32367         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
32368         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32369         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32370         CVec_u8Z_free(ret_var);
32371         return ret_arr;
32372 }
32373
32374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32375         LDKu8slice ser_ref;
32376         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32377         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32378         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
32379         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
32380         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32381         return tag_ptr(ret_conv, true);
32382 }
32383
32384 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1write(JNIEnv *env, jclass clz, int64_t obj) {
32385         LDKChannelCounterparty obj_conv;
32386         obj_conv.inner = untag_ptr(obj);
32387         obj_conv.is_owned = ptr_is_owned(obj);
32388         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32389         obj_conv.is_owned = false;
32390         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
32391         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32392         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32393         CVec_u8Z_free(ret_var);
32394         return ret_arr;
32395 }
32396
32397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32398         LDKu8slice ser_ref;
32399         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32400         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32401         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
32402         *ret_conv = ChannelCounterparty_read(ser_ref);
32403         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32404         return tag_ptr(ret_conv, true);
32405 }
32406
32407 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1write(JNIEnv *env, jclass clz, int64_t obj) {
32408         LDKChannelDetails obj_conv;
32409         obj_conv.inner = untag_ptr(obj);
32410         obj_conv.is_owned = ptr_is_owned(obj);
32411         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32412         obj_conv.is_owned = false;
32413         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
32414         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32415         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32416         CVec_u8Z_free(ret_var);
32417         return ret_arr;
32418 }
32419
32420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32421         LDKu8slice ser_ref;
32422         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32423         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32424         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
32425         *ret_conv = ChannelDetails_read(ser_ref);
32426         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32427         return tag_ptr(ret_conv, true);
32428 }
32429
32430 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1write(JNIEnv *env, jclass clz, int64_t obj) {
32431         LDKPhantomRouteHints obj_conv;
32432         obj_conv.inner = untag_ptr(obj);
32433         obj_conv.is_owned = ptr_is_owned(obj);
32434         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32435         obj_conv.is_owned = false;
32436         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
32437         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32438         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32439         CVec_u8Z_free(ret_var);
32440         return ret_arr;
32441 }
32442
32443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32444         LDKu8slice ser_ref;
32445         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32446         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32447         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
32448         *ret_conv = PhantomRouteHints_read(ser_ref);
32449         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32450         return tag_ptr(ret_conv, true);
32451 }
32452
32453 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
32454         LDKChannelManager obj_conv;
32455         obj_conv.inner = untag_ptr(obj);
32456         obj_conv.is_owned = ptr_is_owned(obj);
32457         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32458         obj_conv.is_owned = false;
32459         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
32460         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32461         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32462         CVec_u8Z_free(ret_var);
32463         return ret_arr;
32464 }
32465
32466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32467         LDKChannelManagerReadArgs this_obj_conv;
32468         this_obj_conv.inner = untag_ptr(this_obj);
32469         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32471         ChannelManagerReadArgs_free(this_obj_conv);
32472 }
32473
32474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
32475         LDKChannelManagerReadArgs 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         // WARNING: This object doesn't live past this scope, needs clone!
32481         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv), false);
32482         return ret_ret;
32483 }
32484
32485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32486         LDKChannelManagerReadArgs this_ptr_conv;
32487         this_ptr_conv.inner = untag_ptr(this_ptr);
32488         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32490         this_ptr_conv.is_owned = false;
32491         void* val_ptr = untag_ptr(val);
32492         CHECK_ACCESS(val_ptr);
32493         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
32494         if (val_conv.free == LDKKeysInterface_JCalls_free) {
32495                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32496                 LDKKeysInterface_JCalls_cloned(&val_conv);
32497         }
32498         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
32499 }
32500
32501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
32502         LDKChannelManagerReadArgs this_ptr_conv;
32503         this_ptr_conv.inner = untag_ptr(this_ptr);
32504         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32506         this_ptr_conv.is_owned = false;
32507         // WARNING: This object doesn't live past this scope, needs clone!
32508         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv), false);
32509         return ret_ret;
32510 }
32511
32512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32513         LDKChannelManagerReadArgs this_ptr_conv;
32514         this_ptr_conv.inner = untag_ptr(this_ptr);
32515         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32517         this_ptr_conv.is_owned = false;
32518         void* val_ptr = untag_ptr(val);
32519         CHECK_ACCESS(val_ptr);
32520         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
32521         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
32522                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32523                 LDKFeeEstimator_JCalls_cloned(&val_conv);
32524         }
32525         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
32526 }
32527
32528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
32529         LDKChannelManagerReadArgs this_ptr_conv;
32530         this_ptr_conv.inner = untag_ptr(this_ptr);
32531         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32533         this_ptr_conv.is_owned = false;
32534         // WARNING: This object doesn't live past this scope, needs clone!
32535         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv), false);
32536         return ret_ret;
32537 }
32538
32539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32540         LDKChannelManagerReadArgs this_ptr_conv;
32541         this_ptr_conv.inner = untag_ptr(this_ptr);
32542         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32544         this_ptr_conv.is_owned = false;
32545         void* val_ptr = untag_ptr(val);
32546         CHECK_ACCESS(val_ptr);
32547         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
32548         if (val_conv.free == LDKWatch_JCalls_free) {
32549                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32550                 LDKWatch_JCalls_cloned(&val_conv);
32551         }
32552         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
32553 }
32554
32555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
32556         LDKChannelManagerReadArgs this_ptr_conv;
32557         this_ptr_conv.inner = untag_ptr(this_ptr);
32558         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32560         this_ptr_conv.is_owned = false;
32561         // WARNING: This object doesn't live past this scope, needs clone!
32562         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv), false);
32563         return ret_ret;
32564 }
32565
32566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32567         LDKChannelManagerReadArgs this_ptr_conv;
32568         this_ptr_conv.inner = untag_ptr(this_ptr);
32569         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32571         this_ptr_conv.is_owned = false;
32572         void* val_ptr = untag_ptr(val);
32573         CHECK_ACCESS(val_ptr);
32574         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
32575         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
32576                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32577                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
32578         }
32579         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
32580 }
32581
32582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
32583         LDKChannelManagerReadArgs this_ptr_conv;
32584         this_ptr_conv.inner = untag_ptr(this_ptr);
32585         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32587         this_ptr_conv.is_owned = false;
32588         // WARNING: This object doesn't live past this scope, needs clone!
32589         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_logger(&this_ptr_conv), false);
32590         return ret_ret;
32591 }
32592
32593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32594         LDKChannelManagerReadArgs this_ptr_conv;
32595         this_ptr_conv.inner = untag_ptr(this_ptr);
32596         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32598         this_ptr_conv.is_owned = false;
32599         void* val_ptr = untag_ptr(val);
32600         CHECK_ACCESS(val_ptr);
32601         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
32602         if (val_conv.free == LDKLogger_JCalls_free) {
32603                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32604                 LDKLogger_JCalls_cloned(&val_conv);
32605         }
32606         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
32607 }
32608
32609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
32610         LDKChannelManagerReadArgs this_ptr_conv;
32611         this_ptr_conv.inner = untag_ptr(this_ptr);
32612         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32614         this_ptr_conv.is_owned = false;
32615         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
32616         int64_t ret_ref = 0;
32617         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32618         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32619         return ret_ref;
32620 }
32621
32622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32623         LDKChannelManagerReadArgs this_ptr_conv;
32624         this_ptr_conv.inner = untag_ptr(this_ptr);
32625         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32627         this_ptr_conv.is_owned = false;
32628         LDKUserConfig val_conv;
32629         val_conv.inner = untag_ptr(val);
32630         val_conv.is_owned = ptr_is_owned(val);
32631         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32632         val_conv = UserConfig_clone(&val_conv);
32633         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
32634 }
32635
32636 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) {
32637         void* keys_manager_ptr = untag_ptr(keys_manager);
32638         CHECK_ACCESS(keys_manager_ptr);
32639         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
32640         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
32641                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32642                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
32643         }
32644         void* fee_estimator_ptr = untag_ptr(fee_estimator);
32645         CHECK_ACCESS(fee_estimator_ptr);
32646         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
32647         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
32648                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32649                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
32650         }
32651         void* chain_monitor_ptr = untag_ptr(chain_monitor);
32652         CHECK_ACCESS(chain_monitor_ptr);
32653         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
32654         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
32655                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32656                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
32657         }
32658         void* tx_broadcaster_ptr = untag_ptr(tx_broadcaster);
32659         CHECK_ACCESS(tx_broadcaster_ptr);
32660         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
32661         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
32662                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32663                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
32664         }
32665         void* logger_ptr = untag_ptr(logger);
32666         CHECK_ACCESS(logger_ptr);
32667         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
32668         if (logger_conv.free == LDKLogger_JCalls_free) {
32669                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32670                 LDKLogger_JCalls_cloned(&logger_conv);
32671         }
32672         LDKUserConfig default_config_conv;
32673         default_config_conv.inner = untag_ptr(default_config);
32674         default_config_conv.is_owned = ptr_is_owned(default_config);
32675         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
32676         default_config_conv = UserConfig_clone(&default_config_conv);
32677         LDKCVec_ChannelMonitorZ channel_monitors_constr;
32678         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
32679         if (channel_monitors_constr.datalen > 0)
32680                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
32681         else
32682                 channel_monitors_constr.data = NULL;
32683         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
32684         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
32685                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
32686                 LDKChannelMonitor channel_monitors_conv_16_conv;
32687                 channel_monitors_conv_16_conv.inner = untag_ptr(channel_monitors_conv_16);
32688                 channel_monitors_conv_16_conv.is_owned = ptr_is_owned(channel_monitors_conv_16);
32689                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
32690                 channel_monitors_conv_16_conv.is_owned = false;
32691                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
32692         }
32693         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
32694         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);
32695         int64_t ret_ref = 0;
32696         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32697         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32698         return ret_ref;
32699 }
32700
32701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
32702         LDKu8slice ser_ref;
32703         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32704         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32705         LDKChannelManagerReadArgs arg_conv;
32706         arg_conv.inner = untag_ptr(arg);
32707         arg_conv.is_owned = ptr_is_owned(arg);
32708         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32709         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
32710         
32711         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
32712         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
32713         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32714         return tag_ptr(ret_conv, true);
32715 }
32716
32717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32718         LDKExpandedKey this_obj_conv;
32719         this_obj_conv.inner = untag_ptr(this_obj);
32720         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32722         ExpandedKey_free(this_obj_conv);
32723 }
32724
32725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1new(JNIEnv *env, jclass clz, int8_tArray key_material) {
32726         unsigned char key_material_arr[32];
32727         CHECK((*env)->GetArrayLength(env, key_material) == 32);
32728         (*env)->GetByteArrayRegion(env, key_material, 0, 32, key_material_arr);
32729         unsigned char (*key_material_ref)[32] = &key_material_arr;
32730         LDKExpandedKey ret_var = ExpandedKey_new(key_material_ref);
32731         int64_t ret_ref = 0;
32732         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32733         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32734         return ret_ref;
32735 }
32736
32737 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) {
32738         LDKExpandedKey keys_conv;
32739         keys_conv.inner = untag_ptr(keys);
32740         keys_conv.is_owned = ptr_is_owned(keys);
32741         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
32742         keys_conv.is_owned = false;
32743         void* min_value_msat_ptr = untag_ptr(min_value_msat);
32744         CHECK_ACCESS(min_value_msat_ptr);
32745         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
32746         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
32747         void* keys_manager_ptr = untag_ptr(keys_manager);
32748         if (ptr_is_owned(keys_manager)) { CHECK_ACCESS(keys_manager_ptr); }
32749         LDKKeysInterface* keys_manager_conv = (LDKKeysInterface*)keys_manager_ptr;
32750         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
32751         *ret_conv = create(&keys_conv, min_value_msat_conv, invoice_expiry_delta_secs, keys_manager_conv, current_time);
32752         return tag_ptr(ret_conv, true);
32753 }
32754
32755 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) {
32756         LDKExpandedKey keys_conv;
32757         keys_conv.inner = untag_ptr(keys);
32758         keys_conv.is_owned = ptr_is_owned(keys);
32759         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
32760         keys_conv.is_owned = false;
32761         void* min_value_msat_ptr = untag_ptr(min_value_msat);
32762         CHECK_ACCESS(min_value_msat_ptr);
32763         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
32764         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
32765         LDKThirtyTwoBytes payment_hash_ref;
32766         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
32767         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
32768         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
32769         *ret_conv = create_from_hash(&keys_conv, min_value_msat_conv, payment_hash_ref, invoice_expiry_delta_secs, current_time);
32770         return tag_ptr(ret_conv, true);
32771 }
32772
32773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
32774         if (!ptr_is_owned(this_ptr)) return;
32775         void* this_ptr_ptr = untag_ptr(this_ptr);
32776         CHECK_ACCESS(this_ptr_ptr);
32777         LDKDecodeError this_ptr_conv = *(LDKDecodeError*)(this_ptr_ptr);
32778         FREE(untag_ptr(this_ptr));
32779         DecodeError_free(this_ptr_conv);
32780 }
32781
32782 static inline uint64_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
32783         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
32784         *ret_copy = DecodeError_clone(arg);
32785         int64_t ret_ref = tag_ptr(ret_copy, true);
32786         return ret_ref;
32787 }
32788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32789         LDKDecodeError* arg_conv = (LDKDecodeError*)untag_ptr(arg);
32790         int64_t ret_conv = DecodeError_clone_ptr(arg_conv);
32791         return ret_conv;
32792 }
32793
32794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32795         LDKDecodeError* orig_conv = (LDKDecodeError*)untag_ptr(orig);
32796         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
32797         *ret_copy = DecodeError_clone(orig_conv);
32798         int64_t ret_ref = tag_ptr(ret_copy, true);
32799         return ret_ref;
32800 }
32801
32802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1unknown_1version(JNIEnv *env, jclass clz) {
32803         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
32804         *ret_copy = DecodeError_unknown_version();
32805         int64_t ret_ref = tag_ptr(ret_copy, true);
32806         return ret_ref;
32807 }
32808
32809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1unknown_1required_1feature(JNIEnv *env, jclass clz) {
32810         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
32811         *ret_copy = DecodeError_unknown_required_feature();
32812         int64_t ret_ref = tag_ptr(ret_copy, true);
32813         return ret_ref;
32814 }
32815
32816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1invalid_1value(JNIEnv *env, jclass clz) {
32817         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
32818         *ret_copy = DecodeError_invalid_value();
32819         int64_t ret_ref = tag_ptr(ret_copy, true);
32820         return ret_ref;
32821 }
32822
32823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1short_1read(JNIEnv *env, jclass clz) {
32824         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
32825         *ret_copy = DecodeError_short_read();
32826         int64_t ret_ref = tag_ptr(ret_copy, true);
32827         return ret_ref;
32828 }
32829
32830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1bad_1length_1descriptor(JNIEnv *env, jclass clz) {
32831         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
32832         *ret_copy = DecodeError_bad_length_descriptor();
32833         int64_t ret_ref = tag_ptr(ret_copy, true);
32834         return ret_ref;
32835 }
32836
32837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1io(JNIEnv *env, jclass clz, jclass a) {
32838         LDKIOError a_conv = LDKIOError_from_java(env, a);
32839         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
32840         *ret_copy = DecodeError_io(a_conv);
32841         int64_t ret_ref = tag_ptr(ret_copy, true);
32842         return ret_ref;
32843 }
32844
32845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1unsupported_1compression(JNIEnv *env, jclass clz) {
32846         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
32847         *ret_copy = DecodeError_unsupported_compression();
32848         int64_t ret_ref = tag_ptr(ret_copy, true);
32849         return ret_ref;
32850 }
32851
32852 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DecodeError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
32853         LDKDecodeError* a_conv = (LDKDecodeError*)untag_ptr(a);
32854         LDKDecodeError* b_conv = (LDKDecodeError*)untag_ptr(b);
32855         jboolean ret_conv = DecodeError_eq(a_conv, b_conv);
32856         return ret_conv;
32857 }
32858
32859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32860         LDKInit this_obj_conv;
32861         this_obj_conv.inner = untag_ptr(this_obj);
32862         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32864         Init_free(this_obj_conv);
32865 }
32866
32867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
32868         LDKInit this_ptr_conv;
32869         this_ptr_conv.inner = untag_ptr(this_ptr);
32870         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32872         this_ptr_conv.is_owned = false;
32873         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
32874         int64_t ret_ref = 0;
32875         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32876         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32877         return ret_ref;
32878 }
32879
32880 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32881         LDKInit this_ptr_conv;
32882         this_ptr_conv.inner = untag_ptr(this_ptr);
32883         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32885         this_ptr_conv.is_owned = false;
32886         LDKInitFeatures val_conv;
32887         val_conv.inner = untag_ptr(val);
32888         val_conv.is_owned = ptr_is_owned(val);
32889         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32890         val_conv = InitFeatures_clone(&val_conv);
32891         Init_set_features(&this_ptr_conv, val_conv);
32892 }
32893
32894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr) {
32895         LDKInit this_ptr_conv;
32896         this_ptr_conv.inner = untag_ptr(this_ptr);
32897         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32899         this_ptr_conv.is_owned = false;
32900         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
32901         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
32902         int64_t ret_ref = tag_ptr(ret_copy, true);
32903         return ret_ref;
32904 }
32905
32906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32907         LDKInit this_ptr_conv;
32908         this_ptr_conv.inner = untag_ptr(this_ptr);
32909         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32911         this_ptr_conv.is_owned = false;
32912         void* val_ptr = untag_ptr(val);
32913         CHECK_ACCESS(val_ptr);
32914         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
32915         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)untag_ptr(val));
32916         Init_set_remote_network_address(&this_ptr_conv, val_conv);
32917 }
32918
32919 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) {
32920         LDKInitFeatures features_arg_conv;
32921         features_arg_conv.inner = untag_ptr(features_arg);
32922         features_arg_conv.is_owned = ptr_is_owned(features_arg);
32923         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
32924         features_arg_conv = InitFeatures_clone(&features_arg_conv);
32925         void* remote_network_address_arg_ptr = untag_ptr(remote_network_address_arg);
32926         CHECK_ACCESS(remote_network_address_arg_ptr);
32927         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
32928         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
32929         int64_t ret_ref = 0;
32930         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32931         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32932         return ret_ref;
32933 }
32934
32935 static inline uint64_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
32936         LDKInit ret_var = Init_clone(arg);
32937         int64_t ret_ref = 0;
32938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32939         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32940         return ret_ref;
32941 }
32942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32943         LDKInit arg_conv;
32944         arg_conv.inner = untag_ptr(arg);
32945         arg_conv.is_owned = ptr_is_owned(arg);
32946         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32947         arg_conv.is_owned = false;
32948         int64_t ret_conv = Init_clone_ptr(&arg_conv);
32949         return ret_conv;
32950 }
32951
32952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32953         LDKInit orig_conv;
32954         orig_conv.inner = untag_ptr(orig);
32955         orig_conv.is_owned = ptr_is_owned(orig);
32956         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32957         orig_conv.is_owned = false;
32958         LDKInit ret_var = Init_clone(&orig_conv);
32959         int64_t ret_ref = 0;
32960         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32961         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32962         return ret_ref;
32963 }
32964
32965 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Init_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
32966         LDKInit a_conv;
32967         a_conv.inner = untag_ptr(a);
32968         a_conv.is_owned = ptr_is_owned(a);
32969         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
32970         a_conv.is_owned = false;
32971         LDKInit b_conv;
32972         b_conv.inner = untag_ptr(b);
32973         b_conv.is_owned = ptr_is_owned(b);
32974         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
32975         b_conv.is_owned = false;
32976         jboolean ret_conv = Init_eq(&a_conv, &b_conv);
32977         return ret_conv;
32978 }
32979
32980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32981         LDKErrorMessage this_obj_conv;
32982         this_obj_conv.inner = untag_ptr(this_obj);
32983         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32985         ErrorMessage_free(this_obj_conv);
32986 }
32987
32988 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32989         LDKErrorMessage this_ptr_conv;
32990         this_ptr_conv.inner = untag_ptr(this_ptr);
32991         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32993         this_ptr_conv.is_owned = false;
32994         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32995         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
32996         return ret_arr;
32997 }
32998
32999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33000         LDKErrorMessage this_ptr_conv;
33001         this_ptr_conv.inner = untag_ptr(this_ptr);
33002         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33004         this_ptr_conv.is_owned = false;
33005         LDKThirtyTwoBytes val_ref;
33006         CHECK((*env)->GetArrayLength(env, val) == 32);
33007         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33008         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
33009 }
33010
33011 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
33012         LDKErrorMessage this_ptr_conv;
33013         this_ptr_conv.inner = untag_ptr(this_ptr);
33014         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33016         this_ptr_conv.is_owned = false;
33017         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
33018         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
33019         Str_free(ret_str);
33020         return ret_conv;
33021 }
33022
33023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
33024         LDKErrorMessage this_ptr_conv;
33025         this_ptr_conv.inner = untag_ptr(this_ptr);
33026         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33028         this_ptr_conv.is_owned = false;
33029         LDKStr val_conv = java_to_owned_str(env, val);
33030         ErrorMessage_set_data(&this_ptr_conv, val_conv);
33031 }
33032
33033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
33034         LDKThirtyTwoBytes channel_id_arg_ref;
33035         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33036         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33037         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
33038         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
33039         int64_t ret_ref = 0;
33040         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33041         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33042         return ret_ref;
33043 }
33044
33045 static inline uint64_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
33046         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
33047         int64_t ret_ref = 0;
33048         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33049         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33050         return ret_ref;
33051 }
33052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33053         LDKErrorMessage arg_conv;
33054         arg_conv.inner = untag_ptr(arg);
33055         arg_conv.is_owned = ptr_is_owned(arg);
33056         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33057         arg_conv.is_owned = false;
33058         int64_t ret_conv = ErrorMessage_clone_ptr(&arg_conv);
33059         return ret_conv;
33060 }
33061
33062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33063         LDKErrorMessage orig_conv;
33064         orig_conv.inner = untag_ptr(orig);
33065         orig_conv.is_owned = ptr_is_owned(orig);
33066         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33067         orig_conv.is_owned = false;
33068         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
33069         int64_t ret_ref = 0;
33070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33071         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33072         return ret_ref;
33073 }
33074
33075 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
33076         LDKErrorMessage a_conv;
33077         a_conv.inner = untag_ptr(a);
33078         a_conv.is_owned = ptr_is_owned(a);
33079         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33080         a_conv.is_owned = false;
33081         LDKErrorMessage b_conv;
33082         b_conv.inner = untag_ptr(b);
33083         b_conv.is_owned = ptr_is_owned(b);
33084         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33085         b_conv.is_owned = false;
33086         jboolean ret_conv = ErrorMessage_eq(&a_conv, &b_conv);
33087         return ret_conv;
33088 }
33089
33090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33091         LDKWarningMessage this_obj_conv;
33092         this_obj_conv.inner = untag_ptr(this_obj);
33093         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33095         WarningMessage_free(this_obj_conv);
33096 }
33097
33098 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33099         LDKWarningMessage this_ptr_conv;
33100         this_ptr_conv.inner = untag_ptr(this_ptr);
33101         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33103         this_ptr_conv.is_owned = false;
33104         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33105         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *WarningMessage_get_channel_id(&this_ptr_conv));
33106         return ret_arr;
33107 }
33108
33109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33110         LDKWarningMessage this_ptr_conv;
33111         this_ptr_conv.inner = untag_ptr(this_ptr);
33112         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33114         this_ptr_conv.is_owned = false;
33115         LDKThirtyTwoBytes val_ref;
33116         CHECK((*env)->GetArrayLength(env, val) == 32);
33117         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33118         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
33119 }
33120
33121 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
33122         LDKWarningMessage this_ptr_conv;
33123         this_ptr_conv.inner = untag_ptr(this_ptr);
33124         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33126         this_ptr_conv.is_owned = false;
33127         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
33128         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
33129         Str_free(ret_str);
33130         return ret_conv;
33131 }
33132
33133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
33134         LDKWarningMessage this_ptr_conv;
33135         this_ptr_conv.inner = untag_ptr(this_ptr);
33136         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33138         this_ptr_conv.is_owned = false;
33139         LDKStr val_conv = java_to_owned_str(env, val);
33140         WarningMessage_set_data(&this_ptr_conv, val_conv);
33141 }
33142
33143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
33144         LDKThirtyTwoBytes channel_id_arg_ref;
33145         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33146         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33147         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
33148         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
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
33155 static inline uint64_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
33156         LDKWarningMessage ret_var = WarningMessage_clone(arg);
33157         int64_t ret_ref = 0;
33158         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33159         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33160         return ret_ref;
33161 }
33162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33163         LDKWarningMessage arg_conv;
33164         arg_conv.inner = untag_ptr(arg);
33165         arg_conv.is_owned = ptr_is_owned(arg);
33166         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33167         arg_conv.is_owned = false;
33168         int64_t ret_conv = WarningMessage_clone_ptr(&arg_conv);
33169         return ret_conv;
33170 }
33171
33172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33173         LDKWarningMessage orig_conv;
33174         orig_conv.inner = untag_ptr(orig);
33175         orig_conv.is_owned = ptr_is_owned(orig);
33176         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33177         orig_conv.is_owned = false;
33178         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
33179         int64_t ret_ref = 0;
33180         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33181         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33182         return ret_ref;
33183 }
33184
33185 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_WarningMessage_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
33186         LDKWarningMessage a_conv;
33187         a_conv.inner = untag_ptr(a);
33188         a_conv.is_owned = ptr_is_owned(a);
33189         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33190         a_conv.is_owned = false;
33191         LDKWarningMessage b_conv;
33192         b_conv.inner = untag_ptr(b);
33193         b_conv.is_owned = ptr_is_owned(b);
33194         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33195         b_conv.is_owned = false;
33196         jboolean ret_conv = WarningMessage_eq(&a_conv, &b_conv);
33197         return ret_conv;
33198 }
33199
33200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33201         LDKPing this_obj_conv;
33202         this_obj_conv.inner = untag_ptr(this_obj);
33203         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33205         Ping_free(this_obj_conv);
33206 }
33207
33208 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
33209         LDKPing 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         int16_t ret_conv = Ping_get_ponglen(&this_ptr_conv);
33215         return ret_conv;
33216 }
33217
33218 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
33219         LDKPing this_ptr_conv;
33220         this_ptr_conv.inner = untag_ptr(this_ptr);
33221         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33223         this_ptr_conv.is_owned = false;
33224         Ping_set_ponglen(&this_ptr_conv, val);
33225 }
33226
33227 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
33228         LDKPing this_ptr_conv;
33229         this_ptr_conv.inner = untag_ptr(this_ptr);
33230         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33232         this_ptr_conv.is_owned = false;
33233         int16_t ret_conv = Ping_get_byteslen(&this_ptr_conv);
33234         return ret_conv;
33235 }
33236
33237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
33238         LDKPing this_ptr_conv;
33239         this_ptr_conv.inner = untag_ptr(this_ptr);
33240         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33242         this_ptr_conv.is_owned = false;
33243         Ping_set_byteslen(&this_ptr_conv, val);
33244 }
33245
33246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
33247         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
33248         int64_t ret_ref = 0;
33249         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33250         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33251         return ret_ref;
33252 }
33253
33254 static inline uint64_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
33255         LDKPing ret_var = Ping_clone(arg);
33256         int64_t ret_ref = 0;
33257         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33258         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33259         return ret_ref;
33260 }
33261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33262         LDKPing arg_conv;
33263         arg_conv.inner = untag_ptr(arg);
33264         arg_conv.is_owned = ptr_is_owned(arg);
33265         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33266         arg_conv.is_owned = false;
33267         int64_t ret_conv = Ping_clone_ptr(&arg_conv);
33268         return ret_conv;
33269 }
33270
33271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33272         LDKPing orig_conv;
33273         orig_conv.inner = untag_ptr(orig);
33274         orig_conv.is_owned = ptr_is_owned(orig);
33275         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33276         orig_conv.is_owned = false;
33277         LDKPing ret_var = Ping_clone(&orig_conv);
33278         int64_t ret_ref = 0;
33279         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33280         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33281         return ret_ref;
33282 }
33283
33284 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Ping_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
33285         LDKPing a_conv;
33286         a_conv.inner = untag_ptr(a);
33287         a_conv.is_owned = ptr_is_owned(a);
33288         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33289         a_conv.is_owned = false;
33290         LDKPing b_conv;
33291         b_conv.inner = untag_ptr(b);
33292         b_conv.is_owned = ptr_is_owned(b);
33293         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33294         b_conv.is_owned = false;
33295         jboolean ret_conv = Ping_eq(&a_conv, &b_conv);
33296         return ret_conv;
33297 }
33298
33299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33300         LDKPong this_obj_conv;
33301         this_obj_conv.inner = untag_ptr(this_obj);
33302         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33304         Pong_free(this_obj_conv);
33305 }
33306
33307 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
33308         LDKPong this_ptr_conv;
33309         this_ptr_conv.inner = untag_ptr(this_ptr);
33310         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33312         this_ptr_conv.is_owned = false;
33313         int16_t ret_conv = Pong_get_byteslen(&this_ptr_conv);
33314         return ret_conv;
33315 }
33316
33317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
33318         LDKPong this_ptr_conv;
33319         this_ptr_conv.inner = untag_ptr(this_ptr);
33320         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33322         this_ptr_conv.is_owned = false;
33323         Pong_set_byteslen(&this_ptr_conv, val);
33324 }
33325
33326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
33327         LDKPong ret_var = Pong_new(byteslen_arg);
33328         int64_t ret_ref = 0;
33329         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33330         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33331         return ret_ref;
33332 }
33333
33334 static inline uint64_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
33335         LDKPong ret_var = Pong_clone(arg);
33336         int64_t ret_ref = 0;
33337         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33338         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33339         return ret_ref;
33340 }
33341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33342         LDKPong arg_conv;
33343         arg_conv.inner = untag_ptr(arg);
33344         arg_conv.is_owned = ptr_is_owned(arg);
33345         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33346         arg_conv.is_owned = false;
33347         int64_t ret_conv = Pong_clone_ptr(&arg_conv);
33348         return ret_conv;
33349 }
33350
33351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33352         LDKPong orig_conv;
33353         orig_conv.inner = untag_ptr(orig);
33354         orig_conv.is_owned = ptr_is_owned(orig);
33355         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33356         orig_conv.is_owned = false;
33357         LDKPong ret_var = Pong_clone(&orig_conv);
33358         int64_t ret_ref = 0;
33359         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33360         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33361         return ret_ref;
33362 }
33363
33364 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Pong_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
33365         LDKPong a_conv;
33366         a_conv.inner = untag_ptr(a);
33367         a_conv.is_owned = ptr_is_owned(a);
33368         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33369         a_conv.is_owned = false;
33370         LDKPong b_conv;
33371         b_conv.inner = untag_ptr(b);
33372         b_conv.is_owned = ptr_is_owned(b);
33373         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33374         b_conv.is_owned = false;
33375         jboolean ret_conv = Pong_eq(&a_conv, &b_conv);
33376         return ret_conv;
33377 }
33378
33379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33380         LDKOpenChannel this_obj_conv;
33381         this_obj_conv.inner = untag_ptr(this_obj);
33382         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33384         OpenChannel_free(this_obj_conv);
33385 }
33386
33387 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
33388         LDKOpenChannel this_ptr_conv;
33389         this_ptr_conv.inner = untag_ptr(this_ptr);
33390         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33392         this_ptr_conv.is_owned = false;
33393         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33394         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
33395         return ret_arr;
33396 }
33397
33398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33399         LDKOpenChannel this_ptr_conv;
33400         this_ptr_conv.inner = untag_ptr(this_ptr);
33401         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33403         this_ptr_conv.is_owned = false;
33404         LDKThirtyTwoBytes val_ref;
33405         CHECK((*env)->GetArrayLength(env, val) == 32);
33406         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33407         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
33408 }
33409
33410 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33411         LDKOpenChannel this_ptr_conv;
33412         this_ptr_conv.inner = untag_ptr(this_ptr);
33413         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33415         this_ptr_conv.is_owned = false;
33416         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33417         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
33418         return ret_arr;
33419 }
33420
33421 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33422         LDKOpenChannel this_ptr_conv;
33423         this_ptr_conv.inner = untag_ptr(this_ptr);
33424         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33426         this_ptr_conv.is_owned = false;
33427         LDKThirtyTwoBytes val_ref;
33428         CHECK((*env)->GetArrayLength(env, val) == 32);
33429         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33430         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
33431 }
33432
33433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
33434         LDKOpenChannel this_ptr_conv;
33435         this_ptr_conv.inner = untag_ptr(this_ptr);
33436         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33438         this_ptr_conv.is_owned = false;
33439         int64_t ret_conv = OpenChannel_get_funding_satoshis(&this_ptr_conv);
33440         return ret_conv;
33441 }
33442
33443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33444         LDKOpenChannel this_ptr_conv;
33445         this_ptr_conv.inner = untag_ptr(this_ptr);
33446         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33448         this_ptr_conv.is_owned = false;
33449         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
33450 }
33451
33452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
33453         LDKOpenChannel this_ptr_conv;
33454         this_ptr_conv.inner = untag_ptr(this_ptr);
33455         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33457         this_ptr_conv.is_owned = false;
33458         int64_t ret_conv = OpenChannel_get_push_msat(&this_ptr_conv);
33459         return ret_conv;
33460 }
33461
33462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33463         LDKOpenChannel this_ptr_conv;
33464         this_ptr_conv.inner = untag_ptr(this_ptr);
33465         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33467         this_ptr_conv.is_owned = false;
33468         OpenChannel_set_push_msat(&this_ptr_conv, val);
33469 }
33470
33471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
33472         LDKOpenChannel this_ptr_conv;
33473         this_ptr_conv.inner = untag_ptr(this_ptr);
33474         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33476         this_ptr_conv.is_owned = false;
33477         int64_t ret_conv = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
33478         return ret_conv;
33479 }
33480
33481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33482         LDKOpenChannel this_ptr_conv;
33483         this_ptr_conv.inner = untag_ptr(this_ptr);
33484         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33486         this_ptr_conv.is_owned = false;
33487         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
33488 }
33489
33490 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) {
33491         LDKOpenChannel this_ptr_conv;
33492         this_ptr_conv.inner = untag_ptr(this_ptr);
33493         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33495         this_ptr_conv.is_owned = false;
33496         int64_t ret_conv = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
33497         return ret_conv;
33498 }
33499
33500 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) {
33501         LDKOpenChannel this_ptr_conv;
33502         this_ptr_conv.inner = untag_ptr(this_ptr);
33503         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33505         this_ptr_conv.is_owned = false;
33506         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
33507 }
33508
33509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
33510         LDKOpenChannel this_ptr_conv;
33511         this_ptr_conv.inner = untag_ptr(this_ptr);
33512         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33514         this_ptr_conv.is_owned = false;
33515         int64_t ret_conv = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
33516         return ret_conv;
33517 }
33518
33519 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33520         LDKOpenChannel this_ptr_conv;
33521         this_ptr_conv.inner = untag_ptr(this_ptr);
33522         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33524         this_ptr_conv.is_owned = false;
33525         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
33526 }
33527
33528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
33529         LDKOpenChannel this_ptr_conv;
33530         this_ptr_conv.inner = untag_ptr(this_ptr);
33531         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33533         this_ptr_conv.is_owned = false;
33534         int64_t ret_conv = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
33535         return ret_conv;
33536 }
33537
33538 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33539         LDKOpenChannel this_ptr_conv;
33540         this_ptr_conv.inner = untag_ptr(this_ptr);
33541         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33543         this_ptr_conv.is_owned = false;
33544         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
33545 }
33546
33547 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
33548         LDKOpenChannel this_ptr_conv;
33549         this_ptr_conv.inner = untag_ptr(this_ptr);
33550         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33552         this_ptr_conv.is_owned = false;
33553         int32_t ret_conv = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
33554         return ret_conv;
33555 }
33556
33557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33558         LDKOpenChannel this_ptr_conv;
33559         this_ptr_conv.inner = untag_ptr(this_ptr);
33560         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33562         this_ptr_conv.is_owned = false;
33563         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
33564 }
33565
33566 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
33567         LDKOpenChannel this_ptr_conv;
33568         this_ptr_conv.inner = untag_ptr(this_ptr);
33569         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33571         this_ptr_conv.is_owned = false;
33572         int16_t ret_conv = OpenChannel_get_to_self_delay(&this_ptr_conv);
33573         return ret_conv;
33574 }
33575
33576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
33577         LDKOpenChannel this_ptr_conv;
33578         this_ptr_conv.inner = untag_ptr(this_ptr);
33579         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33581         this_ptr_conv.is_owned = false;
33582         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
33583 }
33584
33585 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
33586         LDKOpenChannel this_ptr_conv;
33587         this_ptr_conv.inner = untag_ptr(this_ptr);
33588         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33590         this_ptr_conv.is_owned = false;
33591         int16_t ret_conv = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
33592         return ret_conv;
33593 }
33594
33595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
33596         LDKOpenChannel this_ptr_conv;
33597         this_ptr_conv.inner = untag_ptr(this_ptr);
33598         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33600         this_ptr_conv.is_owned = false;
33601         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
33602 }
33603
33604 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
33605         LDKOpenChannel this_ptr_conv;
33606         this_ptr_conv.inner = untag_ptr(this_ptr);
33607         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33609         this_ptr_conv.is_owned = false;
33610         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33611         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
33612         return ret_arr;
33613 }
33614
33615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33616         LDKOpenChannel this_ptr_conv;
33617         this_ptr_conv.inner = untag_ptr(this_ptr);
33618         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33620         this_ptr_conv.is_owned = false;
33621         LDKPublicKey val_ref;
33622         CHECK((*env)->GetArrayLength(env, val) == 33);
33623         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33624         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
33625 }
33626
33627 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
33628         LDKOpenChannel this_ptr_conv;
33629         this_ptr_conv.inner = untag_ptr(this_ptr);
33630         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33632         this_ptr_conv.is_owned = false;
33633         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33634         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
33635         return ret_arr;
33636 }
33637
33638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33639         LDKOpenChannel 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         LDKPublicKey val_ref;
33645         CHECK((*env)->GetArrayLength(env, val) == 33);
33646         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33647         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
33648 }
33649
33650 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
33651         LDKOpenChannel this_ptr_conv;
33652         this_ptr_conv.inner = untag_ptr(this_ptr);
33653         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33655         this_ptr_conv.is_owned = false;
33656         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33657         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
33658         return ret_arr;
33659 }
33660
33661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33662         LDKOpenChannel this_ptr_conv;
33663         this_ptr_conv.inner = untag_ptr(this_ptr);
33664         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33666         this_ptr_conv.is_owned = false;
33667         LDKPublicKey val_ref;
33668         CHECK((*env)->GetArrayLength(env, val) == 33);
33669         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33670         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
33671 }
33672
33673 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
33674         LDKOpenChannel this_ptr_conv;
33675         this_ptr_conv.inner = untag_ptr(this_ptr);
33676         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33678         this_ptr_conv.is_owned = false;
33679         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33680         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
33681         return ret_arr;
33682 }
33683
33684 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33685         LDKOpenChannel this_ptr_conv;
33686         this_ptr_conv.inner = untag_ptr(this_ptr);
33687         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33689         this_ptr_conv.is_owned = false;
33690         LDKPublicKey val_ref;
33691         CHECK((*env)->GetArrayLength(env, val) == 33);
33692         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33693         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
33694 }
33695
33696 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
33697         LDKOpenChannel this_ptr_conv;
33698         this_ptr_conv.inner = untag_ptr(this_ptr);
33699         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33701         this_ptr_conv.is_owned = false;
33702         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33703         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
33704         return ret_arr;
33705 }
33706
33707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33708         LDKOpenChannel this_ptr_conv;
33709         this_ptr_conv.inner = untag_ptr(this_ptr);
33710         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33712         this_ptr_conv.is_owned = false;
33713         LDKPublicKey val_ref;
33714         CHECK((*env)->GetArrayLength(env, val) == 33);
33715         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33716         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
33717 }
33718
33719 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
33720         LDKOpenChannel this_ptr_conv;
33721         this_ptr_conv.inner = untag_ptr(this_ptr);
33722         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33724         this_ptr_conv.is_owned = false;
33725         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33726         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
33727         return ret_arr;
33728 }
33729
33730 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) {
33731         LDKOpenChannel this_ptr_conv;
33732         this_ptr_conv.inner = untag_ptr(this_ptr);
33733         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33735         this_ptr_conv.is_owned = false;
33736         LDKPublicKey val_ref;
33737         CHECK((*env)->GetArrayLength(env, val) == 33);
33738         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33739         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
33740 }
33741
33742 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
33743         LDKOpenChannel this_ptr_conv;
33744         this_ptr_conv.inner = untag_ptr(this_ptr);
33745         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33747         this_ptr_conv.is_owned = false;
33748         int8_t ret_conv = OpenChannel_get_channel_flags(&this_ptr_conv);
33749         return ret_conv;
33750 }
33751
33752 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
33753         LDKOpenChannel this_ptr_conv;
33754         this_ptr_conv.inner = untag_ptr(this_ptr);
33755         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33757         this_ptr_conv.is_owned = false;
33758         OpenChannel_set_channel_flags(&this_ptr_conv, val);
33759 }
33760
33761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
33762         LDKOpenChannel 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         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
33768         int64_t ret_ref = 0;
33769         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33770         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33771         return ret_ref;
33772 }
33773
33774 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33775         LDKOpenChannel this_ptr_conv;
33776         this_ptr_conv.inner = untag_ptr(this_ptr);
33777         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33779         this_ptr_conv.is_owned = false;
33780         LDKChannelTypeFeatures val_conv;
33781         val_conv.inner = untag_ptr(val);
33782         val_conv.is_owned = ptr_is_owned(val);
33783         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33784         val_conv = ChannelTypeFeatures_clone(&val_conv);
33785         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
33786 }
33787
33788 static inline uint64_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
33789         LDKOpenChannel ret_var = OpenChannel_clone(arg);
33790         int64_t ret_ref = 0;
33791         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33792         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33793         return ret_ref;
33794 }
33795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33796         LDKOpenChannel arg_conv;
33797         arg_conv.inner = untag_ptr(arg);
33798         arg_conv.is_owned = ptr_is_owned(arg);
33799         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33800         arg_conv.is_owned = false;
33801         int64_t ret_conv = OpenChannel_clone_ptr(&arg_conv);
33802         return ret_conv;
33803 }
33804
33805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33806         LDKOpenChannel orig_conv;
33807         orig_conv.inner = untag_ptr(orig);
33808         orig_conv.is_owned = ptr_is_owned(orig);
33809         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33810         orig_conv.is_owned = false;
33811         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
33812         int64_t ret_ref = 0;
33813         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33814         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33815         return ret_ref;
33816 }
33817
33818 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OpenChannel_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
33819         LDKOpenChannel a_conv;
33820         a_conv.inner = untag_ptr(a);
33821         a_conv.is_owned = ptr_is_owned(a);
33822         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33823         a_conv.is_owned = false;
33824         LDKOpenChannel b_conv;
33825         b_conv.inner = untag_ptr(b);
33826         b_conv.is_owned = ptr_is_owned(b);
33827         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33828         b_conv.is_owned = false;
33829         jboolean ret_conv = OpenChannel_eq(&a_conv, &b_conv);
33830         return ret_conv;
33831 }
33832
33833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33834         LDKAcceptChannel this_obj_conv;
33835         this_obj_conv.inner = untag_ptr(this_obj);
33836         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33838         AcceptChannel_free(this_obj_conv);
33839 }
33840
33841 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33842         LDKAcceptChannel this_ptr_conv;
33843         this_ptr_conv.inner = untag_ptr(this_ptr);
33844         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33846         this_ptr_conv.is_owned = false;
33847         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33848         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
33849         return ret_arr;
33850 }
33851
33852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33853         LDKAcceptChannel this_ptr_conv;
33854         this_ptr_conv.inner = untag_ptr(this_ptr);
33855         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33857         this_ptr_conv.is_owned = false;
33858         LDKThirtyTwoBytes val_ref;
33859         CHECK((*env)->GetArrayLength(env, val) == 32);
33860         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33861         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
33862 }
33863
33864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
33865         LDKAcceptChannel this_ptr_conv;
33866         this_ptr_conv.inner = untag_ptr(this_ptr);
33867         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33869         this_ptr_conv.is_owned = false;
33870         int64_t ret_conv = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
33871         return ret_conv;
33872 }
33873
33874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33875         LDKAcceptChannel this_ptr_conv;
33876         this_ptr_conv.inner = untag_ptr(this_ptr);
33877         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33879         this_ptr_conv.is_owned = false;
33880         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
33881 }
33882
33883 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) {
33884         LDKAcceptChannel this_ptr_conv;
33885         this_ptr_conv.inner = untag_ptr(this_ptr);
33886         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33888         this_ptr_conv.is_owned = false;
33889         int64_t ret_conv = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
33890         return ret_conv;
33891 }
33892
33893 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) {
33894         LDKAcceptChannel this_ptr_conv;
33895         this_ptr_conv.inner = untag_ptr(this_ptr);
33896         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33898         this_ptr_conv.is_owned = false;
33899         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
33900 }
33901
33902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
33903         LDKAcceptChannel this_ptr_conv;
33904         this_ptr_conv.inner = untag_ptr(this_ptr);
33905         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33907         this_ptr_conv.is_owned = false;
33908         int64_t ret_conv = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
33909         return ret_conv;
33910 }
33911
33912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33913         LDKAcceptChannel this_ptr_conv;
33914         this_ptr_conv.inner = untag_ptr(this_ptr);
33915         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33917         this_ptr_conv.is_owned = false;
33918         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
33919 }
33920
33921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
33922         LDKAcceptChannel this_ptr_conv;
33923         this_ptr_conv.inner = untag_ptr(this_ptr);
33924         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33926         this_ptr_conv.is_owned = false;
33927         int64_t ret_conv = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
33928         return ret_conv;
33929 }
33930
33931 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33932         LDKAcceptChannel this_ptr_conv;
33933         this_ptr_conv.inner = untag_ptr(this_ptr);
33934         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33936         this_ptr_conv.is_owned = false;
33937         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
33938 }
33939
33940 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
33941         LDKAcceptChannel this_ptr_conv;
33942         this_ptr_conv.inner = untag_ptr(this_ptr);
33943         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33945         this_ptr_conv.is_owned = false;
33946         int32_t ret_conv = AcceptChannel_get_minimum_depth(&this_ptr_conv);
33947         return ret_conv;
33948 }
33949
33950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33951         LDKAcceptChannel this_ptr_conv;
33952         this_ptr_conv.inner = untag_ptr(this_ptr);
33953         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33955         this_ptr_conv.is_owned = false;
33956         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
33957 }
33958
33959 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
33960         LDKAcceptChannel this_ptr_conv;
33961         this_ptr_conv.inner = untag_ptr(this_ptr);
33962         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33964         this_ptr_conv.is_owned = false;
33965         int16_t ret_conv = AcceptChannel_get_to_self_delay(&this_ptr_conv);
33966         return ret_conv;
33967 }
33968
33969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
33970         LDKAcceptChannel this_ptr_conv;
33971         this_ptr_conv.inner = untag_ptr(this_ptr);
33972         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33974         this_ptr_conv.is_owned = false;
33975         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
33976 }
33977
33978 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
33979         LDKAcceptChannel 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         int16_t ret_conv = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
33985         return ret_conv;
33986 }
33987
33988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
33989         LDKAcceptChannel 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         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
33995 }
33996
33997 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
33998         LDKAcceptChannel 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, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
34005         return ret_arr;
34006 }
34007
34008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34009         LDKAcceptChannel 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         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
34018 }
34019
34020 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
34021         LDKAcceptChannel 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, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
34028         return ret_arr;
34029 }
34030
34031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34032         LDKAcceptChannel 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         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
34041 }
34042
34043 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
34044         LDKAcceptChannel 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, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
34051         return ret_arr;
34052 }
34053
34054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34055         LDKAcceptChannel 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         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
34064 }
34065
34066 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
34067         LDKAcceptChannel 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, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
34074         return ret_arr;
34075 }
34076
34077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34078         LDKAcceptChannel 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         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
34087 }
34088
34089 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
34090         LDKAcceptChannel this_ptr_conv;
34091         this_ptr_conv.inner = untag_ptr(this_ptr);
34092         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34094         this_ptr_conv.is_owned = false;
34095         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34096         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
34097         return ret_arr;
34098 }
34099
34100 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34101         LDKAcceptChannel this_ptr_conv;
34102         this_ptr_conv.inner = untag_ptr(this_ptr);
34103         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34105         this_ptr_conv.is_owned = false;
34106         LDKPublicKey val_ref;
34107         CHECK((*env)->GetArrayLength(env, val) == 33);
34108         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34109         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
34110 }
34111
34112 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
34113         LDKAcceptChannel this_ptr_conv;
34114         this_ptr_conv.inner = untag_ptr(this_ptr);
34115         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34117         this_ptr_conv.is_owned = false;
34118         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34119         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
34120         return ret_arr;
34121 }
34122
34123 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) {
34124         LDKAcceptChannel this_ptr_conv;
34125         this_ptr_conv.inner = untag_ptr(this_ptr);
34126         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34128         this_ptr_conv.is_owned = false;
34129         LDKPublicKey val_ref;
34130         CHECK((*env)->GetArrayLength(env, val) == 33);
34131         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34132         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
34133 }
34134
34135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
34136         LDKAcceptChannel this_ptr_conv;
34137         this_ptr_conv.inner = untag_ptr(this_ptr);
34138         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34140         this_ptr_conv.is_owned = false;
34141         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
34142         int64_t ret_ref = 0;
34143         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34144         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34145         return ret_ref;
34146 }
34147
34148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34149         LDKAcceptChannel this_ptr_conv;
34150         this_ptr_conv.inner = untag_ptr(this_ptr);
34151         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34153         this_ptr_conv.is_owned = false;
34154         LDKChannelTypeFeatures val_conv;
34155         val_conv.inner = untag_ptr(val);
34156         val_conv.is_owned = ptr_is_owned(val);
34157         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34158         val_conv = ChannelTypeFeatures_clone(&val_conv);
34159         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
34160 }
34161
34162 static inline uint64_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
34163         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
34164         int64_t ret_ref = 0;
34165         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34166         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34167         return ret_ref;
34168 }
34169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34170         LDKAcceptChannel arg_conv;
34171         arg_conv.inner = untag_ptr(arg);
34172         arg_conv.is_owned = ptr_is_owned(arg);
34173         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34174         arg_conv.is_owned = false;
34175         int64_t ret_conv = AcceptChannel_clone_ptr(&arg_conv);
34176         return ret_conv;
34177 }
34178
34179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34180         LDKAcceptChannel orig_conv;
34181         orig_conv.inner = untag_ptr(orig);
34182         orig_conv.is_owned = ptr_is_owned(orig);
34183         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34184         orig_conv.is_owned = false;
34185         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
34186         int64_t ret_ref = 0;
34187         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34188         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34189         return ret_ref;
34190 }
34191
34192 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34193         LDKAcceptChannel a_conv;
34194         a_conv.inner = untag_ptr(a);
34195         a_conv.is_owned = ptr_is_owned(a);
34196         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34197         a_conv.is_owned = false;
34198         LDKAcceptChannel b_conv;
34199         b_conv.inner = untag_ptr(b);
34200         b_conv.is_owned = ptr_is_owned(b);
34201         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34202         b_conv.is_owned = false;
34203         jboolean ret_conv = AcceptChannel_eq(&a_conv, &b_conv);
34204         return ret_conv;
34205 }
34206
34207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34208         LDKFundingCreated this_obj_conv;
34209         this_obj_conv.inner = untag_ptr(this_obj);
34210         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34212         FundingCreated_free(this_obj_conv);
34213 }
34214
34215 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34216         LDKFundingCreated this_ptr_conv;
34217         this_ptr_conv.inner = untag_ptr(this_ptr);
34218         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34220         this_ptr_conv.is_owned = false;
34221         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34222         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
34223         return ret_arr;
34224 }
34225
34226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34227         LDKFundingCreated this_ptr_conv;
34228         this_ptr_conv.inner = untag_ptr(this_ptr);
34229         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34231         this_ptr_conv.is_owned = false;
34232         LDKThirtyTwoBytes val_ref;
34233         CHECK((*env)->GetArrayLength(env, val) == 32);
34234         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34235         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
34236 }
34237
34238 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
34239         LDKFundingCreated this_ptr_conv;
34240         this_ptr_conv.inner = untag_ptr(this_ptr);
34241         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34243         this_ptr_conv.is_owned = false;
34244         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34245         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
34246         return ret_arr;
34247 }
34248
34249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34250         LDKFundingCreated this_ptr_conv;
34251         this_ptr_conv.inner = untag_ptr(this_ptr);
34252         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34254         this_ptr_conv.is_owned = false;
34255         LDKThirtyTwoBytes val_ref;
34256         CHECK((*env)->GetArrayLength(env, val) == 32);
34257         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34258         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
34259 }
34260
34261 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
34262         LDKFundingCreated this_ptr_conv;
34263         this_ptr_conv.inner = untag_ptr(this_ptr);
34264         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34266         this_ptr_conv.is_owned = false;
34267         int16_t ret_conv = FundingCreated_get_funding_output_index(&this_ptr_conv);
34268         return ret_conv;
34269 }
34270
34271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
34272         LDKFundingCreated this_ptr_conv;
34273         this_ptr_conv.inner = untag_ptr(this_ptr);
34274         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34276         this_ptr_conv.is_owned = false;
34277         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
34278 }
34279
34280 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34281         LDKFundingCreated this_ptr_conv;
34282         this_ptr_conv.inner = untag_ptr(this_ptr);
34283         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34285         this_ptr_conv.is_owned = false;
34286         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34287         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
34288         return ret_arr;
34289 }
34290
34291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34292         LDKFundingCreated this_ptr_conv;
34293         this_ptr_conv.inner = untag_ptr(this_ptr);
34294         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34296         this_ptr_conv.is_owned = false;
34297         LDKSignature val_ref;
34298         CHECK((*env)->GetArrayLength(env, val) == 64);
34299         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34300         FundingCreated_set_signature(&this_ptr_conv, val_ref);
34301 }
34302
34303 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) {
34304         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
34305         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
34306         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
34307         LDKThirtyTwoBytes funding_txid_arg_ref;
34308         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
34309         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
34310         LDKSignature signature_arg_ref;
34311         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
34312         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
34313         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
34314         int64_t ret_ref = 0;
34315         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34316         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34317         return ret_ref;
34318 }
34319
34320 static inline uint64_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
34321         LDKFundingCreated ret_var = FundingCreated_clone(arg);
34322         int64_t ret_ref = 0;
34323         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34324         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34325         return ret_ref;
34326 }
34327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34328         LDKFundingCreated arg_conv;
34329         arg_conv.inner = untag_ptr(arg);
34330         arg_conv.is_owned = ptr_is_owned(arg);
34331         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34332         arg_conv.is_owned = false;
34333         int64_t ret_conv = FundingCreated_clone_ptr(&arg_conv);
34334         return ret_conv;
34335 }
34336
34337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34338         LDKFundingCreated orig_conv;
34339         orig_conv.inner = untag_ptr(orig);
34340         orig_conv.is_owned = ptr_is_owned(orig);
34341         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34342         orig_conv.is_owned = false;
34343         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
34344         int64_t ret_ref = 0;
34345         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34346         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34347         return ret_ref;
34348 }
34349
34350 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_FundingCreated_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34351         LDKFundingCreated a_conv;
34352         a_conv.inner = untag_ptr(a);
34353         a_conv.is_owned = ptr_is_owned(a);
34354         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34355         a_conv.is_owned = false;
34356         LDKFundingCreated b_conv;
34357         b_conv.inner = untag_ptr(b);
34358         b_conv.is_owned = ptr_is_owned(b);
34359         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34360         b_conv.is_owned = false;
34361         jboolean ret_conv = FundingCreated_eq(&a_conv, &b_conv);
34362         return ret_conv;
34363 }
34364
34365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34366         LDKFundingSigned this_obj_conv;
34367         this_obj_conv.inner = untag_ptr(this_obj);
34368         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34370         FundingSigned_free(this_obj_conv);
34371 }
34372
34373 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34374         LDKFundingSigned this_ptr_conv;
34375         this_ptr_conv.inner = untag_ptr(this_ptr);
34376         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34378         this_ptr_conv.is_owned = false;
34379         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34380         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
34381         return ret_arr;
34382 }
34383
34384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34385         LDKFundingSigned this_ptr_conv;
34386         this_ptr_conv.inner = untag_ptr(this_ptr);
34387         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34389         this_ptr_conv.is_owned = false;
34390         LDKThirtyTwoBytes val_ref;
34391         CHECK((*env)->GetArrayLength(env, val) == 32);
34392         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34393         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
34394 }
34395
34396 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34397         LDKFundingSigned this_ptr_conv;
34398         this_ptr_conv.inner = untag_ptr(this_ptr);
34399         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34401         this_ptr_conv.is_owned = false;
34402         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34403         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
34404         return ret_arr;
34405 }
34406
34407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34408         LDKFundingSigned this_ptr_conv;
34409         this_ptr_conv.inner = untag_ptr(this_ptr);
34410         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34412         this_ptr_conv.is_owned = false;
34413         LDKSignature val_ref;
34414         CHECK((*env)->GetArrayLength(env, val) == 64);
34415         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34416         FundingSigned_set_signature(&this_ptr_conv, val_ref);
34417 }
34418
34419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
34420         LDKThirtyTwoBytes channel_id_arg_ref;
34421         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34422         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34423         LDKSignature signature_arg_ref;
34424         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
34425         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
34426         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
34427         int64_t ret_ref = 0;
34428         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34429         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34430         return ret_ref;
34431 }
34432
34433 static inline uint64_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
34434         LDKFundingSigned ret_var = FundingSigned_clone(arg);
34435         int64_t ret_ref = 0;
34436         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34437         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34438         return ret_ref;
34439 }
34440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34441         LDKFundingSigned arg_conv;
34442         arg_conv.inner = untag_ptr(arg);
34443         arg_conv.is_owned = ptr_is_owned(arg);
34444         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34445         arg_conv.is_owned = false;
34446         int64_t ret_conv = FundingSigned_clone_ptr(&arg_conv);
34447         return ret_conv;
34448 }
34449
34450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34451         LDKFundingSigned orig_conv;
34452         orig_conv.inner = untag_ptr(orig);
34453         orig_conv.is_owned = ptr_is_owned(orig);
34454         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34455         orig_conv.is_owned = false;
34456         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
34457         int64_t ret_ref = 0;
34458         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34459         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34460         return ret_ref;
34461 }
34462
34463 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_FundingSigned_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34464         LDKFundingSigned a_conv;
34465         a_conv.inner = untag_ptr(a);
34466         a_conv.is_owned = ptr_is_owned(a);
34467         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34468         a_conv.is_owned = false;
34469         LDKFundingSigned b_conv;
34470         b_conv.inner = untag_ptr(b);
34471         b_conv.is_owned = ptr_is_owned(b);
34472         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34473         b_conv.is_owned = false;
34474         jboolean ret_conv = FundingSigned_eq(&a_conv, &b_conv);
34475         return ret_conv;
34476 }
34477
34478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34479         LDKChannelReady this_obj_conv;
34480         this_obj_conv.inner = untag_ptr(this_obj);
34481         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34483         ChannelReady_free(this_obj_conv);
34484 }
34485
34486 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34487         LDKChannelReady this_ptr_conv;
34488         this_ptr_conv.inner = untag_ptr(this_ptr);
34489         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34491         this_ptr_conv.is_owned = false;
34492         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34493         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReady_get_channel_id(&this_ptr_conv));
34494         return ret_arr;
34495 }
34496
34497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34498         LDKChannelReady 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         LDKThirtyTwoBytes val_ref;
34504         CHECK((*env)->GetArrayLength(env, val) == 32);
34505         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34506         ChannelReady_set_channel_id(&this_ptr_conv, val_ref);
34507 }
34508
34509 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
34510         LDKChannelReady this_ptr_conv;
34511         this_ptr_conv.inner = untag_ptr(this_ptr);
34512         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34514         this_ptr_conv.is_owned = false;
34515         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34516         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelReady_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
34517         return ret_arr;
34518 }
34519
34520 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) {
34521         LDKChannelReady this_ptr_conv;
34522         this_ptr_conv.inner = untag_ptr(this_ptr);
34523         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34525         this_ptr_conv.is_owned = false;
34526         LDKPublicKey val_ref;
34527         CHECK((*env)->GetArrayLength(env, val) == 33);
34528         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34529         ChannelReady_set_next_per_commitment_point(&this_ptr_conv, val_ref);
34530 }
34531
34532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1short_1channel_1id_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
34533         LDKChannelReady this_ptr_conv;
34534         this_ptr_conv.inner = untag_ptr(this_ptr);
34535         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34537         this_ptr_conv.is_owned = false;
34538         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
34539         *ret_copy = ChannelReady_get_short_channel_id_alias(&this_ptr_conv);
34540         int64_t ret_ref = tag_ptr(ret_copy, true);
34541         return ret_ref;
34542 }
34543
34544 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) {
34545         LDKChannelReady this_ptr_conv;
34546         this_ptr_conv.inner = untag_ptr(this_ptr);
34547         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34549         this_ptr_conv.is_owned = false;
34550         void* val_ptr = untag_ptr(val);
34551         CHECK_ACCESS(val_ptr);
34552         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
34553         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
34554         ChannelReady_set_short_channel_id_alias(&this_ptr_conv, val_conv);
34555 }
34556
34557 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) {
34558         LDKThirtyTwoBytes channel_id_arg_ref;
34559         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34560         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34561         LDKPublicKey next_per_commitment_point_arg_ref;
34562         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
34563         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
34564         void* short_channel_id_alias_arg_ptr = untag_ptr(short_channel_id_alias_arg);
34565         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
34566         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
34567         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id_alias_arg));
34568         LDKChannelReady ret_var = ChannelReady_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
34569         int64_t ret_ref = 0;
34570         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34571         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34572         return ret_ref;
34573 }
34574
34575 static inline uint64_t ChannelReady_clone_ptr(LDKChannelReady *NONNULL_PTR arg) {
34576         LDKChannelReady ret_var = ChannelReady_clone(arg);
34577         int64_t ret_ref = 0;
34578         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34579         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34580         return ret_ref;
34581 }
34582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34583         LDKChannelReady arg_conv;
34584         arg_conv.inner = untag_ptr(arg);
34585         arg_conv.is_owned = ptr_is_owned(arg);
34586         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34587         arg_conv.is_owned = false;
34588         int64_t ret_conv = ChannelReady_clone_ptr(&arg_conv);
34589         return ret_conv;
34590 }
34591
34592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34593         LDKChannelReady orig_conv;
34594         orig_conv.inner = untag_ptr(orig);
34595         orig_conv.is_owned = ptr_is_owned(orig);
34596         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34597         orig_conv.is_owned = false;
34598         LDKChannelReady ret_var = ChannelReady_clone(&orig_conv);
34599         int64_t ret_ref = 0;
34600         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34601         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34602         return ret_ref;
34603 }
34604
34605 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelReady_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34606         LDKChannelReady a_conv;
34607         a_conv.inner = untag_ptr(a);
34608         a_conv.is_owned = ptr_is_owned(a);
34609         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34610         a_conv.is_owned = false;
34611         LDKChannelReady b_conv;
34612         b_conv.inner = untag_ptr(b);
34613         b_conv.is_owned = ptr_is_owned(b);
34614         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34615         b_conv.is_owned = false;
34616         jboolean ret_conv = ChannelReady_eq(&a_conv, &b_conv);
34617         return ret_conv;
34618 }
34619
34620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34621         LDKShutdown this_obj_conv;
34622         this_obj_conv.inner = untag_ptr(this_obj);
34623         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34625         Shutdown_free(this_obj_conv);
34626 }
34627
34628 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34629         LDKShutdown this_ptr_conv;
34630         this_ptr_conv.inner = untag_ptr(this_ptr);
34631         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34633         this_ptr_conv.is_owned = false;
34634         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34635         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
34636         return ret_arr;
34637 }
34638
34639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34640         LDKShutdown this_ptr_conv;
34641         this_ptr_conv.inner = untag_ptr(this_ptr);
34642         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34644         this_ptr_conv.is_owned = false;
34645         LDKThirtyTwoBytes val_ref;
34646         CHECK((*env)->GetArrayLength(env, val) == 32);
34647         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34648         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
34649 }
34650
34651 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
34652         LDKShutdown this_ptr_conv;
34653         this_ptr_conv.inner = untag_ptr(this_ptr);
34654         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34656         this_ptr_conv.is_owned = false;
34657         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
34658         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34659         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34660         return ret_arr;
34661 }
34662
34663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34664         LDKShutdown this_ptr_conv;
34665         this_ptr_conv.inner = untag_ptr(this_ptr);
34666         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34668         this_ptr_conv.is_owned = false;
34669         LDKCVec_u8Z val_ref;
34670         val_ref.datalen = (*env)->GetArrayLength(env, val);
34671         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
34672         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
34673         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
34674 }
34675
34676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
34677         LDKThirtyTwoBytes channel_id_arg_ref;
34678         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34679         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34680         LDKCVec_u8Z scriptpubkey_arg_ref;
34681         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
34682         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
34683         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
34684         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
34685         int64_t ret_ref = 0;
34686         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34687         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34688         return ret_ref;
34689 }
34690
34691 static inline uint64_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
34692         LDKShutdown ret_var = Shutdown_clone(arg);
34693         int64_t ret_ref = 0;
34694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34695         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34696         return ret_ref;
34697 }
34698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34699         LDKShutdown arg_conv;
34700         arg_conv.inner = untag_ptr(arg);
34701         arg_conv.is_owned = ptr_is_owned(arg);
34702         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34703         arg_conv.is_owned = false;
34704         int64_t ret_conv = Shutdown_clone_ptr(&arg_conv);
34705         return ret_conv;
34706 }
34707
34708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34709         LDKShutdown orig_conv;
34710         orig_conv.inner = untag_ptr(orig);
34711         orig_conv.is_owned = ptr_is_owned(orig);
34712         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34713         orig_conv.is_owned = false;
34714         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
34715         int64_t ret_ref = 0;
34716         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34717         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34718         return ret_ref;
34719 }
34720
34721 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Shutdown_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34722         LDKShutdown a_conv;
34723         a_conv.inner = untag_ptr(a);
34724         a_conv.is_owned = ptr_is_owned(a);
34725         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34726         a_conv.is_owned = false;
34727         LDKShutdown b_conv;
34728         b_conv.inner = untag_ptr(b);
34729         b_conv.is_owned = ptr_is_owned(b);
34730         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34731         b_conv.is_owned = false;
34732         jboolean ret_conv = Shutdown_eq(&a_conv, &b_conv);
34733         return ret_conv;
34734 }
34735
34736 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34737         LDKClosingSignedFeeRange this_obj_conv;
34738         this_obj_conv.inner = untag_ptr(this_obj);
34739         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34741         ClosingSignedFeeRange_free(this_obj_conv);
34742 }
34743
34744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
34745         LDKClosingSignedFeeRange this_ptr_conv;
34746         this_ptr_conv.inner = untag_ptr(this_ptr);
34747         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34749         this_ptr_conv.is_owned = false;
34750         int64_t ret_conv = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
34751         return ret_conv;
34752 }
34753
34754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34755         LDKClosingSignedFeeRange this_ptr_conv;
34756         this_ptr_conv.inner = untag_ptr(this_ptr);
34757         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34759         this_ptr_conv.is_owned = false;
34760         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
34761 }
34762
34763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
34764         LDKClosingSignedFeeRange this_ptr_conv;
34765         this_ptr_conv.inner = untag_ptr(this_ptr);
34766         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34768         this_ptr_conv.is_owned = false;
34769         int64_t ret_conv = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
34770         return ret_conv;
34771 }
34772
34773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34774         LDKClosingSignedFeeRange this_ptr_conv;
34775         this_ptr_conv.inner = untag_ptr(this_ptr);
34776         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34778         this_ptr_conv.is_owned = false;
34779         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
34780 }
34781
34782 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) {
34783         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
34784         int64_t ret_ref = 0;
34785         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34786         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34787         return ret_ref;
34788 }
34789
34790 static inline uint64_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
34791         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
34792         int64_t ret_ref = 0;
34793         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34794         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34795         return ret_ref;
34796 }
34797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34798         LDKClosingSignedFeeRange arg_conv;
34799         arg_conv.inner = untag_ptr(arg);
34800         arg_conv.is_owned = ptr_is_owned(arg);
34801         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34802         arg_conv.is_owned = false;
34803         int64_t ret_conv = ClosingSignedFeeRange_clone_ptr(&arg_conv);
34804         return ret_conv;
34805 }
34806
34807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34808         LDKClosingSignedFeeRange orig_conv;
34809         orig_conv.inner = untag_ptr(orig);
34810         orig_conv.is_owned = ptr_is_owned(orig);
34811         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34812         orig_conv.is_owned = false;
34813         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
34814         int64_t ret_ref = 0;
34815         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34816         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34817         return ret_ref;
34818 }
34819
34820 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34821         LDKClosingSignedFeeRange a_conv;
34822         a_conv.inner = untag_ptr(a);
34823         a_conv.is_owned = ptr_is_owned(a);
34824         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34825         a_conv.is_owned = false;
34826         LDKClosingSignedFeeRange b_conv;
34827         b_conv.inner = untag_ptr(b);
34828         b_conv.is_owned = ptr_is_owned(b);
34829         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34830         b_conv.is_owned = false;
34831         jboolean ret_conv = ClosingSignedFeeRange_eq(&a_conv, &b_conv);
34832         return ret_conv;
34833 }
34834
34835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34836         LDKClosingSigned this_obj_conv;
34837         this_obj_conv.inner = untag_ptr(this_obj);
34838         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34840         ClosingSigned_free(this_obj_conv);
34841 }
34842
34843 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34844         LDKClosingSigned this_ptr_conv;
34845         this_ptr_conv.inner = untag_ptr(this_ptr);
34846         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34848         this_ptr_conv.is_owned = false;
34849         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34850         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
34851         return ret_arr;
34852 }
34853
34854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34855         LDKClosingSigned this_ptr_conv;
34856         this_ptr_conv.inner = untag_ptr(this_ptr);
34857         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34859         this_ptr_conv.is_owned = false;
34860         LDKThirtyTwoBytes val_ref;
34861         CHECK((*env)->GetArrayLength(env, val) == 32);
34862         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34863         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
34864 }
34865
34866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
34867         LDKClosingSigned this_ptr_conv;
34868         this_ptr_conv.inner = untag_ptr(this_ptr);
34869         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34871         this_ptr_conv.is_owned = false;
34872         int64_t ret_conv = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
34873         return ret_conv;
34874 }
34875
34876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34877         LDKClosingSigned 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         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
34883 }
34884
34885 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34886         LDKClosingSigned this_ptr_conv;
34887         this_ptr_conv.inner = untag_ptr(this_ptr);
34888         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34890         this_ptr_conv.is_owned = false;
34891         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34892         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
34893         return ret_arr;
34894 }
34895
34896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34897         LDKClosingSigned this_ptr_conv;
34898         this_ptr_conv.inner = untag_ptr(this_ptr);
34899         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34901         this_ptr_conv.is_owned = false;
34902         LDKSignature val_ref;
34903         CHECK((*env)->GetArrayLength(env, val) == 64);
34904         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34905         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
34906 }
34907
34908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
34909         LDKClosingSigned this_ptr_conv;
34910         this_ptr_conv.inner = untag_ptr(this_ptr);
34911         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34913         this_ptr_conv.is_owned = false;
34914         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
34915         int64_t ret_ref = 0;
34916         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34917         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34918         return ret_ref;
34919 }
34920
34921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34922         LDKClosingSigned this_ptr_conv;
34923         this_ptr_conv.inner = untag_ptr(this_ptr);
34924         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34926         this_ptr_conv.is_owned = false;
34927         LDKClosingSignedFeeRange val_conv;
34928         val_conv.inner = untag_ptr(val);
34929         val_conv.is_owned = ptr_is_owned(val);
34930         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34931         val_conv = ClosingSignedFeeRange_clone(&val_conv);
34932         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
34933 }
34934
34935 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) {
34936         LDKThirtyTwoBytes channel_id_arg_ref;
34937         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34938         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34939         LDKSignature signature_arg_ref;
34940         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
34941         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
34942         LDKClosingSignedFeeRange fee_range_arg_conv;
34943         fee_range_arg_conv.inner = untag_ptr(fee_range_arg);
34944         fee_range_arg_conv.is_owned = ptr_is_owned(fee_range_arg);
34945         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
34946         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
34947         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
34948         int64_t ret_ref = 0;
34949         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34950         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34951         return ret_ref;
34952 }
34953
34954 static inline uint64_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
34955         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
34956         int64_t ret_ref = 0;
34957         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34958         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34959         return ret_ref;
34960 }
34961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34962         LDKClosingSigned arg_conv;
34963         arg_conv.inner = untag_ptr(arg);
34964         arg_conv.is_owned = ptr_is_owned(arg);
34965         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34966         arg_conv.is_owned = false;
34967         int64_t ret_conv = ClosingSigned_clone_ptr(&arg_conv);
34968         return ret_conv;
34969 }
34970
34971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34972         LDKClosingSigned orig_conv;
34973         orig_conv.inner = untag_ptr(orig);
34974         orig_conv.is_owned = ptr_is_owned(orig);
34975         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34976         orig_conv.is_owned = false;
34977         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
34978         int64_t ret_ref = 0;
34979         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34980         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34981         return ret_ref;
34982 }
34983
34984 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34985         LDKClosingSigned a_conv;
34986         a_conv.inner = untag_ptr(a);
34987         a_conv.is_owned = ptr_is_owned(a);
34988         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34989         a_conv.is_owned = false;
34990         LDKClosingSigned b_conv;
34991         b_conv.inner = untag_ptr(b);
34992         b_conv.is_owned = ptr_is_owned(b);
34993         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34994         b_conv.is_owned = false;
34995         jboolean ret_conv = ClosingSigned_eq(&a_conv, &b_conv);
34996         return ret_conv;
34997 }
34998
34999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35000         LDKUpdateAddHTLC this_obj_conv;
35001         this_obj_conv.inner = untag_ptr(this_obj);
35002         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35004         UpdateAddHTLC_free(this_obj_conv);
35005 }
35006
35007 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35008         LDKUpdateAddHTLC this_ptr_conv;
35009         this_ptr_conv.inner = untag_ptr(this_ptr);
35010         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35012         this_ptr_conv.is_owned = false;
35013         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35014         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
35015         return ret_arr;
35016 }
35017
35018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35019         LDKUpdateAddHTLC this_ptr_conv;
35020         this_ptr_conv.inner = untag_ptr(this_ptr);
35021         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35023         this_ptr_conv.is_owned = false;
35024         LDKThirtyTwoBytes val_ref;
35025         CHECK((*env)->GetArrayLength(env, val) == 32);
35026         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35027         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
35028 }
35029
35030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35031         LDKUpdateAddHTLC this_ptr_conv;
35032         this_ptr_conv.inner = untag_ptr(this_ptr);
35033         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35035         this_ptr_conv.is_owned = false;
35036         int64_t ret_conv = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
35037         return ret_conv;
35038 }
35039
35040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35041         LDKUpdateAddHTLC this_ptr_conv;
35042         this_ptr_conv.inner = untag_ptr(this_ptr);
35043         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35045         this_ptr_conv.is_owned = false;
35046         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
35047 }
35048
35049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35050         LDKUpdateAddHTLC this_ptr_conv;
35051         this_ptr_conv.inner = untag_ptr(this_ptr);
35052         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35054         this_ptr_conv.is_owned = false;
35055         int64_t ret_conv = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
35056         return ret_conv;
35057 }
35058
35059 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35060         LDKUpdateAddHTLC this_ptr_conv;
35061         this_ptr_conv.inner = untag_ptr(this_ptr);
35062         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35064         this_ptr_conv.is_owned = false;
35065         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
35066 }
35067
35068 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35069         LDKUpdateAddHTLC this_ptr_conv;
35070         this_ptr_conv.inner = untag_ptr(this_ptr);
35071         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35073         this_ptr_conv.is_owned = false;
35074         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35075         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
35076         return ret_arr;
35077 }
35078
35079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35080         LDKUpdateAddHTLC this_ptr_conv;
35081         this_ptr_conv.inner = untag_ptr(this_ptr);
35082         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35084         this_ptr_conv.is_owned = false;
35085         LDKThirtyTwoBytes val_ref;
35086         CHECK((*env)->GetArrayLength(env, val) == 32);
35087         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35088         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
35089 }
35090
35091 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
35092         LDKUpdateAddHTLC this_ptr_conv;
35093         this_ptr_conv.inner = untag_ptr(this_ptr);
35094         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35096         this_ptr_conv.is_owned = false;
35097         int32_t ret_conv = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
35098         return ret_conv;
35099 }
35100
35101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35102         LDKUpdateAddHTLC this_ptr_conv;
35103         this_ptr_conv.inner = untag_ptr(this_ptr);
35104         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35106         this_ptr_conv.is_owned = false;
35107         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
35108 }
35109
35110 static inline uint64_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
35111         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
35112         int64_t ret_ref = 0;
35113         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35114         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35115         return ret_ref;
35116 }
35117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35118         LDKUpdateAddHTLC arg_conv;
35119         arg_conv.inner = untag_ptr(arg);
35120         arg_conv.is_owned = ptr_is_owned(arg);
35121         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35122         arg_conv.is_owned = false;
35123         int64_t ret_conv = UpdateAddHTLC_clone_ptr(&arg_conv);
35124         return ret_conv;
35125 }
35126
35127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35128         LDKUpdateAddHTLC orig_conv;
35129         orig_conv.inner = untag_ptr(orig);
35130         orig_conv.is_owned = ptr_is_owned(orig);
35131         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35132         orig_conv.is_owned = false;
35133         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
35134         int64_t ret_ref = 0;
35135         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35136         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35137         return ret_ref;
35138 }
35139
35140 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35141         LDKUpdateAddHTLC a_conv;
35142         a_conv.inner = untag_ptr(a);
35143         a_conv.is_owned = ptr_is_owned(a);
35144         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35145         a_conv.is_owned = false;
35146         LDKUpdateAddHTLC b_conv;
35147         b_conv.inner = untag_ptr(b);
35148         b_conv.is_owned = ptr_is_owned(b);
35149         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35150         b_conv.is_owned = false;
35151         jboolean ret_conv = UpdateAddHTLC_eq(&a_conv, &b_conv);
35152         return ret_conv;
35153 }
35154
35155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35156         LDKOnionMessage this_obj_conv;
35157         this_obj_conv.inner = untag_ptr(this_obj);
35158         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35160         OnionMessage_free(this_obj_conv);
35161 }
35162
35163 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OnionMessage_1get_1blinding_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
35164         LDKOnionMessage this_ptr_conv;
35165         this_ptr_conv.inner = untag_ptr(this_ptr);
35166         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35168         this_ptr_conv.is_owned = false;
35169         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35170         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OnionMessage_get_blinding_point(&this_ptr_conv).compressed_form);
35171         return ret_arr;
35172 }
35173
35174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessage_1set_1blinding_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35175         LDKOnionMessage this_ptr_conv;
35176         this_ptr_conv.inner = untag_ptr(this_ptr);
35177         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35179         this_ptr_conv.is_owned = false;
35180         LDKPublicKey val_ref;
35181         CHECK((*env)->GetArrayLength(env, val) == 33);
35182         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35183         OnionMessage_set_blinding_point(&this_ptr_conv, val_ref);
35184 }
35185
35186 static inline uint64_t OnionMessage_clone_ptr(LDKOnionMessage *NONNULL_PTR arg) {
35187         LDKOnionMessage ret_var = OnionMessage_clone(arg);
35188         int64_t ret_ref = 0;
35189         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35190         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35191         return ret_ref;
35192 }
35193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35194         LDKOnionMessage arg_conv;
35195         arg_conv.inner = untag_ptr(arg);
35196         arg_conv.is_owned = ptr_is_owned(arg);
35197         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35198         arg_conv.is_owned = false;
35199         int64_t ret_conv = OnionMessage_clone_ptr(&arg_conv);
35200         return ret_conv;
35201 }
35202
35203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35204         LDKOnionMessage orig_conv;
35205         orig_conv.inner = untag_ptr(orig);
35206         orig_conv.is_owned = ptr_is_owned(orig);
35207         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35208         orig_conv.is_owned = false;
35209         LDKOnionMessage ret_var = OnionMessage_clone(&orig_conv);
35210         int64_t ret_ref = 0;
35211         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35212         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35213         return ret_ref;
35214 }
35215
35216 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OnionMessage_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35217         LDKOnionMessage a_conv;
35218         a_conv.inner = untag_ptr(a);
35219         a_conv.is_owned = ptr_is_owned(a);
35220         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35221         a_conv.is_owned = false;
35222         LDKOnionMessage b_conv;
35223         b_conv.inner = untag_ptr(b);
35224         b_conv.is_owned = ptr_is_owned(b);
35225         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35226         b_conv.is_owned = false;
35227         jboolean ret_conv = OnionMessage_eq(&a_conv, &b_conv);
35228         return ret_conv;
35229 }
35230
35231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35232         LDKUpdateFulfillHTLC this_obj_conv;
35233         this_obj_conv.inner = untag_ptr(this_obj);
35234         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35236         UpdateFulfillHTLC_free(this_obj_conv);
35237 }
35238
35239 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35240         LDKUpdateFulfillHTLC this_ptr_conv;
35241         this_ptr_conv.inner = untag_ptr(this_ptr);
35242         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35244         this_ptr_conv.is_owned = false;
35245         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35246         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
35247         return ret_arr;
35248 }
35249
35250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35251         LDKUpdateFulfillHTLC this_ptr_conv;
35252         this_ptr_conv.inner = untag_ptr(this_ptr);
35253         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35255         this_ptr_conv.is_owned = false;
35256         LDKThirtyTwoBytes val_ref;
35257         CHECK((*env)->GetArrayLength(env, val) == 32);
35258         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35259         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
35260 }
35261
35262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35263         LDKUpdateFulfillHTLC this_ptr_conv;
35264         this_ptr_conv.inner = untag_ptr(this_ptr);
35265         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35267         this_ptr_conv.is_owned = false;
35268         int64_t ret_conv = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
35269         return ret_conv;
35270 }
35271
35272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35273         LDKUpdateFulfillHTLC this_ptr_conv;
35274         this_ptr_conv.inner = untag_ptr(this_ptr);
35275         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35277         this_ptr_conv.is_owned = false;
35278         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
35279 }
35280
35281 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
35282         LDKUpdateFulfillHTLC this_ptr_conv;
35283         this_ptr_conv.inner = untag_ptr(this_ptr);
35284         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35286         this_ptr_conv.is_owned = false;
35287         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35288         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
35289         return ret_arr;
35290 }
35291
35292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35293         LDKUpdateFulfillHTLC this_ptr_conv;
35294         this_ptr_conv.inner = untag_ptr(this_ptr);
35295         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35297         this_ptr_conv.is_owned = false;
35298         LDKThirtyTwoBytes val_ref;
35299         CHECK((*env)->GetArrayLength(env, val) == 32);
35300         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35301         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
35302 }
35303
35304 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) {
35305         LDKThirtyTwoBytes channel_id_arg_ref;
35306         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
35307         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
35308         LDKThirtyTwoBytes payment_preimage_arg_ref;
35309         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
35310         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
35311         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
35312         int64_t ret_ref = 0;
35313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35314         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35315         return ret_ref;
35316 }
35317
35318 static inline uint64_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
35319         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
35320         int64_t ret_ref = 0;
35321         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35322         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35323         return ret_ref;
35324 }
35325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35326         LDKUpdateFulfillHTLC arg_conv;
35327         arg_conv.inner = untag_ptr(arg);
35328         arg_conv.is_owned = ptr_is_owned(arg);
35329         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35330         arg_conv.is_owned = false;
35331         int64_t ret_conv = UpdateFulfillHTLC_clone_ptr(&arg_conv);
35332         return ret_conv;
35333 }
35334
35335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35336         LDKUpdateFulfillHTLC orig_conv;
35337         orig_conv.inner = untag_ptr(orig);
35338         orig_conv.is_owned = ptr_is_owned(orig);
35339         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35340         orig_conv.is_owned = false;
35341         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
35342         int64_t ret_ref = 0;
35343         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35344         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35345         return ret_ref;
35346 }
35347
35348 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35349         LDKUpdateFulfillHTLC a_conv;
35350         a_conv.inner = untag_ptr(a);
35351         a_conv.is_owned = ptr_is_owned(a);
35352         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35353         a_conv.is_owned = false;
35354         LDKUpdateFulfillHTLC b_conv;
35355         b_conv.inner = untag_ptr(b);
35356         b_conv.is_owned = ptr_is_owned(b);
35357         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35358         b_conv.is_owned = false;
35359         jboolean ret_conv = UpdateFulfillHTLC_eq(&a_conv, &b_conv);
35360         return ret_conv;
35361 }
35362
35363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35364         LDKUpdateFailHTLC 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         UpdateFailHTLC_free(this_obj_conv);
35369 }
35370
35371 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35372         LDKUpdateFailHTLC this_ptr_conv;
35373         this_ptr_conv.inner = untag_ptr(this_ptr);
35374         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35376         this_ptr_conv.is_owned = false;
35377         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35378         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
35379         return ret_arr;
35380 }
35381
35382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35383         LDKUpdateFailHTLC this_ptr_conv;
35384         this_ptr_conv.inner = untag_ptr(this_ptr);
35385         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35387         this_ptr_conv.is_owned = false;
35388         LDKThirtyTwoBytes val_ref;
35389         CHECK((*env)->GetArrayLength(env, val) == 32);
35390         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35391         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
35392 }
35393
35394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35395         LDKUpdateFailHTLC this_ptr_conv;
35396         this_ptr_conv.inner = untag_ptr(this_ptr);
35397         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35399         this_ptr_conv.is_owned = false;
35400         int64_t ret_conv = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
35401         return ret_conv;
35402 }
35403
35404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35405         LDKUpdateFailHTLC this_ptr_conv;
35406         this_ptr_conv.inner = untag_ptr(this_ptr);
35407         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35409         this_ptr_conv.is_owned = false;
35410         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
35411 }
35412
35413 static inline uint64_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
35414         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
35415         int64_t ret_ref = 0;
35416         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35417         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35418         return ret_ref;
35419 }
35420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35421         LDKUpdateFailHTLC arg_conv;
35422         arg_conv.inner = untag_ptr(arg);
35423         arg_conv.is_owned = ptr_is_owned(arg);
35424         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35425         arg_conv.is_owned = false;
35426         int64_t ret_conv = UpdateFailHTLC_clone_ptr(&arg_conv);
35427         return ret_conv;
35428 }
35429
35430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35431         LDKUpdateFailHTLC orig_conv;
35432         orig_conv.inner = untag_ptr(orig);
35433         orig_conv.is_owned = ptr_is_owned(orig);
35434         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35435         orig_conv.is_owned = false;
35436         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
35437         int64_t ret_ref = 0;
35438         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35439         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35440         return ret_ref;
35441 }
35442
35443 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35444         LDKUpdateFailHTLC a_conv;
35445         a_conv.inner = untag_ptr(a);
35446         a_conv.is_owned = ptr_is_owned(a);
35447         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35448         a_conv.is_owned = false;
35449         LDKUpdateFailHTLC b_conv;
35450         b_conv.inner = untag_ptr(b);
35451         b_conv.is_owned = ptr_is_owned(b);
35452         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35453         b_conv.is_owned = false;
35454         jboolean ret_conv = UpdateFailHTLC_eq(&a_conv, &b_conv);
35455         return ret_conv;
35456 }
35457
35458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35459         LDKUpdateFailMalformedHTLC this_obj_conv;
35460         this_obj_conv.inner = untag_ptr(this_obj);
35461         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35463         UpdateFailMalformedHTLC_free(this_obj_conv);
35464 }
35465
35466 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35467         LDKUpdateFailMalformedHTLC this_ptr_conv;
35468         this_ptr_conv.inner = untag_ptr(this_ptr);
35469         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35471         this_ptr_conv.is_owned = false;
35472         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35473         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
35474         return ret_arr;
35475 }
35476
35477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35478         LDKUpdateFailMalformedHTLC this_ptr_conv;
35479         this_ptr_conv.inner = untag_ptr(this_ptr);
35480         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35482         this_ptr_conv.is_owned = false;
35483         LDKThirtyTwoBytes val_ref;
35484         CHECK((*env)->GetArrayLength(env, val) == 32);
35485         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35486         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
35487 }
35488
35489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35490         LDKUpdateFailMalformedHTLC this_ptr_conv;
35491         this_ptr_conv.inner = untag_ptr(this_ptr);
35492         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35494         this_ptr_conv.is_owned = false;
35495         int64_t ret_conv = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
35496         return ret_conv;
35497 }
35498
35499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35500         LDKUpdateFailMalformedHTLC this_ptr_conv;
35501         this_ptr_conv.inner = untag_ptr(this_ptr);
35502         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35504         this_ptr_conv.is_owned = false;
35505         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
35506 }
35507
35508 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
35509         LDKUpdateFailMalformedHTLC this_ptr_conv;
35510         this_ptr_conv.inner = untag_ptr(this_ptr);
35511         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35513         this_ptr_conv.is_owned = false;
35514         int16_t ret_conv = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
35515         return ret_conv;
35516 }
35517
35518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35519         LDKUpdateFailMalformedHTLC this_ptr_conv;
35520         this_ptr_conv.inner = untag_ptr(this_ptr);
35521         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35523         this_ptr_conv.is_owned = false;
35524         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
35525 }
35526
35527 static inline uint64_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
35528         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
35529         int64_t ret_ref = 0;
35530         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35531         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35532         return ret_ref;
35533 }
35534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35535         LDKUpdateFailMalformedHTLC arg_conv;
35536         arg_conv.inner = untag_ptr(arg);
35537         arg_conv.is_owned = ptr_is_owned(arg);
35538         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35539         arg_conv.is_owned = false;
35540         int64_t ret_conv = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
35541         return ret_conv;
35542 }
35543
35544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35545         LDKUpdateFailMalformedHTLC orig_conv;
35546         orig_conv.inner = untag_ptr(orig);
35547         orig_conv.is_owned = ptr_is_owned(orig);
35548         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35549         orig_conv.is_owned = false;
35550         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
35551         int64_t ret_ref = 0;
35552         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35553         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35554         return ret_ref;
35555 }
35556
35557 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35558         LDKUpdateFailMalformedHTLC a_conv;
35559         a_conv.inner = untag_ptr(a);
35560         a_conv.is_owned = ptr_is_owned(a);
35561         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35562         a_conv.is_owned = false;
35563         LDKUpdateFailMalformedHTLC b_conv;
35564         b_conv.inner = untag_ptr(b);
35565         b_conv.is_owned = ptr_is_owned(b);
35566         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35567         b_conv.is_owned = false;
35568         jboolean ret_conv = UpdateFailMalformedHTLC_eq(&a_conv, &b_conv);
35569         return ret_conv;
35570 }
35571
35572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35573         LDKCommitmentSigned this_obj_conv;
35574         this_obj_conv.inner = untag_ptr(this_obj);
35575         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35577         CommitmentSigned_free(this_obj_conv);
35578 }
35579
35580 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35581         LDKCommitmentSigned this_ptr_conv;
35582         this_ptr_conv.inner = untag_ptr(this_ptr);
35583         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35585         this_ptr_conv.is_owned = false;
35586         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35587         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
35588         return ret_arr;
35589 }
35590
35591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35592         LDKCommitmentSigned this_ptr_conv;
35593         this_ptr_conv.inner = untag_ptr(this_ptr);
35594         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35596         this_ptr_conv.is_owned = false;
35597         LDKThirtyTwoBytes val_ref;
35598         CHECK((*env)->GetArrayLength(env, val) == 32);
35599         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35600         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
35601 }
35602
35603 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
35604         LDKCommitmentSigned this_ptr_conv;
35605         this_ptr_conv.inner = untag_ptr(this_ptr);
35606         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35608         this_ptr_conv.is_owned = false;
35609         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35610         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
35611         return ret_arr;
35612 }
35613
35614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35615         LDKCommitmentSigned this_ptr_conv;
35616         this_ptr_conv.inner = untag_ptr(this_ptr);
35617         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35619         this_ptr_conv.is_owned = false;
35620         LDKSignature val_ref;
35621         CHECK((*env)->GetArrayLength(env, val) == 64);
35622         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35623         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
35624 }
35625
35626 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr) {
35627         LDKCommitmentSigned this_ptr_conv;
35628         this_ptr_conv.inner = untag_ptr(this_ptr);
35629         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35631         this_ptr_conv.is_owned = false;
35632         LDKCVec_SignatureZ ret_var = CommitmentSigned_get_htlc_signatures(&this_ptr_conv);
35633         jobjectArray ret_arr = NULL;
35634         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
35635         ;
35636         for (size_t i = 0; i < ret_var.datalen; i++) {
35637                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
35638                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
35639                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
35640         }
35641         
35642         FREE(ret_var.data);
35643         return ret_arr;
35644 }
35645
35646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
35647         LDKCommitmentSigned this_ptr_conv;
35648         this_ptr_conv.inner = untag_ptr(this_ptr);
35649         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35651         this_ptr_conv.is_owned = false;
35652         LDKCVec_SignatureZ val_constr;
35653         val_constr.datalen = (*env)->GetArrayLength(env, val);
35654         if (val_constr.datalen > 0)
35655                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
35656         else
35657                 val_constr.data = NULL;
35658         for (size_t i = 0; i < val_constr.datalen; i++) {
35659                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
35660                 LDKSignature val_conv_8_ref;
35661                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
35662                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
35663                 val_constr.data[i] = val_conv_8_ref;
35664         }
35665         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
35666 }
35667
35668 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) {
35669         LDKThirtyTwoBytes channel_id_arg_ref;
35670         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
35671         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
35672         LDKSignature signature_arg_ref;
35673         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
35674         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
35675         LDKCVec_SignatureZ htlc_signatures_arg_constr;
35676         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
35677         if (htlc_signatures_arg_constr.datalen > 0)
35678                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
35679         else
35680                 htlc_signatures_arg_constr.data = NULL;
35681         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
35682                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
35683                 LDKSignature htlc_signatures_arg_conv_8_ref;
35684                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
35685                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
35686                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
35687         }
35688         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
35689         int64_t ret_ref = 0;
35690         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35691         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35692         return ret_ref;
35693 }
35694
35695 static inline uint64_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
35696         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
35697         int64_t ret_ref = 0;
35698         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35699         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35700         return ret_ref;
35701 }
35702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35703         LDKCommitmentSigned arg_conv;
35704         arg_conv.inner = untag_ptr(arg);
35705         arg_conv.is_owned = ptr_is_owned(arg);
35706         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35707         arg_conv.is_owned = false;
35708         int64_t ret_conv = CommitmentSigned_clone_ptr(&arg_conv);
35709         return ret_conv;
35710 }
35711
35712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35713         LDKCommitmentSigned orig_conv;
35714         orig_conv.inner = untag_ptr(orig);
35715         orig_conv.is_owned = ptr_is_owned(orig);
35716         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35717         orig_conv.is_owned = false;
35718         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
35719         int64_t ret_ref = 0;
35720         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35721         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35722         return ret_ref;
35723 }
35724
35725 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35726         LDKCommitmentSigned a_conv;
35727         a_conv.inner = untag_ptr(a);
35728         a_conv.is_owned = ptr_is_owned(a);
35729         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35730         a_conv.is_owned = false;
35731         LDKCommitmentSigned b_conv;
35732         b_conv.inner = untag_ptr(b);
35733         b_conv.is_owned = ptr_is_owned(b);
35734         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35735         b_conv.is_owned = false;
35736         jboolean ret_conv = CommitmentSigned_eq(&a_conv, &b_conv);
35737         return ret_conv;
35738 }
35739
35740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35741         LDKRevokeAndACK this_obj_conv;
35742         this_obj_conv.inner = untag_ptr(this_obj);
35743         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35745         RevokeAndACK_free(this_obj_conv);
35746 }
35747
35748 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35749         LDKRevokeAndACK this_ptr_conv;
35750         this_ptr_conv.inner = untag_ptr(this_ptr);
35751         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35753         this_ptr_conv.is_owned = false;
35754         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35755         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
35756         return ret_arr;
35757 }
35758
35759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35760         LDKRevokeAndACK this_ptr_conv;
35761         this_ptr_conv.inner = untag_ptr(this_ptr);
35762         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35764         this_ptr_conv.is_owned = false;
35765         LDKThirtyTwoBytes val_ref;
35766         CHECK((*env)->GetArrayLength(env, val) == 32);
35767         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35768         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
35769 }
35770
35771 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
35772         LDKRevokeAndACK this_ptr_conv;
35773         this_ptr_conv.inner = untag_ptr(this_ptr);
35774         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35776         this_ptr_conv.is_owned = false;
35777         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35778         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
35779         return ret_arr;
35780 }
35781
35782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35783         LDKRevokeAndACK this_ptr_conv;
35784         this_ptr_conv.inner = untag_ptr(this_ptr);
35785         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35787         this_ptr_conv.is_owned = false;
35788         LDKThirtyTwoBytes val_ref;
35789         CHECK((*env)->GetArrayLength(env, val) == 32);
35790         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35791         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
35792 }
35793
35794 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
35795         LDKRevokeAndACK this_ptr_conv;
35796         this_ptr_conv.inner = untag_ptr(this_ptr);
35797         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35799         this_ptr_conv.is_owned = false;
35800         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35801         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
35802         return ret_arr;
35803 }
35804
35805 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) {
35806         LDKRevokeAndACK this_ptr_conv;
35807         this_ptr_conv.inner = untag_ptr(this_ptr);
35808         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35810         this_ptr_conv.is_owned = false;
35811         LDKPublicKey val_ref;
35812         CHECK((*env)->GetArrayLength(env, val) == 33);
35813         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35814         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
35815 }
35816
35817 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) {
35818         LDKThirtyTwoBytes channel_id_arg_ref;
35819         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
35820         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
35821         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
35822         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
35823         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
35824         LDKPublicKey next_per_commitment_point_arg_ref;
35825         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
35826         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
35827         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
35828         int64_t ret_ref = 0;
35829         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35830         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35831         return ret_ref;
35832 }
35833
35834 static inline uint64_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
35835         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
35836         int64_t ret_ref = 0;
35837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35838         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35839         return ret_ref;
35840 }
35841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35842         LDKRevokeAndACK arg_conv;
35843         arg_conv.inner = untag_ptr(arg);
35844         arg_conv.is_owned = ptr_is_owned(arg);
35845         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35846         arg_conv.is_owned = false;
35847         int64_t ret_conv = RevokeAndACK_clone_ptr(&arg_conv);
35848         return ret_conv;
35849 }
35850
35851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35852         LDKRevokeAndACK orig_conv;
35853         orig_conv.inner = untag_ptr(orig);
35854         orig_conv.is_owned = ptr_is_owned(orig);
35855         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35856         orig_conv.is_owned = false;
35857         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
35858         int64_t ret_ref = 0;
35859         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35860         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35861         return ret_ref;
35862 }
35863
35864 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35865         LDKRevokeAndACK a_conv;
35866         a_conv.inner = untag_ptr(a);
35867         a_conv.is_owned = ptr_is_owned(a);
35868         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35869         a_conv.is_owned = false;
35870         LDKRevokeAndACK b_conv;
35871         b_conv.inner = untag_ptr(b);
35872         b_conv.is_owned = ptr_is_owned(b);
35873         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35874         b_conv.is_owned = false;
35875         jboolean ret_conv = RevokeAndACK_eq(&a_conv, &b_conv);
35876         return ret_conv;
35877 }
35878
35879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35880         LDKUpdateFee this_obj_conv;
35881         this_obj_conv.inner = untag_ptr(this_obj);
35882         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35884         UpdateFee_free(this_obj_conv);
35885 }
35886
35887 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35888         LDKUpdateFee this_ptr_conv;
35889         this_ptr_conv.inner = untag_ptr(this_ptr);
35890         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35892         this_ptr_conv.is_owned = false;
35893         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35894         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
35895         return ret_arr;
35896 }
35897
35898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35899         LDKUpdateFee this_ptr_conv;
35900         this_ptr_conv.inner = untag_ptr(this_ptr);
35901         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35903         this_ptr_conv.is_owned = false;
35904         LDKThirtyTwoBytes val_ref;
35905         CHECK((*env)->GetArrayLength(env, val) == 32);
35906         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35907         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
35908 }
35909
35910 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
35911         LDKUpdateFee this_ptr_conv;
35912         this_ptr_conv.inner = untag_ptr(this_ptr);
35913         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35915         this_ptr_conv.is_owned = false;
35916         int32_t ret_conv = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
35917         return ret_conv;
35918 }
35919
35920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35921         LDKUpdateFee this_ptr_conv;
35922         this_ptr_conv.inner = untag_ptr(this_ptr);
35923         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35925         this_ptr_conv.is_owned = false;
35926         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
35927 }
35928
35929 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) {
35930         LDKThirtyTwoBytes channel_id_arg_ref;
35931         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
35932         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
35933         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
35934         int64_t ret_ref = 0;
35935         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35936         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35937         return ret_ref;
35938 }
35939
35940 static inline uint64_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
35941         LDKUpdateFee ret_var = UpdateFee_clone(arg);
35942         int64_t ret_ref = 0;
35943         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35944         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35945         return ret_ref;
35946 }
35947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35948         LDKUpdateFee arg_conv;
35949         arg_conv.inner = untag_ptr(arg);
35950         arg_conv.is_owned = ptr_is_owned(arg);
35951         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35952         arg_conv.is_owned = false;
35953         int64_t ret_conv = UpdateFee_clone_ptr(&arg_conv);
35954         return ret_conv;
35955 }
35956
35957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35958         LDKUpdateFee orig_conv;
35959         orig_conv.inner = untag_ptr(orig);
35960         orig_conv.is_owned = ptr_is_owned(orig);
35961         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35962         orig_conv.is_owned = false;
35963         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
35964         int64_t ret_ref = 0;
35965         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35966         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35967         return ret_ref;
35968 }
35969
35970 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFee_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35971         LDKUpdateFee a_conv;
35972         a_conv.inner = untag_ptr(a);
35973         a_conv.is_owned = ptr_is_owned(a);
35974         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35975         a_conv.is_owned = false;
35976         LDKUpdateFee b_conv;
35977         b_conv.inner = untag_ptr(b);
35978         b_conv.is_owned = ptr_is_owned(b);
35979         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35980         b_conv.is_owned = false;
35981         jboolean ret_conv = UpdateFee_eq(&a_conv, &b_conv);
35982         return ret_conv;
35983 }
35984
35985 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35986         LDKDataLossProtect this_obj_conv;
35987         this_obj_conv.inner = untag_ptr(this_obj);
35988         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35990         DataLossProtect_free(this_obj_conv);
35991 }
35992
35993 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
35994         LDKDataLossProtect this_ptr_conv;
35995         this_ptr_conv.inner = untag_ptr(this_ptr);
35996         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35998         this_ptr_conv.is_owned = false;
35999         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36000         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
36001         return ret_arr;
36002 }
36003
36004 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) {
36005         LDKDataLossProtect this_ptr_conv;
36006         this_ptr_conv.inner = untag_ptr(this_ptr);
36007         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36009         this_ptr_conv.is_owned = false;
36010         LDKThirtyTwoBytes val_ref;
36011         CHECK((*env)->GetArrayLength(env, val) == 32);
36012         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36013         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
36014 }
36015
36016 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
36017         LDKDataLossProtect this_ptr_conv;
36018         this_ptr_conv.inner = untag_ptr(this_ptr);
36019         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36021         this_ptr_conv.is_owned = false;
36022         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36023         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
36024         return ret_arr;
36025 }
36026
36027 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) {
36028         LDKDataLossProtect this_ptr_conv;
36029         this_ptr_conv.inner = untag_ptr(this_ptr);
36030         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36032         this_ptr_conv.is_owned = false;
36033         LDKPublicKey val_ref;
36034         CHECK((*env)->GetArrayLength(env, val) == 33);
36035         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36036         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
36037 }
36038
36039 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) {
36040         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
36041         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
36042         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
36043         LDKPublicKey my_current_per_commitment_point_arg_ref;
36044         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
36045         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
36046         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
36047         int64_t ret_ref = 0;
36048         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36049         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36050         return ret_ref;
36051 }
36052
36053 static inline uint64_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
36054         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
36055         int64_t ret_ref = 0;
36056         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36057         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36058         return ret_ref;
36059 }
36060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36061         LDKDataLossProtect arg_conv;
36062         arg_conv.inner = untag_ptr(arg);
36063         arg_conv.is_owned = ptr_is_owned(arg);
36064         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36065         arg_conv.is_owned = false;
36066         int64_t ret_conv = DataLossProtect_clone_ptr(&arg_conv);
36067         return ret_conv;
36068 }
36069
36070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36071         LDKDataLossProtect orig_conv;
36072         orig_conv.inner = untag_ptr(orig);
36073         orig_conv.is_owned = ptr_is_owned(orig);
36074         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36075         orig_conv.is_owned = false;
36076         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
36077         int64_t ret_ref = 0;
36078         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36079         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36080         return ret_ref;
36081 }
36082
36083 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36084         LDKDataLossProtect a_conv;
36085         a_conv.inner = untag_ptr(a);
36086         a_conv.is_owned = ptr_is_owned(a);
36087         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36088         a_conv.is_owned = false;
36089         LDKDataLossProtect b_conv;
36090         b_conv.inner = untag_ptr(b);
36091         b_conv.is_owned = ptr_is_owned(b);
36092         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36093         b_conv.is_owned = false;
36094         jboolean ret_conv = DataLossProtect_eq(&a_conv, &b_conv);
36095         return ret_conv;
36096 }
36097
36098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36099         LDKChannelReestablish this_obj_conv;
36100         this_obj_conv.inner = untag_ptr(this_obj);
36101         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36103         ChannelReestablish_free(this_obj_conv);
36104 }
36105
36106 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36107         LDKChannelReestablish this_ptr_conv;
36108         this_ptr_conv.inner = untag_ptr(this_ptr);
36109         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36111         this_ptr_conv.is_owned = false;
36112         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36113         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
36114         return ret_arr;
36115 }
36116
36117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36118         LDKChannelReestablish this_ptr_conv;
36119         this_ptr_conv.inner = untag_ptr(this_ptr);
36120         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36122         this_ptr_conv.is_owned = false;
36123         LDKThirtyTwoBytes val_ref;
36124         CHECK((*env)->GetArrayLength(env, val) == 32);
36125         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36126         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
36127 }
36128
36129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
36130         LDKChannelReestablish this_ptr_conv;
36131         this_ptr_conv.inner = untag_ptr(this_ptr);
36132         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36134         this_ptr_conv.is_owned = false;
36135         int64_t ret_conv = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
36136         return ret_conv;
36137 }
36138
36139 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) {
36140         LDKChannelReestablish this_ptr_conv;
36141         this_ptr_conv.inner = untag_ptr(this_ptr);
36142         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36144         this_ptr_conv.is_owned = false;
36145         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
36146 }
36147
36148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
36149         LDKChannelReestablish this_ptr_conv;
36150         this_ptr_conv.inner = untag_ptr(this_ptr);
36151         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36153         this_ptr_conv.is_owned = false;
36154         int64_t ret_conv = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
36155         return ret_conv;
36156 }
36157
36158 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) {
36159         LDKChannelReestablish this_ptr_conv;
36160         this_ptr_conv.inner = untag_ptr(this_ptr);
36161         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36163         this_ptr_conv.is_owned = false;
36164         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
36165 }
36166
36167 static inline uint64_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
36168         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
36169         int64_t ret_ref = 0;
36170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36171         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36172         return ret_ref;
36173 }
36174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36175         LDKChannelReestablish arg_conv;
36176         arg_conv.inner = untag_ptr(arg);
36177         arg_conv.is_owned = ptr_is_owned(arg);
36178         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36179         arg_conv.is_owned = false;
36180         int64_t ret_conv = ChannelReestablish_clone_ptr(&arg_conv);
36181         return ret_conv;
36182 }
36183
36184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36185         LDKChannelReestablish orig_conv;
36186         orig_conv.inner = untag_ptr(orig);
36187         orig_conv.is_owned = ptr_is_owned(orig);
36188         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36189         orig_conv.is_owned = false;
36190         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
36191         int64_t ret_ref = 0;
36192         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36193         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36194         return ret_ref;
36195 }
36196
36197 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36198         LDKChannelReestablish a_conv;
36199         a_conv.inner = untag_ptr(a);
36200         a_conv.is_owned = ptr_is_owned(a);
36201         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36202         a_conv.is_owned = false;
36203         LDKChannelReestablish b_conv;
36204         b_conv.inner = untag_ptr(b);
36205         b_conv.is_owned = ptr_is_owned(b);
36206         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36207         b_conv.is_owned = false;
36208         jboolean ret_conv = ChannelReestablish_eq(&a_conv, &b_conv);
36209         return ret_conv;
36210 }
36211
36212 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36213         LDKAnnouncementSignatures this_obj_conv;
36214         this_obj_conv.inner = untag_ptr(this_obj);
36215         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36217         AnnouncementSignatures_free(this_obj_conv);
36218 }
36219
36220 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36221         LDKAnnouncementSignatures this_ptr_conv;
36222         this_ptr_conv.inner = untag_ptr(this_ptr);
36223         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36225         this_ptr_conv.is_owned = false;
36226         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36227         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
36228         return ret_arr;
36229 }
36230
36231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36232         LDKAnnouncementSignatures this_ptr_conv;
36233         this_ptr_conv.inner = untag_ptr(this_ptr);
36234         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36236         this_ptr_conv.is_owned = false;
36237         LDKThirtyTwoBytes val_ref;
36238         CHECK((*env)->GetArrayLength(env, val) == 32);
36239         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36240         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
36241 }
36242
36243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36244         LDKAnnouncementSignatures this_ptr_conv;
36245         this_ptr_conv.inner = untag_ptr(this_ptr);
36246         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36248         this_ptr_conv.is_owned = false;
36249         int64_t ret_conv = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
36250         return ret_conv;
36251 }
36252
36253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36254         LDKAnnouncementSignatures this_ptr_conv;
36255         this_ptr_conv.inner = untag_ptr(this_ptr);
36256         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36258         this_ptr_conv.is_owned = false;
36259         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
36260 }
36261
36262 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
36263         LDKAnnouncementSignatures this_ptr_conv;
36264         this_ptr_conv.inner = untag_ptr(this_ptr);
36265         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36267         this_ptr_conv.is_owned = false;
36268         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36269         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
36270         return ret_arr;
36271 }
36272
36273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36274         LDKAnnouncementSignatures this_ptr_conv;
36275         this_ptr_conv.inner = untag_ptr(this_ptr);
36276         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36278         this_ptr_conv.is_owned = false;
36279         LDKSignature val_ref;
36280         CHECK((*env)->GetArrayLength(env, val) == 64);
36281         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36282         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
36283 }
36284
36285 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
36286         LDKAnnouncementSignatures this_ptr_conv;
36287         this_ptr_conv.inner = untag_ptr(this_ptr);
36288         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36290         this_ptr_conv.is_owned = false;
36291         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36292         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
36293         return ret_arr;
36294 }
36295
36296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36297         LDKAnnouncementSignatures this_ptr_conv;
36298         this_ptr_conv.inner = untag_ptr(this_ptr);
36299         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36301         this_ptr_conv.is_owned = false;
36302         LDKSignature val_ref;
36303         CHECK((*env)->GetArrayLength(env, val) == 64);
36304         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36305         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
36306 }
36307
36308 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) {
36309         LDKThirtyTwoBytes channel_id_arg_ref;
36310         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36311         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36312         LDKSignature node_signature_arg_ref;
36313         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
36314         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
36315         LDKSignature bitcoin_signature_arg_ref;
36316         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
36317         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
36318         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
36319         int64_t ret_ref = 0;
36320         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36321         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36322         return ret_ref;
36323 }
36324
36325 static inline uint64_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
36326         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
36327         int64_t ret_ref = 0;
36328         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36329         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36330         return ret_ref;
36331 }
36332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36333         LDKAnnouncementSignatures arg_conv;
36334         arg_conv.inner = untag_ptr(arg);
36335         arg_conv.is_owned = ptr_is_owned(arg);
36336         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36337         arg_conv.is_owned = false;
36338         int64_t ret_conv = AnnouncementSignatures_clone_ptr(&arg_conv);
36339         return ret_conv;
36340 }
36341
36342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36343         LDKAnnouncementSignatures orig_conv;
36344         orig_conv.inner = untag_ptr(orig);
36345         orig_conv.is_owned = ptr_is_owned(orig);
36346         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36347         orig_conv.is_owned = false;
36348         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
36349         int64_t ret_ref = 0;
36350         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36351         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36352         return ret_ref;
36353 }
36354
36355 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36356         LDKAnnouncementSignatures a_conv;
36357         a_conv.inner = untag_ptr(a);
36358         a_conv.is_owned = ptr_is_owned(a);
36359         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36360         a_conv.is_owned = false;
36361         LDKAnnouncementSignatures b_conv;
36362         b_conv.inner = untag_ptr(b);
36363         b_conv.is_owned = ptr_is_owned(b);
36364         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36365         b_conv.is_owned = false;
36366         jboolean ret_conv = AnnouncementSignatures_eq(&a_conv, &b_conv);
36367         return ret_conv;
36368 }
36369
36370 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
36371         if (!ptr_is_owned(this_ptr)) return;
36372         void* this_ptr_ptr = untag_ptr(this_ptr);
36373         CHECK_ACCESS(this_ptr_ptr);
36374         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
36375         FREE(untag_ptr(this_ptr));
36376         NetAddress_free(this_ptr_conv);
36377 }
36378
36379 static inline uint64_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
36380         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
36381         *ret_copy = NetAddress_clone(arg);
36382         int64_t ret_ref = tag_ptr(ret_copy, true);
36383         return ret_ref;
36384 }
36385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36386         LDKNetAddress* arg_conv = (LDKNetAddress*)untag_ptr(arg);
36387         int64_t ret_conv = NetAddress_clone_ptr(arg_conv);
36388         return ret_conv;
36389 }
36390
36391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36392         LDKNetAddress* orig_conv = (LDKNetAddress*)untag_ptr(orig);
36393         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
36394         *ret_copy = NetAddress_clone(orig_conv);
36395         int64_t ret_ref = tag_ptr(ret_copy, true);
36396         return ret_ref;
36397 }
36398
36399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
36400         LDKFourBytes addr_ref;
36401         CHECK((*env)->GetArrayLength(env, addr) == 4);
36402         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
36403         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
36404         *ret_copy = NetAddress_ipv4(addr_ref, port);
36405         int64_t ret_ref = tag_ptr(ret_copy, true);
36406         return ret_ref;
36407 }
36408
36409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
36410         LDKSixteenBytes addr_ref;
36411         CHECK((*env)->GetArrayLength(env, addr) == 16);
36412         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
36413         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
36414         *ret_copy = NetAddress_ipv6(addr_ref, port);
36415         int64_t ret_ref = tag_ptr(ret_copy, true);
36416         return ret_ref;
36417 }
36418
36419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray a) {
36420         LDKTwelveBytes a_ref;
36421         CHECK((*env)->GetArrayLength(env, a) == 12);
36422         (*env)->GetByteArrayRegion(env, a, 0, 12, a_ref.data);
36423         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
36424         *ret_copy = NetAddress_onion_v2(a_ref);
36425         int64_t ret_ref = tag_ptr(ret_copy, true);
36426         return ret_ref;
36427 }
36428
36429 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) {
36430         LDKThirtyTwoBytes ed25519_pubkey_ref;
36431         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
36432         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
36433         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
36434         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
36435         int64_t ret_ref = tag_ptr(ret_copy, true);
36436         return ret_ref;
36437 }
36438
36439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1hostname(JNIEnv *env, jclass clz, int64_t hostname, int16_t port) {
36440         LDKHostname hostname_conv;
36441         hostname_conv.inner = untag_ptr(hostname);
36442         hostname_conv.is_owned = ptr_is_owned(hostname);
36443         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_conv);
36444         hostname_conv = Hostname_clone(&hostname_conv);
36445         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
36446         *ret_copy = NetAddress_hostname(hostname_conv, port);
36447         int64_t ret_ref = tag_ptr(ret_copy, true);
36448         return ret_ref;
36449 }
36450
36451 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NetAddress_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36452         LDKNetAddress* a_conv = (LDKNetAddress*)untag_ptr(a);
36453         LDKNetAddress* b_conv = (LDKNetAddress*)untag_ptr(b);
36454         jboolean ret_conv = NetAddress_eq(a_conv, b_conv);
36455         return ret_conv;
36456 }
36457
36458 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
36459         LDKNetAddress* obj_conv = (LDKNetAddress*)untag_ptr(obj);
36460         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
36461         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36462         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36463         CVec_u8Z_free(ret_var);
36464         return ret_arr;
36465 }
36466
36467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36468         LDKu8slice ser_ref;
36469         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36470         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36471         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
36472         *ret_conv = NetAddress_read(ser_ref);
36473         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36474         return tag_ptr(ret_conv, true);
36475 }
36476
36477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36478         LDKUnsignedNodeAnnouncement this_obj_conv;
36479         this_obj_conv.inner = untag_ptr(this_obj);
36480         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36482         UnsignedNodeAnnouncement_free(this_obj_conv);
36483 }
36484
36485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
36486         LDKUnsignedNodeAnnouncement this_ptr_conv;
36487         this_ptr_conv.inner = untag_ptr(this_ptr);
36488         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36490         this_ptr_conv.is_owned = false;
36491         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
36492         int64_t ret_ref = 0;
36493         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36494         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36495         return ret_ref;
36496 }
36497
36498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36499         LDKUnsignedNodeAnnouncement this_ptr_conv;
36500         this_ptr_conv.inner = untag_ptr(this_ptr);
36501         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36503         this_ptr_conv.is_owned = false;
36504         LDKNodeFeatures val_conv;
36505         val_conv.inner = untag_ptr(val);
36506         val_conv.is_owned = ptr_is_owned(val);
36507         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36508         val_conv = NodeFeatures_clone(&val_conv);
36509         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
36510 }
36511
36512 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
36513         LDKUnsignedNodeAnnouncement this_ptr_conv;
36514         this_ptr_conv.inner = untag_ptr(this_ptr);
36515         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36517         this_ptr_conv.is_owned = false;
36518         int32_t ret_conv = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
36519         return ret_conv;
36520 }
36521
36522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36523         LDKUnsignedNodeAnnouncement this_ptr_conv;
36524         this_ptr_conv.inner = untag_ptr(this_ptr);
36525         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36527         this_ptr_conv.is_owned = false;
36528         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
36529 }
36530
36531 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36532         LDKUnsignedNodeAnnouncement this_ptr_conv;
36533         this_ptr_conv.inner = untag_ptr(this_ptr);
36534         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36536         this_ptr_conv.is_owned = false;
36537         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36538         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
36539         return ret_arr;
36540 }
36541
36542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36543         LDKUnsignedNodeAnnouncement this_ptr_conv;
36544         this_ptr_conv.inner = untag_ptr(this_ptr);
36545         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36547         this_ptr_conv.is_owned = false;
36548         LDKPublicKey val_ref;
36549         CHECK((*env)->GetArrayLength(env, val) == 33);
36550         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36551         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
36552 }
36553
36554 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
36555         LDKUnsignedNodeAnnouncement this_ptr_conv;
36556         this_ptr_conv.inner = untag_ptr(this_ptr);
36557         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36559         this_ptr_conv.is_owned = false;
36560         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
36561         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
36562         return ret_arr;
36563 }
36564
36565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36566         LDKUnsignedNodeAnnouncement this_ptr_conv;
36567         this_ptr_conv.inner = untag_ptr(this_ptr);
36568         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36570         this_ptr_conv.is_owned = false;
36571         LDKThreeBytes val_ref;
36572         CHECK((*env)->GetArrayLength(env, val) == 3);
36573         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
36574         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
36575 }
36576
36577 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
36578         LDKUnsignedNodeAnnouncement this_ptr_conv;
36579         this_ptr_conv.inner = untag_ptr(this_ptr);
36580         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36582         this_ptr_conv.is_owned = false;
36583         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36584         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
36585         return ret_arr;
36586 }
36587
36588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36589         LDKUnsignedNodeAnnouncement this_ptr_conv;
36590         this_ptr_conv.inner = untag_ptr(this_ptr);
36591         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36593         this_ptr_conv.is_owned = false;
36594         LDKThirtyTwoBytes val_ref;
36595         CHECK((*env)->GetArrayLength(env, val) == 32);
36596         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36597         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
36598 }
36599
36600 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr) {
36601         LDKUnsignedNodeAnnouncement this_ptr_conv;
36602         this_ptr_conv.inner = untag_ptr(this_ptr);
36603         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36605         this_ptr_conv.is_owned = false;
36606         LDKCVec_NetAddressZ ret_var = UnsignedNodeAnnouncement_get_addresses(&this_ptr_conv);
36607         int64_tArray ret_arr = NULL;
36608         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
36609         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
36610         for (size_t m = 0; m < ret_var.datalen; m++) {
36611                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
36612                 *ret_conv_12_copy = ret_var.data[m];
36613                 int64_t ret_conv_12_ref = tag_ptr(ret_conv_12_copy, true);
36614                 ret_arr_ptr[m] = ret_conv_12_ref;
36615         }
36616         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
36617         FREE(ret_var.data);
36618         return ret_arr;
36619 }
36620
36621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
36622         LDKUnsignedNodeAnnouncement this_ptr_conv;
36623         this_ptr_conv.inner = untag_ptr(this_ptr);
36624         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36626         this_ptr_conv.is_owned = false;
36627         LDKCVec_NetAddressZ val_constr;
36628         val_constr.datalen = (*env)->GetArrayLength(env, val);
36629         if (val_constr.datalen > 0)
36630                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
36631         else
36632                 val_constr.data = NULL;
36633         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
36634         for (size_t m = 0; m < val_constr.datalen; m++) {
36635                 int64_t val_conv_12 = val_vals[m];
36636                 void* val_conv_12_ptr = untag_ptr(val_conv_12);
36637                 CHECK_ACCESS(val_conv_12_ptr);
36638                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
36639                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(val_conv_12));
36640                 val_constr.data[m] = val_conv_12_conv;
36641         }
36642         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
36643         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
36644 }
36645
36646 static inline uint64_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
36647         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
36648         int64_t ret_ref = 0;
36649         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36650         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36651         return ret_ref;
36652 }
36653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36654         LDKUnsignedNodeAnnouncement arg_conv;
36655         arg_conv.inner = untag_ptr(arg);
36656         arg_conv.is_owned = ptr_is_owned(arg);
36657         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36658         arg_conv.is_owned = false;
36659         int64_t ret_conv = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
36660         return ret_conv;
36661 }
36662
36663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36664         LDKUnsignedNodeAnnouncement orig_conv;
36665         orig_conv.inner = untag_ptr(orig);
36666         orig_conv.is_owned = ptr_is_owned(orig);
36667         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36668         orig_conv.is_owned = false;
36669         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
36670         int64_t ret_ref = 0;
36671         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36672         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36673         return ret_ref;
36674 }
36675
36676 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36677         LDKUnsignedNodeAnnouncement a_conv;
36678         a_conv.inner = untag_ptr(a);
36679         a_conv.is_owned = ptr_is_owned(a);
36680         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36681         a_conv.is_owned = false;
36682         LDKUnsignedNodeAnnouncement b_conv;
36683         b_conv.inner = untag_ptr(b);
36684         b_conv.is_owned = ptr_is_owned(b);
36685         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36686         b_conv.is_owned = false;
36687         jboolean ret_conv = UnsignedNodeAnnouncement_eq(&a_conv, &b_conv);
36688         return ret_conv;
36689 }
36690
36691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36692         LDKNodeAnnouncement this_obj_conv;
36693         this_obj_conv.inner = untag_ptr(this_obj);
36694         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36696         NodeAnnouncement_free(this_obj_conv);
36697 }
36698
36699 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
36700         LDKNodeAnnouncement this_ptr_conv;
36701         this_ptr_conv.inner = untag_ptr(this_ptr);
36702         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36704         this_ptr_conv.is_owned = false;
36705         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36706         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
36707         return ret_arr;
36708 }
36709
36710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36711         LDKNodeAnnouncement this_ptr_conv;
36712         this_ptr_conv.inner = untag_ptr(this_ptr);
36713         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36715         this_ptr_conv.is_owned = false;
36716         LDKSignature val_ref;
36717         CHECK((*env)->GetArrayLength(env, val) == 64);
36718         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36719         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
36720 }
36721
36722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
36723         LDKNodeAnnouncement this_ptr_conv;
36724         this_ptr_conv.inner = untag_ptr(this_ptr);
36725         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36727         this_ptr_conv.is_owned = false;
36728         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
36729         int64_t ret_ref = 0;
36730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36731         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36732         return ret_ref;
36733 }
36734
36735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36736         LDKNodeAnnouncement this_ptr_conv;
36737         this_ptr_conv.inner = untag_ptr(this_ptr);
36738         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36740         this_ptr_conv.is_owned = false;
36741         LDKUnsignedNodeAnnouncement val_conv;
36742         val_conv.inner = untag_ptr(val);
36743         val_conv.is_owned = ptr_is_owned(val);
36744         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36745         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
36746         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
36747 }
36748
36749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
36750         LDKSignature signature_arg_ref;
36751         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
36752         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
36753         LDKUnsignedNodeAnnouncement contents_arg_conv;
36754         contents_arg_conv.inner = untag_ptr(contents_arg);
36755         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
36756         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
36757         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
36758         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
36759         int64_t ret_ref = 0;
36760         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36761         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36762         return ret_ref;
36763 }
36764
36765 static inline uint64_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
36766         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
36767         int64_t ret_ref = 0;
36768         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36769         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36770         return ret_ref;
36771 }
36772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36773         LDKNodeAnnouncement arg_conv;
36774         arg_conv.inner = untag_ptr(arg);
36775         arg_conv.is_owned = ptr_is_owned(arg);
36776         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36777         arg_conv.is_owned = false;
36778         int64_t ret_conv = NodeAnnouncement_clone_ptr(&arg_conv);
36779         return ret_conv;
36780 }
36781
36782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36783         LDKNodeAnnouncement orig_conv;
36784         orig_conv.inner = untag_ptr(orig);
36785         orig_conv.is_owned = ptr_is_owned(orig);
36786         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36787         orig_conv.is_owned = false;
36788         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
36789         int64_t ret_ref = 0;
36790         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36791         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36792         return ret_ref;
36793 }
36794
36795 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36796         LDKNodeAnnouncement a_conv;
36797         a_conv.inner = untag_ptr(a);
36798         a_conv.is_owned = ptr_is_owned(a);
36799         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36800         a_conv.is_owned = false;
36801         LDKNodeAnnouncement b_conv;
36802         b_conv.inner = untag_ptr(b);
36803         b_conv.is_owned = ptr_is_owned(b);
36804         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36805         b_conv.is_owned = false;
36806         jboolean ret_conv = NodeAnnouncement_eq(&a_conv, &b_conv);
36807         return ret_conv;
36808 }
36809
36810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36811         LDKUnsignedChannelAnnouncement this_obj_conv;
36812         this_obj_conv.inner = untag_ptr(this_obj);
36813         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36815         UnsignedChannelAnnouncement_free(this_obj_conv);
36816 }
36817
36818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
36819         LDKUnsignedChannelAnnouncement this_ptr_conv;
36820         this_ptr_conv.inner = untag_ptr(this_ptr);
36821         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36823         this_ptr_conv.is_owned = false;
36824         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
36825         int64_t ret_ref = 0;
36826         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36827         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36828         return ret_ref;
36829 }
36830
36831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36832         LDKUnsignedChannelAnnouncement this_ptr_conv;
36833         this_ptr_conv.inner = untag_ptr(this_ptr);
36834         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36836         this_ptr_conv.is_owned = false;
36837         LDKChannelFeatures val_conv;
36838         val_conv.inner = untag_ptr(val);
36839         val_conv.is_owned = ptr_is_owned(val);
36840         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36841         val_conv = ChannelFeatures_clone(&val_conv);
36842         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
36843 }
36844
36845 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36846         LDKUnsignedChannelAnnouncement this_ptr_conv;
36847         this_ptr_conv.inner = untag_ptr(this_ptr);
36848         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36850         this_ptr_conv.is_owned = false;
36851         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36852         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
36853         return ret_arr;
36854 }
36855
36856 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36857         LDKUnsignedChannelAnnouncement this_ptr_conv;
36858         this_ptr_conv.inner = untag_ptr(this_ptr);
36859         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36861         this_ptr_conv.is_owned = false;
36862         LDKThirtyTwoBytes val_ref;
36863         CHECK((*env)->GetArrayLength(env, val) == 32);
36864         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36865         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
36866 }
36867
36868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36869         LDKUnsignedChannelAnnouncement this_ptr_conv;
36870         this_ptr_conv.inner = untag_ptr(this_ptr);
36871         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36873         this_ptr_conv.is_owned = false;
36874         int64_t ret_conv = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
36875         return ret_conv;
36876 }
36877
36878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36879         LDKUnsignedChannelAnnouncement this_ptr_conv;
36880         this_ptr_conv.inner = untag_ptr(this_ptr);
36881         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36883         this_ptr_conv.is_owned = false;
36884         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
36885 }
36886
36887 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
36888         LDKUnsignedChannelAnnouncement this_ptr_conv;
36889         this_ptr_conv.inner = untag_ptr(this_ptr);
36890         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36892         this_ptr_conv.is_owned = false;
36893         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36894         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
36895         return ret_arr;
36896 }
36897
36898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36899         LDKUnsignedChannelAnnouncement this_ptr_conv;
36900         this_ptr_conv.inner = untag_ptr(this_ptr);
36901         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36903         this_ptr_conv.is_owned = false;
36904         LDKPublicKey val_ref;
36905         CHECK((*env)->GetArrayLength(env, val) == 33);
36906         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36907         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
36908 }
36909
36910 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
36911         LDKUnsignedChannelAnnouncement this_ptr_conv;
36912         this_ptr_conv.inner = untag_ptr(this_ptr);
36913         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36915         this_ptr_conv.is_owned = false;
36916         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36917         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
36918         return ret_arr;
36919 }
36920
36921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36922         LDKUnsignedChannelAnnouncement this_ptr_conv;
36923         this_ptr_conv.inner = untag_ptr(this_ptr);
36924         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36926         this_ptr_conv.is_owned = false;
36927         LDKPublicKey val_ref;
36928         CHECK((*env)->GetArrayLength(env, val) == 33);
36929         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36930         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
36931 }
36932
36933 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
36934         LDKUnsignedChannelAnnouncement this_ptr_conv;
36935         this_ptr_conv.inner = untag_ptr(this_ptr);
36936         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36938         this_ptr_conv.is_owned = false;
36939         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36940         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
36941         return ret_arr;
36942 }
36943
36944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36945         LDKUnsignedChannelAnnouncement this_ptr_conv;
36946         this_ptr_conv.inner = untag_ptr(this_ptr);
36947         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36949         this_ptr_conv.is_owned = false;
36950         LDKPublicKey val_ref;
36951         CHECK((*env)->GetArrayLength(env, val) == 33);
36952         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36953         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
36954 }
36955
36956 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
36957         LDKUnsignedChannelAnnouncement this_ptr_conv;
36958         this_ptr_conv.inner = untag_ptr(this_ptr);
36959         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36961         this_ptr_conv.is_owned = false;
36962         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36963         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
36964         return ret_arr;
36965 }
36966
36967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36968         LDKUnsignedChannelAnnouncement this_ptr_conv;
36969         this_ptr_conv.inner = untag_ptr(this_ptr);
36970         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36972         this_ptr_conv.is_owned = false;
36973         LDKPublicKey val_ref;
36974         CHECK((*env)->GetArrayLength(env, val) == 33);
36975         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36976         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
36977 }
36978
36979 static inline uint64_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
36980         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
36981         int64_t ret_ref = 0;
36982         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36983         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36984         return ret_ref;
36985 }
36986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36987         LDKUnsignedChannelAnnouncement arg_conv;
36988         arg_conv.inner = untag_ptr(arg);
36989         arg_conv.is_owned = ptr_is_owned(arg);
36990         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36991         arg_conv.is_owned = false;
36992         int64_t ret_conv = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
36993         return ret_conv;
36994 }
36995
36996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36997         LDKUnsignedChannelAnnouncement orig_conv;
36998         orig_conv.inner = untag_ptr(orig);
36999         orig_conv.is_owned = ptr_is_owned(orig);
37000         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37001         orig_conv.is_owned = false;
37002         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
37003         int64_t ret_ref = 0;
37004         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37005         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37006         return ret_ref;
37007 }
37008
37009 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37010         LDKUnsignedChannelAnnouncement a_conv;
37011         a_conv.inner = untag_ptr(a);
37012         a_conv.is_owned = ptr_is_owned(a);
37013         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37014         a_conv.is_owned = false;
37015         LDKUnsignedChannelAnnouncement b_conv;
37016         b_conv.inner = untag_ptr(b);
37017         b_conv.is_owned = ptr_is_owned(b);
37018         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37019         b_conv.is_owned = false;
37020         jboolean ret_conv = UnsignedChannelAnnouncement_eq(&a_conv, &b_conv);
37021         return ret_conv;
37022 }
37023
37024 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37025         LDKChannelAnnouncement this_obj_conv;
37026         this_obj_conv.inner = untag_ptr(this_obj);
37027         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37029         ChannelAnnouncement_free(this_obj_conv);
37030 }
37031
37032 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
37033         LDKChannelAnnouncement this_ptr_conv;
37034         this_ptr_conv.inner = untag_ptr(this_ptr);
37035         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37037         this_ptr_conv.is_owned = false;
37038         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
37039         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
37040         return ret_arr;
37041 }
37042
37043 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37044         LDKChannelAnnouncement this_ptr_conv;
37045         this_ptr_conv.inner = untag_ptr(this_ptr);
37046         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37048         this_ptr_conv.is_owned = false;
37049         LDKSignature val_ref;
37050         CHECK((*env)->GetArrayLength(env, val) == 64);
37051         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
37052         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
37053 }
37054
37055 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
37056         LDKChannelAnnouncement this_ptr_conv;
37057         this_ptr_conv.inner = untag_ptr(this_ptr);
37058         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37060         this_ptr_conv.is_owned = false;
37061         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
37062         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
37063         return ret_arr;
37064 }
37065
37066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37067         LDKChannelAnnouncement this_ptr_conv;
37068         this_ptr_conv.inner = untag_ptr(this_ptr);
37069         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37071         this_ptr_conv.is_owned = false;
37072         LDKSignature val_ref;
37073         CHECK((*env)->GetArrayLength(env, val) == 64);
37074         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
37075         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
37076 }
37077
37078 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
37079         LDKChannelAnnouncement this_ptr_conv;
37080         this_ptr_conv.inner = untag_ptr(this_ptr);
37081         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37083         this_ptr_conv.is_owned = false;
37084         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
37085         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
37086         return ret_arr;
37087 }
37088
37089 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37090         LDKChannelAnnouncement this_ptr_conv;
37091         this_ptr_conv.inner = untag_ptr(this_ptr);
37092         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37094         this_ptr_conv.is_owned = false;
37095         LDKSignature val_ref;
37096         CHECK((*env)->GetArrayLength(env, val) == 64);
37097         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
37098         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
37099 }
37100
37101 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
37102         LDKChannelAnnouncement this_ptr_conv;
37103         this_ptr_conv.inner = untag_ptr(this_ptr);
37104         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37106         this_ptr_conv.is_owned = false;
37107         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
37108         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
37109         return ret_arr;
37110 }
37111
37112 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37113         LDKChannelAnnouncement this_ptr_conv;
37114         this_ptr_conv.inner = untag_ptr(this_ptr);
37115         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37117         this_ptr_conv.is_owned = false;
37118         LDKSignature val_ref;
37119         CHECK((*env)->GetArrayLength(env, val) == 64);
37120         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
37121         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
37122 }
37123
37124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
37125         LDKChannelAnnouncement this_ptr_conv;
37126         this_ptr_conv.inner = untag_ptr(this_ptr);
37127         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37129         this_ptr_conv.is_owned = false;
37130         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
37131         int64_t ret_ref = 0;
37132         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37133         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37134         return ret_ref;
37135 }
37136
37137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37138         LDKChannelAnnouncement this_ptr_conv;
37139         this_ptr_conv.inner = untag_ptr(this_ptr);
37140         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37142         this_ptr_conv.is_owned = false;
37143         LDKUnsignedChannelAnnouncement val_conv;
37144         val_conv.inner = untag_ptr(val);
37145         val_conv.is_owned = ptr_is_owned(val);
37146         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37147         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
37148         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
37149 }
37150
37151 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) {
37152         LDKSignature node_signature_1_arg_ref;
37153         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
37154         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
37155         LDKSignature node_signature_2_arg_ref;
37156         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
37157         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
37158         LDKSignature bitcoin_signature_1_arg_ref;
37159         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
37160         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
37161         LDKSignature bitcoin_signature_2_arg_ref;
37162         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
37163         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
37164         LDKUnsignedChannelAnnouncement contents_arg_conv;
37165         contents_arg_conv.inner = untag_ptr(contents_arg);
37166         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
37167         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
37168         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
37169         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);
37170         int64_t ret_ref = 0;
37171         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37172         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37173         return ret_ref;
37174 }
37175
37176 static inline uint64_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
37177         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
37178         int64_t ret_ref = 0;
37179         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37180         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37181         return ret_ref;
37182 }
37183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37184         LDKChannelAnnouncement arg_conv;
37185         arg_conv.inner = untag_ptr(arg);
37186         arg_conv.is_owned = ptr_is_owned(arg);
37187         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37188         arg_conv.is_owned = false;
37189         int64_t ret_conv = ChannelAnnouncement_clone_ptr(&arg_conv);
37190         return ret_conv;
37191 }
37192
37193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37194         LDKChannelAnnouncement orig_conv;
37195         orig_conv.inner = untag_ptr(orig);
37196         orig_conv.is_owned = ptr_is_owned(orig);
37197         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37198         orig_conv.is_owned = false;
37199         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
37200         int64_t ret_ref = 0;
37201         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37202         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37203         return ret_ref;
37204 }
37205
37206 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37207         LDKChannelAnnouncement a_conv;
37208         a_conv.inner = untag_ptr(a);
37209         a_conv.is_owned = ptr_is_owned(a);
37210         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37211         a_conv.is_owned = false;
37212         LDKChannelAnnouncement b_conv;
37213         b_conv.inner = untag_ptr(b);
37214         b_conv.is_owned = ptr_is_owned(b);
37215         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37216         b_conv.is_owned = false;
37217         jboolean ret_conv = ChannelAnnouncement_eq(&a_conv, &b_conv);
37218         return ret_conv;
37219 }
37220
37221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37222         LDKUnsignedChannelUpdate this_obj_conv;
37223         this_obj_conv.inner = untag_ptr(this_obj);
37224         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37226         UnsignedChannelUpdate_free(this_obj_conv);
37227 }
37228
37229 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
37230         LDKUnsignedChannelUpdate this_ptr_conv;
37231         this_ptr_conv.inner = untag_ptr(this_ptr);
37232         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37234         this_ptr_conv.is_owned = false;
37235         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37236         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
37237         return ret_arr;
37238 }
37239
37240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37241         LDKUnsignedChannelUpdate this_ptr_conv;
37242         this_ptr_conv.inner = untag_ptr(this_ptr);
37243         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37245         this_ptr_conv.is_owned = false;
37246         LDKThirtyTwoBytes val_ref;
37247         CHECK((*env)->GetArrayLength(env, val) == 32);
37248         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37249         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
37250 }
37251
37252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37253         LDKUnsignedChannelUpdate this_ptr_conv;
37254         this_ptr_conv.inner = untag_ptr(this_ptr);
37255         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37257         this_ptr_conv.is_owned = false;
37258         int64_t ret_conv = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
37259         return ret_conv;
37260 }
37261
37262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37263         LDKUnsignedChannelUpdate this_ptr_conv;
37264         this_ptr_conv.inner = untag_ptr(this_ptr);
37265         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37267         this_ptr_conv.is_owned = false;
37268         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
37269 }
37270
37271 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
37272         LDKUnsignedChannelUpdate this_ptr_conv;
37273         this_ptr_conv.inner = untag_ptr(this_ptr);
37274         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37276         this_ptr_conv.is_owned = false;
37277         int32_t ret_conv = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
37278         return ret_conv;
37279 }
37280
37281 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
37282         LDKUnsignedChannelUpdate this_ptr_conv;
37283         this_ptr_conv.inner = untag_ptr(this_ptr);
37284         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37286         this_ptr_conv.is_owned = false;
37287         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
37288 }
37289
37290 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
37291         LDKUnsignedChannelUpdate this_ptr_conv;
37292         this_ptr_conv.inner = untag_ptr(this_ptr);
37293         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37295         this_ptr_conv.is_owned = false;
37296         int8_t ret_conv = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
37297         return ret_conv;
37298 }
37299
37300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
37301         LDKUnsignedChannelUpdate 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         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
37307 }
37308
37309 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
37310         LDKUnsignedChannelUpdate this_ptr_conv;
37311         this_ptr_conv.inner = untag_ptr(this_ptr);
37312         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37314         this_ptr_conv.is_owned = false;
37315         int16_t ret_conv = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
37316         return ret_conv;
37317 }
37318
37319 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
37320         LDKUnsignedChannelUpdate this_ptr_conv;
37321         this_ptr_conv.inner = untag_ptr(this_ptr);
37322         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37324         this_ptr_conv.is_owned = false;
37325         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
37326 }
37327
37328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
37329         LDKUnsignedChannelUpdate this_ptr_conv;
37330         this_ptr_conv.inner = untag_ptr(this_ptr);
37331         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37333         this_ptr_conv.is_owned = false;
37334         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
37335         return ret_conv;
37336 }
37337
37338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37339         LDKUnsignedChannelUpdate this_ptr_conv;
37340         this_ptr_conv.inner = untag_ptr(this_ptr);
37341         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37343         this_ptr_conv.is_owned = false;
37344         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
37345 }
37346
37347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
37348         LDKUnsignedChannelUpdate this_ptr_conv;
37349         this_ptr_conv.inner = untag_ptr(this_ptr);
37350         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37352         this_ptr_conv.is_owned = false;
37353         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_maximum_msat(&this_ptr_conv);
37354         return ret_conv;
37355 }
37356
37357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37358         LDKUnsignedChannelUpdate 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         UnsignedChannelUpdate_set_htlc_maximum_msat(&this_ptr_conv, val);
37364 }
37365
37366 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
37367         LDKUnsignedChannelUpdate this_ptr_conv;
37368         this_ptr_conv.inner = untag_ptr(this_ptr);
37369         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37371         this_ptr_conv.is_owned = false;
37372         int32_t ret_conv = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
37373         return ret_conv;
37374 }
37375
37376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
37377         LDKUnsignedChannelUpdate this_ptr_conv;
37378         this_ptr_conv.inner = untag_ptr(this_ptr);
37379         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37381         this_ptr_conv.is_owned = false;
37382         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
37383 }
37384
37385 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
37386         LDKUnsignedChannelUpdate this_ptr_conv;
37387         this_ptr_conv.inner = untag_ptr(this_ptr);
37388         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37390         this_ptr_conv.is_owned = false;
37391         int32_t ret_conv = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
37392         return ret_conv;
37393 }
37394
37395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
37396         LDKUnsignedChannelUpdate this_ptr_conv;
37397         this_ptr_conv.inner = untag_ptr(this_ptr);
37398         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37400         this_ptr_conv.is_owned = false;
37401         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
37402 }
37403
37404 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1excess_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
37405         LDKUnsignedChannelUpdate this_ptr_conv;
37406         this_ptr_conv.inner = untag_ptr(this_ptr);
37407         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37409         this_ptr_conv.is_owned = false;
37410         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_get_excess_data(&this_ptr_conv);
37411         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37412         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37413         CVec_u8Z_free(ret_var);
37414         return ret_arr;
37415 }
37416
37417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1excess_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37418         LDKUnsignedChannelUpdate this_ptr_conv;
37419         this_ptr_conv.inner = untag_ptr(this_ptr);
37420         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37422         this_ptr_conv.is_owned = false;
37423         LDKCVec_u8Z val_ref;
37424         val_ref.datalen = (*env)->GetArrayLength(env, val);
37425         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
37426         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
37427         UnsignedChannelUpdate_set_excess_data(&this_ptr_conv, val_ref);
37428 }
37429
37430 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) {
37431         LDKThirtyTwoBytes chain_hash_arg_ref;
37432         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
37433         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
37434         LDKCVec_u8Z excess_data_arg_ref;
37435         excess_data_arg_ref.datalen = (*env)->GetArrayLength(env, excess_data_arg);
37436         excess_data_arg_ref.data = MALLOC(excess_data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
37437         (*env)->GetByteArrayRegion(env, excess_data_arg, 0, excess_data_arg_ref.datalen, excess_data_arg_ref.data);
37438         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);
37439         int64_t ret_ref = 0;
37440         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37441         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37442         return ret_ref;
37443 }
37444
37445 static inline uint64_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
37446         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
37447         int64_t ret_ref = 0;
37448         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37449         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37450         return ret_ref;
37451 }
37452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37453         LDKUnsignedChannelUpdate arg_conv;
37454         arg_conv.inner = untag_ptr(arg);
37455         arg_conv.is_owned = ptr_is_owned(arg);
37456         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37457         arg_conv.is_owned = false;
37458         int64_t ret_conv = UnsignedChannelUpdate_clone_ptr(&arg_conv);
37459         return ret_conv;
37460 }
37461
37462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37463         LDKUnsignedChannelUpdate orig_conv;
37464         orig_conv.inner = untag_ptr(orig);
37465         orig_conv.is_owned = ptr_is_owned(orig);
37466         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37467         orig_conv.is_owned = false;
37468         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
37469         int64_t ret_ref = 0;
37470         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37471         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37472         return ret_ref;
37473 }
37474
37475 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37476         LDKUnsignedChannelUpdate a_conv;
37477         a_conv.inner = untag_ptr(a);
37478         a_conv.is_owned = ptr_is_owned(a);
37479         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37480         a_conv.is_owned = false;
37481         LDKUnsignedChannelUpdate b_conv;
37482         b_conv.inner = untag_ptr(b);
37483         b_conv.is_owned = ptr_is_owned(b);
37484         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37485         b_conv.is_owned = false;
37486         jboolean ret_conv = UnsignedChannelUpdate_eq(&a_conv, &b_conv);
37487         return ret_conv;
37488 }
37489
37490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37491         LDKChannelUpdate this_obj_conv;
37492         this_obj_conv.inner = untag_ptr(this_obj);
37493         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37495         ChannelUpdate_free(this_obj_conv);
37496 }
37497
37498 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
37499         LDKChannelUpdate this_ptr_conv;
37500         this_ptr_conv.inner = untag_ptr(this_ptr);
37501         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37503         this_ptr_conv.is_owned = false;
37504         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
37505         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
37506         return ret_arr;
37507 }
37508
37509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37510         LDKChannelUpdate this_ptr_conv;
37511         this_ptr_conv.inner = untag_ptr(this_ptr);
37512         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37514         this_ptr_conv.is_owned = false;
37515         LDKSignature val_ref;
37516         CHECK((*env)->GetArrayLength(env, val) == 64);
37517         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
37518         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
37519 }
37520
37521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
37522         LDKChannelUpdate this_ptr_conv;
37523         this_ptr_conv.inner = untag_ptr(this_ptr);
37524         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37526         this_ptr_conv.is_owned = false;
37527         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
37528         int64_t ret_ref = 0;
37529         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37530         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37531         return ret_ref;
37532 }
37533
37534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37535         LDKChannelUpdate this_ptr_conv;
37536         this_ptr_conv.inner = untag_ptr(this_ptr);
37537         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37539         this_ptr_conv.is_owned = false;
37540         LDKUnsignedChannelUpdate val_conv;
37541         val_conv.inner = untag_ptr(val);
37542         val_conv.is_owned = ptr_is_owned(val);
37543         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37544         val_conv = UnsignedChannelUpdate_clone(&val_conv);
37545         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
37546 }
37547
37548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
37549         LDKSignature signature_arg_ref;
37550         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
37551         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
37552         LDKUnsignedChannelUpdate contents_arg_conv;
37553         contents_arg_conv.inner = untag_ptr(contents_arg);
37554         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
37555         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
37556         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
37557         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
37558         int64_t ret_ref = 0;
37559         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37560         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37561         return ret_ref;
37562 }
37563
37564 static inline uint64_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
37565         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
37566         int64_t ret_ref = 0;
37567         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37568         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37569         return ret_ref;
37570 }
37571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37572         LDKChannelUpdate arg_conv;
37573         arg_conv.inner = untag_ptr(arg);
37574         arg_conv.is_owned = ptr_is_owned(arg);
37575         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37576         arg_conv.is_owned = false;
37577         int64_t ret_conv = ChannelUpdate_clone_ptr(&arg_conv);
37578         return ret_conv;
37579 }
37580
37581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37582         LDKChannelUpdate orig_conv;
37583         orig_conv.inner = untag_ptr(orig);
37584         orig_conv.is_owned = ptr_is_owned(orig);
37585         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37586         orig_conv.is_owned = false;
37587         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
37588         int64_t ret_ref = 0;
37589         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37590         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37591         return ret_ref;
37592 }
37593
37594 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37595         LDKChannelUpdate a_conv;
37596         a_conv.inner = untag_ptr(a);
37597         a_conv.is_owned = ptr_is_owned(a);
37598         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37599         a_conv.is_owned = false;
37600         LDKChannelUpdate b_conv;
37601         b_conv.inner = untag_ptr(b);
37602         b_conv.is_owned = ptr_is_owned(b);
37603         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37604         b_conv.is_owned = false;
37605         jboolean ret_conv = ChannelUpdate_eq(&a_conv, &b_conv);
37606         return ret_conv;
37607 }
37608
37609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37610         LDKQueryChannelRange this_obj_conv;
37611         this_obj_conv.inner = untag_ptr(this_obj);
37612         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37614         QueryChannelRange_free(this_obj_conv);
37615 }
37616
37617 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
37618         LDKQueryChannelRange this_ptr_conv;
37619         this_ptr_conv.inner = untag_ptr(this_ptr);
37620         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37622         this_ptr_conv.is_owned = false;
37623         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37624         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
37625         return ret_arr;
37626 }
37627
37628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37629         LDKQueryChannelRange this_ptr_conv;
37630         this_ptr_conv.inner = untag_ptr(this_ptr);
37631         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37633         this_ptr_conv.is_owned = false;
37634         LDKThirtyTwoBytes val_ref;
37635         CHECK((*env)->GetArrayLength(env, val) == 32);
37636         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37637         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
37638 }
37639
37640 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
37641         LDKQueryChannelRange this_ptr_conv;
37642         this_ptr_conv.inner = untag_ptr(this_ptr);
37643         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37645         this_ptr_conv.is_owned = false;
37646         int32_t ret_conv = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
37647         return ret_conv;
37648 }
37649
37650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
37651         LDKQueryChannelRange this_ptr_conv;
37652         this_ptr_conv.inner = untag_ptr(this_ptr);
37653         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37655         this_ptr_conv.is_owned = false;
37656         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
37657 }
37658
37659 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
37660         LDKQueryChannelRange this_ptr_conv;
37661         this_ptr_conv.inner = untag_ptr(this_ptr);
37662         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37664         this_ptr_conv.is_owned = false;
37665         int32_t ret_conv = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
37666         return ret_conv;
37667 }
37668
37669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
37670         LDKQueryChannelRange this_ptr_conv;
37671         this_ptr_conv.inner = untag_ptr(this_ptr);
37672         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37674         this_ptr_conv.is_owned = false;
37675         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
37676 }
37677
37678 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) {
37679         LDKThirtyTwoBytes chain_hash_arg_ref;
37680         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
37681         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
37682         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
37683         int64_t ret_ref = 0;
37684         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37685         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37686         return ret_ref;
37687 }
37688
37689 static inline uint64_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
37690         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
37691         int64_t ret_ref = 0;
37692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37693         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37694         return ret_ref;
37695 }
37696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37697         LDKQueryChannelRange arg_conv;
37698         arg_conv.inner = untag_ptr(arg);
37699         arg_conv.is_owned = ptr_is_owned(arg);
37700         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37701         arg_conv.is_owned = false;
37702         int64_t ret_conv = QueryChannelRange_clone_ptr(&arg_conv);
37703         return ret_conv;
37704 }
37705
37706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37707         LDKQueryChannelRange orig_conv;
37708         orig_conv.inner = untag_ptr(orig);
37709         orig_conv.is_owned = ptr_is_owned(orig);
37710         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37711         orig_conv.is_owned = false;
37712         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
37713         int64_t ret_ref = 0;
37714         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37715         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37716         return ret_ref;
37717 }
37718
37719 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37720         LDKQueryChannelRange a_conv;
37721         a_conv.inner = untag_ptr(a);
37722         a_conv.is_owned = ptr_is_owned(a);
37723         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37724         a_conv.is_owned = false;
37725         LDKQueryChannelRange b_conv;
37726         b_conv.inner = untag_ptr(b);
37727         b_conv.is_owned = ptr_is_owned(b);
37728         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37729         b_conv.is_owned = false;
37730         jboolean ret_conv = QueryChannelRange_eq(&a_conv, &b_conv);
37731         return ret_conv;
37732 }
37733
37734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37735         LDKReplyChannelRange this_obj_conv;
37736         this_obj_conv.inner = untag_ptr(this_obj);
37737         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37739         ReplyChannelRange_free(this_obj_conv);
37740 }
37741
37742 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
37743         LDKReplyChannelRange this_ptr_conv;
37744         this_ptr_conv.inner = untag_ptr(this_ptr);
37745         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37747         this_ptr_conv.is_owned = false;
37748         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37749         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
37750         return ret_arr;
37751 }
37752
37753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37754         LDKReplyChannelRange this_ptr_conv;
37755         this_ptr_conv.inner = untag_ptr(this_ptr);
37756         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37758         this_ptr_conv.is_owned = false;
37759         LDKThirtyTwoBytes val_ref;
37760         CHECK((*env)->GetArrayLength(env, val) == 32);
37761         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37762         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
37763 }
37764
37765 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
37766         LDKReplyChannelRange this_ptr_conv;
37767         this_ptr_conv.inner = untag_ptr(this_ptr);
37768         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37770         this_ptr_conv.is_owned = false;
37771         int32_t ret_conv = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
37772         return ret_conv;
37773 }
37774
37775 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
37776         LDKReplyChannelRange this_ptr_conv;
37777         this_ptr_conv.inner = untag_ptr(this_ptr);
37778         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37780         this_ptr_conv.is_owned = false;
37781         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
37782 }
37783
37784 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
37785         LDKReplyChannelRange this_ptr_conv;
37786         this_ptr_conv.inner = untag_ptr(this_ptr);
37787         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37789         this_ptr_conv.is_owned = false;
37790         int32_t ret_conv = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
37791         return ret_conv;
37792 }
37793
37794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
37795         LDKReplyChannelRange this_ptr_conv;
37796         this_ptr_conv.inner = untag_ptr(this_ptr);
37797         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37799         this_ptr_conv.is_owned = false;
37800         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
37801 }
37802
37803 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
37804         LDKReplyChannelRange this_ptr_conv;
37805         this_ptr_conv.inner = untag_ptr(this_ptr);
37806         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37808         this_ptr_conv.is_owned = false;
37809         jboolean ret_conv = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
37810         return ret_conv;
37811 }
37812
37813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
37814         LDKReplyChannelRange this_ptr_conv;
37815         this_ptr_conv.inner = untag_ptr(this_ptr);
37816         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37818         this_ptr_conv.is_owned = false;
37819         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
37820 }
37821
37822 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr) {
37823         LDKReplyChannelRange this_ptr_conv;
37824         this_ptr_conv.inner = untag_ptr(this_ptr);
37825         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37827         this_ptr_conv.is_owned = false;
37828         LDKCVec_u64Z ret_var = ReplyChannelRange_get_short_channel_ids(&this_ptr_conv);
37829         int64_tArray ret_arr = NULL;
37830         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
37831         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
37832         for (size_t g = 0; g < ret_var.datalen; g++) {
37833                 int64_t ret_conv_6_conv = ret_var.data[g];
37834                 ret_arr_ptr[g] = ret_conv_6_conv;
37835         }
37836         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
37837         FREE(ret_var.data);
37838         return ret_arr;
37839 }
37840
37841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
37842         LDKReplyChannelRange this_ptr_conv;
37843         this_ptr_conv.inner = untag_ptr(this_ptr);
37844         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37846         this_ptr_conv.is_owned = false;
37847         LDKCVec_u64Z val_constr;
37848         val_constr.datalen = (*env)->GetArrayLength(env, val);
37849         if (val_constr.datalen > 0)
37850                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
37851         else
37852                 val_constr.data = NULL;
37853         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
37854         for (size_t g = 0; g < val_constr.datalen; g++) {
37855                 int64_t val_conv_6 = val_vals[g];
37856                 val_constr.data[g] = val_conv_6;
37857         }
37858         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
37859         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
37860 }
37861
37862 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) {
37863         LDKThirtyTwoBytes chain_hash_arg_ref;
37864         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
37865         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
37866         LDKCVec_u64Z short_channel_ids_arg_constr;
37867         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
37868         if (short_channel_ids_arg_constr.datalen > 0)
37869                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
37870         else
37871                 short_channel_ids_arg_constr.data = NULL;
37872         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
37873         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
37874                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
37875                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
37876         }
37877         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
37878         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
37879         int64_t ret_ref = 0;
37880         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37881         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37882         return ret_ref;
37883 }
37884
37885 static inline uint64_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
37886         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
37887         int64_t ret_ref = 0;
37888         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37889         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37890         return ret_ref;
37891 }
37892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37893         LDKReplyChannelRange arg_conv;
37894         arg_conv.inner = untag_ptr(arg);
37895         arg_conv.is_owned = ptr_is_owned(arg);
37896         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37897         arg_conv.is_owned = false;
37898         int64_t ret_conv = ReplyChannelRange_clone_ptr(&arg_conv);
37899         return ret_conv;
37900 }
37901
37902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37903         LDKReplyChannelRange orig_conv;
37904         orig_conv.inner = untag_ptr(orig);
37905         orig_conv.is_owned = ptr_is_owned(orig);
37906         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37907         orig_conv.is_owned = false;
37908         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
37909         int64_t ret_ref = 0;
37910         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37911         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37912         return ret_ref;
37913 }
37914
37915 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37916         LDKReplyChannelRange a_conv;
37917         a_conv.inner = untag_ptr(a);
37918         a_conv.is_owned = ptr_is_owned(a);
37919         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37920         a_conv.is_owned = false;
37921         LDKReplyChannelRange b_conv;
37922         b_conv.inner = untag_ptr(b);
37923         b_conv.is_owned = ptr_is_owned(b);
37924         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37925         b_conv.is_owned = false;
37926         jboolean ret_conv = ReplyChannelRange_eq(&a_conv, &b_conv);
37927         return ret_conv;
37928 }
37929
37930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37931         LDKQueryShortChannelIds this_obj_conv;
37932         this_obj_conv.inner = untag_ptr(this_obj);
37933         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37935         QueryShortChannelIds_free(this_obj_conv);
37936 }
37937
37938 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
37939         LDKQueryShortChannelIds this_ptr_conv;
37940         this_ptr_conv.inner = untag_ptr(this_ptr);
37941         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37943         this_ptr_conv.is_owned = false;
37944         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37945         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
37946         return ret_arr;
37947 }
37948
37949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37950         LDKQueryShortChannelIds this_ptr_conv;
37951         this_ptr_conv.inner = untag_ptr(this_ptr);
37952         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37954         this_ptr_conv.is_owned = false;
37955         LDKThirtyTwoBytes val_ref;
37956         CHECK((*env)->GetArrayLength(env, val) == 32);
37957         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37958         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
37959 }
37960
37961 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr) {
37962         LDKQueryShortChannelIds this_ptr_conv;
37963         this_ptr_conv.inner = untag_ptr(this_ptr);
37964         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37966         this_ptr_conv.is_owned = false;
37967         LDKCVec_u64Z ret_var = QueryShortChannelIds_get_short_channel_ids(&this_ptr_conv);
37968         int64_tArray ret_arr = NULL;
37969         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
37970         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
37971         for (size_t g = 0; g < ret_var.datalen; g++) {
37972                 int64_t ret_conv_6_conv = ret_var.data[g];
37973                 ret_arr_ptr[g] = ret_conv_6_conv;
37974         }
37975         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
37976         FREE(ret_var.data);
37977         return ret_arr;
37978 }
37979
37980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
37981         LDKQueryShortChannelIds this_ptr_conv;
37982         this_ptr_conv.inner = untag_ptr(this_ptr);
37983         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37985         this_ptr_conv.is_owned = false;
37986         LDKCVec_u64Z val_constr;
37987         val_constr.datalen = (*env)->GetArrayLength(env, val);
37988         if (val_constr.datalen > 0)
37989                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
37990         else
37991                 val_constr.data = NULL;
37992         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
37993         for (size_t g = 0; g < val_constr.datalen; g++) {
37994                 int64_t val_conv_6 = val_vals[g];
37995                 val_constr.data[g] = val_conv_6;
37996         }
37997         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
37998         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
37999 }
38000
38001 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) {
38002         LDKThirtyTwoBytes chain_hash_arg_ref;
38003         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
38004         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
38005         LDKCVec_u64Z short_channel_ids_arg_constr;
38006         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
38007         if (short_channel_ids_arg_constr.datalen > 0)
38008                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
38009         else
38010                 short_channel_ids_arg_constr.data = NULL;
38011         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
38012         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
38013                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
38014                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
38015         }
38016         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
38017         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
38018         int64_t ret_ref = 0;
38019         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38020         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38021         return ret_ref;
38022 }
38023
38024 static inline uint64_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
38025         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
38026         int64_t ret_ref = 0;
38027         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38028         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38029         return ret_ref;
38030 }
38031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38032         LDKQueryShortChannelIds arg_conv;
38033         arg_conv.inner = untag_ptr(arg);
38034         arg_conv.is_owned = ptr_is_owned(arg);
38035         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38036         arg_conv.is_owned = false;
38037         int64_t ret_conv = QueryShortChannelIds_clone_ptr(&arg_conv);
38038         return ret_conv;
38039 }
38040
38041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38042         LDKQueryShortChannelIds orig_conv;
38043         orig_conv.inner = untag_ptr(orig);
38044         orig_conv.is_owned = ptr_is_owned(orig);
38045         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38046         orig_conv.is_owned = false;
38047         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
38048         int64_t ret_ref = 0;
38049         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38050         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38051         return ret_ref;
38052 }
38053
38054 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38055         LDKQueryShortChannelIds a_conv;
38056         a_conv.inner = untag_ptr(a);
38057         a_conv.is_owned = ptr_is_owned(a);
38058         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38059         a_conv.is_owned = false;
38060         LDKQueryShortChannelIds b_conv;
38061         b_conv.inner = untag_ptr(b);
38062         b_conv.is_owned = ptr_is_owned(b);
38063         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38064         b_conv.is_owned = false;
38065         jboolean ret_conv = QueryShortChannelIds_eq(&a_conv, &b_conv);
38066         return ret_conv;
38067 }
38068
38069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38070         LDKReplyShortChannelIdsEnd this_obj_conv;
38071         this_obj_conv.inner = untag_ptr(this_obj);
38072         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38074         ReplyShortChannelIdsEnd_free(this_obj_conv);
38075 }
38076
38077 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
38078         LDKReplyShortChannelIdsEnd 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38084         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
38085         return ret_arr;
38086 }
38087
38088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38089         LDKReplyShortChannelIdsEnd this_ptr_conv;
38090         this_ptr_conv.inner = untag_ptr(this_ptr);
38091         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38093         this_ptr_conv.is_owned = false;
38094         LDKThirtyTwoBytes val_ref;
38095         CHECK((*env)->GetArrayLength(env, val) == 32);
38096         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
38097         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
38098 }
38099
38100 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
38101         LDKReplyShortChannelIdsEnd this_ptr_conv;
38102         this_ptr_conv.inner = untag_ptr(this_ptr);
38103         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38105         this_ptr_conv.is_owned = false;
38106         jboolean ret_conv = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
38107         return ret_conv;
38108 }
38109
38110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
38111         LDKReplyShortChannelIdsEnd this_ptr_conv;
38112         this_ptr_conv.inner = untag_ptr(this_ptr);
38113         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38115         this_ptr_conv.is_owned = false;
38116         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
38117 }
38118
38119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
38120         LDKThirtyTwoBytes chain_hash_arg_ref;
38121         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
38122         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
38123         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
38124         int64_t ret_ref = 0;
38125         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38126         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38127         return ret_ref;
38128 }
38129
38130 static inline uint64_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
38131         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
38132         int64_t ret_ref = 0;
38133         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38134         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38135         return ret_ref;
38136 }
38137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38138         LDKReplyShortChannelIdsEnd arg_conv;
38139         arg_conv.inner = untag_ptr(arg);
38140         arg_conv.is_owned = ptr_is_owned(arg);
38141         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38142         arg_conv.is_owned = false;
38143         int64_t ret_conv = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
38144         return ret_conv;
38145 }
38146
38147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38148         LDKReplyShortChannelIdsEnd orig_conv;
38149         orig_conv.inner = untag_ptr(orig);
38150         orig_conv.is_owned = ptr_is_owned(orig);
38151         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38152         orig_conv.is_owned = false;
38153         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
38154         int64_t ret_ref = 0;
38155         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38156         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38157         return ret_ref;
38158 }
38159
38160 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38161         LDKReplyShortChannelIdsEnd a_conv;
38162         a_conv.inner = untag_ptr(a);
38163         a_conv.is_owned = ptr_is_owned(a);
38164         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38165         a_conv.is_owned = false;
38166         LDKReplyShortChannelIdsEnd b_conv;
38167         b_conv.inner = untag_ptr(b);
38168         b_conv.is_owned = ptr_is_owned(b);
38169         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38170         b_conv.is_owned = false;
38171         jboolean ret_conv = ReplyShortChannelIdsEnd_eq(&a_conv, &b_conv);
38172         return ret_conv;
38173 }
38174
38175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38176         LDKGossipTimestampFilter this_obj_conv;
38177         this_obj_conv.inner = untag_ptr(this_obj);
38178         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38180         GossipTimestampFilter_free(this_obj_conv);
38181 }
38182
38183 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
38184         LDKGossipTimestampFilter this_ptr_conv;
38185         this_ptr_conv.inner = untag_ptr(this_ptr);
38186         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38188         this_ptr_conv.is_owned = false;
38189         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38190         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
38191         return ret_arr;
38192 }
38193
38194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38195         LDKGossipTimestampFilter this_ptr_conv;
38196         this_ptr_conv.inner = untag_ptr(this_ptr);
38197         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38199         this_ptr_conv.is_owned = false;
38200         LDKThirtyTwoBytes val_ref;
38201         CHECK((*env)->GetArrayLength(env, val) == 32);
38202         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
38203         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
38204 }
38205
38206 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
38207         LDKGossipTimestampFilter this_ptr_conv;
38208         this_ptr_conv.inner = untag_ptr(this_ptr);
38209         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38211         this_ptr_conv.is_owned = false;
38212         int32_t ret_conv = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
38213         return ret_conv;
38214 }
38215
38216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
38217         LDKGossipTimestampFilter this_ptr_conv;
38218         this_ptr_conv.inner = untag_ptr(this_ptr);
38219         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38221         this_ptr_conv.is_owned = false;
38222         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
38223 }
38224
38225 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
38226         LDKGossipTimestampFilter this_ptr_conv;
38227         this_ptr_conv.inner = untag_ptr(this_ptr);
38228         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38230         this_ptr_conv.is_owned = false;
38231         int32_t ret_conv = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
38232         return ret_conv;
38233 }
38234
38235 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
38236         LDKGossipTimestampFilter this_ptr_conv;
38237         this_ptr_conv.inner = untag_ptr(this_ptr);
38238         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38240         this_ptr_conv.is_owned = false;
38241         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
38242 }
38243
38244 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) {
38245         LDKThirtyTwoBytes chain_hash_arg_ref;
38246         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
38247         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
38248         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
38249         int64_t ret_ref = 0;
38250         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38251         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38252         return ret_ref;
38253 }
38254
38255 static inline uint64_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
38256         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
38257         int64_t ret_ref = 0;
38258         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38259         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38260         return ret_ref;
38261 }
38262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38263         LDKGossipTimestampFilter arg_conv;
38264         arg_conv.inner = untag_ptr(arg);
38265         arg_conv.is_owned = ptr_is_owned(arg);
38266         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38267         arg_conv.is_owned = false;
38268         int64_t ret_conv = GossipTimestampFilter_clone_ptr(&arg_conv);
38269         return ret_conv;
38270 }
38271
38272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38273         LDKGossipTimestampFilter orig_conv;
38274         orig_conv.inner = untag_ptr(orig);
38275         orig_conv.is_owned = ptr_is_owned(orig);
38276         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38277         orig_conv.is_owned = false;
38278         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
38279         int64_t ret_ref = 0;
38280         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38281         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38282         return ret_ref;
38283 }
38284
38285 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38286         LDKGossipTimestampFilter a_conv;
38287         a_conv.inner = untag_ptr(a);
38288         a_conv.is_owned = ptr_is_owned(a);
38289         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38290         a_conv.is_owned = false;
38291         LDKGossipTimestampFilter b_conv;
38292         b_conv.inner = untag_ptr(b);
38293         b_conv.is_owned = ptr_is_owned(b);
38294         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38295         b_conv.is_owned = false;
38296         jboolean ret_conv = GossipTimestampFilter_eq(&a_conv, &b_conv);
38297         return ret_conv;
38298 }
38299
38300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38301         if (!ptr_is_owned(this_ptr)) return;
38302         void* this_ptr_ptr = untag_ptr(this_ptr);
38303         CHECK_ACCESS(this_ptr_ptr);
38304         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
38305         FREE(untag_ptr(this_ptr));
38306         ErrorAction_free(this_ptr_conv);
38307 }
38308
38309 static inline uint64_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
38310         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
38311         *ret_copy = ErrorAction_clone(arg);
38312         int64_t ret_ref = tag_ptr(ret_copy, true);
38313         return ret_ref;
38314 }
38315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38316         LDKErrorAction* arg_conv = (LDKErrorAction*)untag_ptr(arg);
38317         int64_t ret_conv = ErrorAction_clone_ptr(arg_conv);
38318         return ret_conv;
38319 }
38320
38321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38322         LDKErrorAction* orig_conv = (LDKErrorAction*)untag_ptr(orig);
38323         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
38324         *ret_copy = ErrorAction_clone(orig_conv);
38325         int64_t ret_ref = tag_ptr(ret_copy, true);
38326         return ret_ref;
38327 }
38328
38329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
38330         LDKErrorMessage msg_conv;
38331         msg_conv.inner = untag_ptr(msg);
38332         msg_conv.is_owned = ptr_is_owned(msg);
38333         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
38334         msg_conv = ErrorMessage_clone(&msg_conv);
38335         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
38336         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
38337         int64_t ret_ref = tag_ptr(ret_copy, true);
38338         return ret_ref;
38339 }
38340
38341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
38342         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
38343         *ret_copy = ErrorAction_ignore_error();
38344         int64_t ret_ref = tag_ptr(ret_copy, true);
38345         return ret_ref;
38346 }
38347
38348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
38349         LDKLevel a_conv = LDKLevel_from_java(env, a);
38350         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
38351         *ret_copy = ErrorAction_ignore_and_log(a_conv);
38352         int64_t ret_ref = tag_ptr(ret_copy, true);
38353         return ret_ref;
38354 }
38355
38356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1duplicate_1gossip(JNIEnv *env, jclass clz) {
38357         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
38358         *ret_copy = ErrorAction_ignore_duplicate_gossip();
38359         int64_t ret_ref = tag_ptr(ret_copy, true);
38360         return ret_ref;
38361 }
38362
38363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
38364         LDKErrorMessage msg_conv;
38365         msg_conv.inner = untag_ptr(msg);
38366         msg_conv.is_owned = ptr_is_owned(msg);
38367         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
38368         msg_conv = ErrorMessage_clone(&msg_conv);
38369         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
38370         *ret_copy = ErrorAction_send_error_message(msg_conv);
38371         int64_t ret_ref = tag_ptr(ret_copy, true);
38372         return ret_ref;
38373 }
38374
38375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1warning_1message(JNIEnv *env, jclass clz, int64_t msg, jclass log_level) {
38376         LDKWarningMessage msg_conv;
38377         msg_conv.inner = untag_ptr(msg);
38378         msg_conv.is_owned = ptr_is_owned(msg);
38379         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
38380         msg_conv = WarningMessage_clone(&msg_conv);
38381         LDKLevel log_level_conv = LDKLevel_from_java(env, log_level);
38382         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
38383         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
38384         int64_t ret_ref = tag_ptr(ret_copy, true);
38385         return ret_ref;
38386 }
38387
38388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38389         LDKLightningError this_obj_conv;
38390         this_obj_conv.inner = untag_ptr(this_obj);
38391         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38393         LightningError_free(this_obj_conv);
38394 }
38395
38396 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
38397         LDKLightningError this_ptr_conv;
38398         this_ptr_conv.inner = untag_ptr(this_ptr);
38399         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38401         this_ptr_conv.is_owned = false;
38402         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
38403         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
38404         Str_free(ret_str);
38405         return ret_conv;
38406 }
38407
38408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
38409         LDKLightningError this_ptr_conv;
38410         this_ptr_conv.inner = untag_ptr(this_ptr);
38411         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38413         this_ptr_conv.is_owned = false;
38414         LDKStr val_conv = java_to_owned_str(env, val);
38415         LightningError_set_err(&this_ptr_conv, val_conv);
38416 }
38417
38418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
38419         LDKLightningError this_ptr_conv;
38420         this_ptr_conv.inner = untag_ptr(this_ptr);
38421         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38423         this_ptr_conv.is_owned = false;
38424         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
38425         *ret_copy = LightningError_get_action(&this_ptr_conv);
38426         int64_t ret_ref = tag_ptr(ret_copy, true);
38427         return ret_ref;
38428 }
38429
38430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38431         LDKLightningError this_ptr_conv;
38432         this_ptr_conv.inner = untag_ptr(this_ptr);
38433         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38435         this_ptr_conv.is_owned = false;
38436         void* val_ptr = untag_ptr(val);
38437         CHECK_ACCESS(val_ptr);
38438         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
38439         val_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(val));
38440         LightningError_set_action(&this_ptr_conv, val_conv);
38441 }
38442
38443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
38444         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
38445         void* action_arg_ptr = untag_ptr(action_arg);
38446         CHECK_ACCESS(action_arg_ptr);
38447         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
38448         action_arg_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(action_arg));
38449         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
38450         int64_t ret_ref = 0;
38451         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38452         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38453         return ret_ref;
38454 }
38455
38456 static inline uint64_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
38457         LDKLightningError ret_var = LightningError_clone(arg);
38458         int64_t ret_ref = 0;
38459         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38460         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38461         return ret_ref;
38462 }
38463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38464         LDKLightningError arg_conv;
38465         arg_conv.inner = untag_ptr(arg);
38466         arg_conv.is_owned = ptr_is_owned(arg);
38467         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38468         arg_conv.is_owned = false;
38469         int64_t ret_conv = LightningError_clone_ptr(&arg_conv);
38470         return ret_conv;
38471 }
38472
38473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38474         LDKLightningError orig_conv;
38475         orig_conv.inner = untag_ptr(orig);
38476         orig_conv.is_owned = ptr_is_owned(orig);
38477         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38478         orig_conv.is_owned = false;
38479         LDKLightningError ret_var = LightningError_clone(&orig_conv);
38480         int64_t ret_ref = 0;
38481         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38482         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38483         return ret_ref;
38484 }
38485
38486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38487         LDKCommitmentUpdate this_obj_conv;
38488         this_obj_conv.inner = untag_ptr(this_obj);
38489         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38491         CommitmentUpdate_free(this_obj_conv);
38492 }
38493
38494 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
38495         LDKCommitmentUpdate this_ptr_conv;
38496         this_ptr_conv.inner = untag_ptr(this_ptr);
38497         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38499         this_ptr_conv.is_owned = false;
38500         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
38501         int64_tArray ret_arr = NULL;
38502         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
38503         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
38504         for (size_t p = 0; p < ret_var.datalen; p++) {
38505                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
38506                 int64_t ret_conv_15_ref = 0;
38507                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
38508                 ret_conv_15_ref = tag_ptr(ret_conv_15_var.inner, ret_conv_15_var.is_owned);
38509                 ret_arr_ptr[p] = ret_conv_15_ref;
38510         }
38511         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
38512         FREE(ret_var.data);
38513         return ret_arr;
38514 }
38515
38516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
38517         LDKCommitmentUpdate this_ptr_conv;
38518         this_ptr_conv.inner = untag_ptr(this_ptr);
38519         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38521         this_ptr_conv.is_owned = false;
38522         LDKCVec_UpdateAddHTLCZ val_constr;
38523         val_constr.datalen = (*env)->GetArrayLength(env, val);
38524         if (val_constr.datalen > 0)
38525                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
38526         else
38527                 val_constr.data = NULL;
38528         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
38529         for (size_t p = 0; p < val_constr.datalen; p++) {
38530                 int64_t val_conv_15 = val_vals[p];
38531                 LDKUpdateAddHTLC val_conv_15_conv;
38532                 val_conv_15_conv.inner = untag_ptr(val_conv_15);
38533                 val_conv_15_conv.is_owned = ptr_is_owned(val_conv_15);
38534                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
38535                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
38536                 val_constr.data[p] = val_conv_15_conv;
38537         }
38538         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
38539         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
38540 }
38541
38542 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
38543         LDKCommitmentUpdate this_ptr_conv;
38544         this_ptr_conv.inner = untag_ptr(this_ptr);
38545         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38547         this_ptr_conv.is_owned = false;
38548         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
38549         int64_tArray ret_arr = NULL;
38550         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
38551         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
38552         for (size_t t = 0; t < ret_var.datalen; t++) {
38553                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
38554                 int64_t ret_conv_19_ref = 0;
38555                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
38556                 ret_conv_19_ref = tag_ptr(ret_conv_19_var.inner, ret_conv_19_var.is_owned);
38557                 ret_arr_ptr[t] = ret_conv_19_ref;
38558         }
38559         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
38560         FREE(ret_var.data);
38561         return ret_arr;
38562 }
38563
38564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
38565         LDKCommitmentUpdate this_ptr_conv;
38566         this_ptr_conv.inner = untag_ptr(this_ptr);
38567         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38569         this_ptr_conv.is_owned = false;
38570         LDKCVec_UpdateFulfillHTLCZ val_constr;
38571         val_constr.datalen = (*env)->GetArrayLength(env, val);
38572         if (val_constr.datalen > 0)
38573                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
38574         else
38575                 val_constr.data = NULL;
38576         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
38577         for (size_t t = 0; t < val_constr.datalen; t++) {
38578                 int64_t val_conv_19 = val_vals[t];
38579                 LDKUpdateFulfillHTLC val_conv_19_conv;
38580                 val_conv_19_conv.inner = untag_ptr(val_conv_19);
38581                 val_conv_19_conv.is_owned = ptr_is_owned(val_conv_19);
38582                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
38583                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
38584                 val_constr.data[t] = val_conv_19_conv;
38585         }
38586         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
38587         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
38588 }
38589
38590 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
38591         LDKCommitmentUpdate this_ptr_conv;
38592         this_ptr_conv.inner = untag_ptr(this_ptr);
38593         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38595         this_ptr_conv.is_owned = false;
38596         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
38597         int64_tArray ret_arr = NULL;
38598         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
38599         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
38600         for (size_t q = 0; q < ret_var.datalen; q++) {
38601                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
38602                 int64_t ret_conv_16_ref = 0;
38603                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
38604                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
38605                 ret_arr_ptr[q] = ret_conv_16_ref;
38606         }
38607         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
38608         FREE(ret_var.data);
38609         return ret_arr;
38610 }
38611
38612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
38613         LDKCommitmentUpdate this_ptr_conv;
38614         this_ptr_conv.inner = untag_ptr(this_ptr);
38615         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38617         this_ptr_conv.is_owned = false;
38618         LDKCVec_UpdateFailHTLCZ val_constr;
38619         val_constr.datalen = (*env)->GetArrayLength(env, val);
38620         if (val_constr.datalen > 0)
38621                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
38622         else
38623                 val_constr.data = NULL;
38624         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
38625         for (size_t q = 0; q < val_constr.datalen; q++) {
38626                 int64_t val_conv_16 = val_vals[q];
38627                 LDKUpdateFailHTLC val_conv_16_conv;
38628                 val_conv_16_conv.inner = untag_ptr(val_conv_16);
38629                 val_conv_16_conv.is_owned = ptr_is_owned(val_conv_16);
38630                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
38631                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
38632                 val_constr.data[q] = val_conv_16_conv;
38633         }
38634         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
38635         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
38636 }
38637
38638 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
38639         LDKCommitmentUpdate this_ptr_conv;
38640         this_ptr_conv.inner = untag_ptr(this_ptr);
38641         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38643         this_ptr_conv.is_owned = false;
38644         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
38645         int64_tArray ret_arr = NULL;
38646         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
38647         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
38648         for (size_t z = 0; z < ret_var.datalen; z++) {
38649                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
38650                 int64_t ret_conv_25_ref = 0;
38651                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
38652                 ret_conv_25_ref = tag_ptr(ret_conv_25_var.inner, ret_conv_25_var.is_owned);
38653                 ret_arr_ptr[z] = ret_conv_25_ref;
38654         }
38655         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
38656         FREE(ret_var.data);
38657         return ret_arr;
38658 }
38659
38660 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) {
38661         LDKCommitmentUpdate this_ptr_conv;
38662         this_ptr_conv.inner = untag_ptr(this_ptr);
38663         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38665         this_ptr_conv.is_owned = false;
38666         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
38667         val_constr.datalen = (*env)->GetArrayLength(env, val);
38668         if (val_constr.datalen > 0)
38669                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
38670         else
38671                 val_constr.data = NULL;
38672         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
38673         for (size_t z = 0; z < val_constr.datalen; z++) {
38674                 int64_t val_conv_25 = val_vals[z];
38675                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
38676                 val_conv_25_conv.inner = untag_ptr(val_conv_25);
38677                 val_conv_25_conv.is_owned = ptr_is_owned(val_conv_25);
38678                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
38679                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
38680                 val_constr.data[z] = val_conv_25_conv;
38681         }
38682         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
38683         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
38684 }
38685
38686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
38687         LDKCommitmentUpdate this_ptr_conv;
38688         this_ptr_conv.inner = untag_ptr(this_ptr);
38689         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38691         this_ptr_conv.is_owned = false;
38692         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
38693         int64_t ret_ref = 0;
38694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38695         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38696         return ret_ref;
38697 }
38698
38699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38700         LDKCommitmentUpdate this_ptr_conv;
38701         this_ptr_conv.inner = untag_ptr(this_ptr);
38702         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38704         this_ptr_conv.is_owned = false;
38705         LDKUpdateFee val_conv;
38706         val_conv.inner = untag_ptr(val);
38707         val_conv.is_owned = ptr_is_owned(val);
38708         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38709         val_conv = UpdateFee_clone(&val_conv);
38710         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
38711 }
38712
38713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
38714         LDKCommitmentUpdate this_ptr_conv;
38715         this_ptr_conv.inner = untag_ptr(this_ptr);
38716         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38718         this_ptr_conv.is_owned = false;
38719         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
38720         int64_t ret_ref = 0;
38721         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38722         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38723         return ret_ref;
38724 }
38725
38726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38727         LDKCommitmentUpdate this_ptr_conv;
38728         this_ptr_conv.inner = untag_ptr(this_ptr);
38729         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38731         this_ptr_conv.is_owned = false;
38732         LDKCommitmentSigned val_conv;
38733         val_conv.inner = untag_ptr(val);
38734         val_conv.is_owned = ptr_is_owned(val);
38735         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38736         val_conv = CommitmentSigned_clone(&val_conv);
38737         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
38738 }
38739
38740 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) {
38741         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
38742         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
38743         if (update_add_htlcs_arg_constr.datalen > 0)
38744                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
38745         else
38746                 update_add_htlcs_arg_constr.data = NULL;
38747         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
38748         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
38749                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
38750                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
38751                 update_add_htlcs_arg_conv_15_conv.inner = untag_ptr(update_add_htlcs_arg_conv_15);
38752                 update_add_htlcs_arg_conv_15_conv.is_owned = ptr_is_owned(update_add_htlcs_arg_conv_15);
38753                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
38754                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
38755                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
38756         }
38757         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
38758         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
38759         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
38760         if (update_fulfill_htlcs_arg_constr.datalen > 0)
38761                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
38762         else
38763                 update_fulfill_htlcs_arg_constr.data = NULL;
38764         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
38765         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
38766                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
38767                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
38768                 update_fulfill_htlcs_arg_conv_19_conv.inner = untag_ptr(update_fulfill_htlcs_arg_conv_19);
38769                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = ptr_is_owned(update_fulfill_htlcs_arg_conv_19);
38770                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
38771                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
38772                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
38773         }
38774         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
38775         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
38776         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
38777         if (update_fail_htlcs_arg_constr.datalen > 0)
38778                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
38779         else
38780                 update_fail_htlcs_arg_constr.data = NULL;
38781         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
38782         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
38783                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
38784                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
38785                 update_fail_htlcs_arg_conv_16_conv.inner = untag_ptr(update_fail_htlcs_arg_conv_16);
38786                 update_fail_htlcs_arg_conv_16_conv.is_owned = ptr_is_owned(update_fail_htlcs_arg_conv_16);
38787                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
38788                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
38789                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
38790         }
38791         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
38792         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
38793         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
38794         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
38795                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
38796         else
38797                 update_fail_malformed_htlcs_arg_constr.data = NULL;
38798         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
38799         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
38800                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
38801                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
38802                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = untag_ptr(update_fail_malformed_htlcs_arg_conv_25);
38803                 update_fail_malformed_htlcs_arg_conv_25_conv.is_owned = ptr_is_owned(update_fail_malformed_htlcs_arg_conv_25);
38804                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
38805                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
38806                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
38807         }
38808         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
38809         LDKUpdateFee update_fee_arg_conv;
38810         update_fee_arg_conv.inner = untag_ptr(update_fee_arg);
38811         update_fee_arg_conv.is_owned = ptr_is_owned(update_fee_arg);
38812         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
38813         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
38814         LDKCommitmentSigned commitment_signed_arg_conv;
38815         commitment_signed_arg_conv.inner = untag_ptr(commitment_signed_arg);
38816         commitment_signed_arg_conv.is_owned = ptr_is_owned(commitment_signed_arg);
38817         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
38818         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
38819         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);
38820         int64_t ret_ref = 0;
38821         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38822         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38823         return ret_ref;
38824 }
38825
38826 static inline uint64_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
38827         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
38828         int64_t ret_ref = 0;
38829         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38830         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38831         return ret_ref;
38832 }
38833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38834         LDKCommitmentUpdate arg_conv;
38835         arg_conv.inner = untag_ptr(arg);
38836         arg_conv.is_owned = ptr_is_owned(arg);
38837         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38838         arg_conv.is_owned = false;
38839         int64_t ret_conv = CommitmentUpdate_clone_ptr(&arg_conv);
38840         return ret_conv;
38841 }
38842
38843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38844         LDKCommitmentUpdate orig_conv;
38845         orig_conv.inner = untag_ptr(orig);
38846         orig_conv.is_owned = ptr_is_owned(orig);
38847         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38848         orig_conv.is_owned = false;
38849         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
38850         int64_t ret_ref = 0;
38851         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38852         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38853         return ret_ref;
38854 }
38855
38856 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38857         LDKCommitmentUpdate a_conv;
38858         a_conv.inner = untag_ptr(a);
38859         a_conv.is_owned = ptr_is_owned(a);
38860         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38861         a_conv.is_owned = false;
38862         LDKCommitmentUpdate b_conv;
38863         b_conv.inner = untag_ptr(b);
38864         b_conv.is_owned = ptr_is_owned(b);
38865         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38866         b_conv.is_owned = false;
38867         jboolean ret_conv = CommitmentUpdate_eq(&a_conv, &b_conv);
38868         return ret_conv;
38869 }
38870
38871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38872         if (!ptr_is_owned(this_ptr)) return;
38873         void* this_ptr_ptr = untag_ptr(this_ptr);
38874         CHECK_ACCESS(this_ptr_ptr);
38875         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
38876         FREE(untag_ptr(this_ptr));
38877         ChannelMessageHandler_free(this_ptr_conv);
38878 }
38879
38880 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38881         if (!ptr_is_owned(this_ptr)) return;
38882         void* this_ptr_ptr = untag_ptr(this_ptr);
38883         CHECK_ACCESS(this_ptr_ptr);
38884         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
38885         FREE(untag_ptr(this_ptr));
38886         RoutingMessageHandler_free(this_ptr_conv);
38887 }
38888
38889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38890         if (!ptr_is_owned(this_ptr)) return;
38891         void* this_ptr_ptr = untag_ptr(this_ptr);
38892         CHECK_ACCESS(this_ptr_ptr);
38893         LDKOnionMessageHandler this_ptr_conv = *(LDKOnionMessageHandler*)(this_ptr_ptr);
38894         FREE(untag_ptr(this_ptr));
38895         OnionMessageHandler_free(this_ptr_conv);
38896 }
38897
38898 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
38899         LDKAcceptChannel obj_conv;
38900         obj_conv.inner = untag_ptr(obj);
38901         obj_conv.is_owned = ptr_is_owned(obj);
38902         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38903         obj_conv.is_owned = false;
38904         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
38905         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38906         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38907         CVec_u8Z_free(ret_var);
38908         return ret_arr;
38909 }
38910
38911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38912         LDKu8slice ser_ref;
38913         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38914         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38915         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
38916         *ret_conv = AcceptChannel_read(ser_ref);
38917         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38918         return tag_ptr(ret_conv, true);
38919 }
38920
38921 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
38922         LDKAnnouncementSignatures obj_conv;
38923         obj_conv.inner = untag_ptr(obj);
38924         obj_conv.is_owned = ptr_is_owned(obj);
38925         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38926         obj_conv.is_owned = false;
38927         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
38928         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38929         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38930         CVec_u8Z_free(ret_var);
38931         return ret_arr;
38932 }
38933
38934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38935         LDKu8slice ser_ref;
38936         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38937         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38938         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
38939         *ret_conv = AnnouncementSignatures_read(ser_ref);
38940         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38941         return tag_ptr(ret_conv, true);
38942 }
38943
38944 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
38945         LDKChannelReestablish obj_conv;
38946         obj_conv.inner = untag_ptr(obj);
38947         obj_conv.is_owned = ptr_is_owned(obj);
38948         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38949         obj_conv.is_owned = false;
38950         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
38951         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38952         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38953         CVec_u8Z_free(ret_var);
38954         return ret_arr;
38955 }
38956
38957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38958         LDKu8slice ser_ref;
38959         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38960         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38961         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
38962         *ret_conv = ChannelReestablish_read(ser_ref);
38963         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38964         return tag_ptr(ret_conv, true);
38965 }
38966
38967 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
38968         LDKClosingSigned obj_conv;
38969         obj_conv.inner = untag_ptr(obj);
38970         obj_conv.is_owned = ptr_is_owned(obj);
38971         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38972         obj_conv.is_owned = false;
38973         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
38974         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38975         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38976         CVec_u8Z_free(ret_var);
38977         return ret_arr;
38978 }
38979
38980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38981         LDKu8slice ser_ref;
38982         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38983         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38984         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
38985         *ret_conv = ClosingSigned_read(ser_ref);
38986         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38987         return tag_ptr(ret_conv, true);
38988 }
38989
38990 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
38991         LDKClosingSignedFeeRange obj_conv;
38992         obj_conv.inner = untag_ptr(obj);
38993         obj_conv.is_owned = ptr_is_owned(obj);
38994         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38995         obj_conv.is_owned = false;
38996         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
38997         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38998         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38999         CVec_u8Z_free(ret_var);
39000         return ret_arr;
39001 }
39002
39003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39004         LDKu8slice ser_ref;
39005         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39006         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39007         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
39008         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
39009         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39010         return tag_ptr(ret_conv, true);
39011 }
39012
39013 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
39014         LDKCommitmentSigned obj_conv;
39015         obj_conv.inner = untag_ptr(obj);
39016         obj_conv.is_owned = ptr_is_owned(obj);
39017         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39018         obj_conv.is_owned = false;
39019         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
39020         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39021         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39022         CVec_u8Z_free(ret_var);
39023         return ret_arr;
39024 }
39025
39026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39027         LDKu8slice ser_ref;
39028         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39029         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39030         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
39031         *ret_conv = CommitmentSigned_read(ser_ref);
39032         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39033         return tag_ptr(ret_conv, true);
39034 }
39035
39036 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
39037         LDKFundingCreated obj_conv;
39038         obj_conv.inner = untag_ptr(obj);
39039         obj_conv.is_owned = ptr_is_owned(obj);
39040         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39041         obj_conv.is_owned = false;
39042         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
39043         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39044         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39045         CVec_u8Z_free(ret_var);
39046         return ret_arr;
39047 }
39048
39049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39050         LDKu8slice ser_ref;
39051         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39052         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39053         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
39054         *ret_conv = FundingCreated_read(ser_ref);
39055         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39056         return tag_ptr(ret_conv, true);
39057 }
39058
39059 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
39060         LDKFundingSigned obj_conv;
39061         obj_conv.inner = untag_ptr(obj);
39062         obj_conv.is_owned = ptr_is_owned(obj);
39063         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39064         obj_conv.is_owned = false;
39065         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
39066         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39067         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39068         CVec_u8Z_free(ret_var);
39069         return ret_arr;
39070 }
39071
39072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39073         LDKu8slice ser_ref;
39074         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39075         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39076         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
39077         *ret_conv = FundingSigned_read(ser_ref);
39078         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39079         return tag_ptr(ret_conv, true);
39080 }
39081
39082 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1write(JNIEnv *env, jclass clz, int64_t obj) {
39083         LDKChannelReady obj_conv;
39084         obj_conv.inner = untag_ptr(obj);
39085         obj_conv.is_owned = ptr_is_owned(obj);
39086         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39087         obj_conv.is_owned = false;
39088         LDKCVec_u8Z ret_var = ChannelReady_write(&obj_conv);
39089         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39090         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39091         CVec_u8Z_free(ret_var);
39092         return ret_arr;
39093 }
39094
39095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39096         LDKu8slice ser_ref;
39097         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39098         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39099         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
39100         *ret_conv = ChannelReady_read(ser_ref);
39101         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39102         return tag_ptr(ret_conv, true);
39103 }
39104
39105 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
39106         LDKInit obj_conv;
39107         obj_conv.inner = untag_ptr(obj);
39108         obj_conv.is_owned = ptr_is_owned(obj);
39109         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39110         obj_conv.is_owned = false;
39111         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
39112         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39113         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39114         CVec_u8Z_free(ret_var);
39115         return ret_arr;
39116 }
39117
39118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39119         LDKu8slice ser_ref;
39120         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39121         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39122         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
39123         *ret_conv = Init_read(ser_ref);
39124         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39125         return tag_ptr(ret_conv, true);
39126 }
39127
39128 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
39129         LDKOpenChannel obj_conv;
39130         obj_conv.inner = untag_ptr(obj);
39131         obj_conv.is_owned = ptr_is_owned(obj);
39132         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39133         obj_conv.is_owned = false;
39134         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
39135         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39136         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39137         CVec_u8Z_free(ret_var);
39138         return ret_arr;
39139 }
39140
39141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39142         LDKu8slice ser_ref;
39143         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39144         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39145         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
39146         *ret_conv = OpenChannel_read(ser_ref);
39147         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39148         return tag_ptr(ret_conv, true);
39149 }
39150
39151 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
39152         LDKRevokeAndACK obj_conv;
39153         obj_conv.inner = untag_ptr(obj);
39154         obj_conv.is_owned = ptr_is_owned(obj);
39155         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39156         obj_conv.is_owned = false;
39157         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
39158         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39159         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39160         CVec_u8Z_free(ret_var);
39161         return ret_arr;
39162 }
39163
39164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39165         LDKu8slice ser_ref;
39166         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39167         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39168         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
39169         *ret_conv = RevokeAndACK_read(ser_ref);
39170         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39171         return tag_ptr(ret_conv, true);
39172 }
39173
39174 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
39175         LDKShutdown obj_conv;
39176         obj_conv.inner = untag_ptr(obj);
39177         obj_conv.is_owned = ptr_is_owned(obj);
39178         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39179         obj_conv.is_owned = false;
39180         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
39181         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39182         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39183         CVec_u8Z_free(ret_var);
39184         return ret_arr;
39185 }
39186
39187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39188         LDKu8slice ser_ref;
39189         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39190         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39191         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
39192         *ret_conv = Shutdown_read(ser_ref);
39193         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39194         return tag_ptr(ret_conv, true);
39195 }
39196
39197 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
39198         LDKUpdateFailHTLC obj_conv;
39199         obj_conv.inner = untag_ptr(obj);
39200         obj_conv.is_owned = ptr_is_owned(obj);
39201         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39202         obj_conv.is_owned = false;
39203         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
39204         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39205         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39206         CVec_u8Z_free(ret_var);
39207         return ret_arr;
39208 }
39209
39210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39211         LDKu8slice ser_ref;
39212         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39213         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39214         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
39215         *ret_conv = UpdateFailHTLC_read(ser_ref);
39216         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39217         return tag_ptr(ret_conv, true);
39218 }
39219
39220 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
39221         LDKUpdateFailMalformedHTLC obj_conv;
39222         obj_conv.inner = untag_ptr(obj);
39223         obj_conv.is_owned = ptr_is_owned(obj);
39224         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39225         obj_conv.is_owned = false;
39226         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
39227         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39228         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39229         CVec_u8Z_free(ret_var);
39230         return ret_arr;
39231 }
39232
39233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39234         LDKu8slice ser_ref;
39235         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39236         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39237         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
39238         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
39239         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39240         return tag_ptr(ret_conv, true);
39241 }
39242
39243 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
39244         LDKUpdateFee obj_conv;
39245         obj_conv.inner = untag_ptr(obj);
39246         obj_conv.is_owned = ptr_is_owned(obj);
39247         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39248         obj_conv.is_owned = false;
39249         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
39250         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39251         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39252         CVec_u8Z_free(ret_var);
39253         return ret_arr;
39254 }
39255
39256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39257         LDKu8slice ser_ref;
39258         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39259         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39260         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
39261         *ret_conv = UpdateFee_read(ser_ref);
39262         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39263         return tag_ptr(ret_conv, true);
39264 }
39265
39266 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
39267         LDKUpdateFulfillHTLC obj_conv;
39268         obj_conv.inner = untag_ptr(obj);
39269         obj_conv.is_owned = ptr_is_owned(obj);
39270         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39271         obj_conv.is_owned = false;
39272         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
39273         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39274         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39275         CVec_u8Z_free(ret_var);
39276         return ret_arr;
39277 }
39278
39279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39280         LDKu8slice ser_ref;
39281         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39282         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39283         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
39284         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
39285         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39286         return tag_ptr(ret_conv, true);
39287 }
39288
39289 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
39290         LDKUpdateAddHTLC obj_conv;
39291         obj_conv.inner = untag_ptr(obj);
39292         obj_conv.is_owned = ptr_is_owned(obj);
39293         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39294         obj_conv.is_owned = false;
39295         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
39296         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39297         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39298         CVec_u8Z_free(ret_var);
39299         return ret_arr;
39300 }
39301
39302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39303         LDKu8slice ser_ref;
39304         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39305         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39306         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
39307         *ret_conv = UpdateAddHTLC_read(ser_ref);
39308         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39309         return tag_ptr(ret_conv, true);
39310 }
39311
39312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39313         LDKu8slice ser_ref;
39314         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39315         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39316         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
39317         *ret_conv = OnionMessage_read(ser_ref);
39318         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39319         return tag_ptr(ret_conv, true);
39320 }
39321
39322 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OnionMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
39323         LDKOnionMessage obj_conv;
39324         obj_conv.inner = untag_ptr(obj);
39325         obj_conv.is_owned = ptr_is_owned(obj);
39326         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39327         obj_conv.is_owned = false;
39328         LDKCVec_u8Z ret_var = OnionMessage_write(&obj_conv);
39329         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39330         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39331         CVec_u8Z_free(ret_var);
39332         return ret_arr;
39333 }
39334
39335 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
39336         LDKPing obj_conv;
39337         obj_conv.inner = untag_ptr(obj);
39338         obj_conv.is_owned = ptr_is_owned(obj);
39339         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39340         obj_conv.is_owned = false;
39341         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
39342         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39343         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39344         CVec_u8Z_free(ret_var);
39345         return ret_arr;
39346 }
39347
39348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39349         LDKu8slice ser_ref;
39350         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39351         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39352         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
39353         *ret_conv = Ping_read(ser_ref);
39354         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39355         return tag_ptr(ret_conv, true);
39356 }
39357
39358 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
39359         LDKPong obj_conv;
39360         obj_conv.inner = untag_ptr(obj);
39361         obj_conv.is_owned = ptr_is_owned(obj);
39362         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39363         obj_conv.is_owned = false;
39364         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
39365         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39366         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39367         CVec_u8Z_free(ret_var);
39368         return ret_arr;
39369 }
39370
39371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39372         LDKu8slice ser_ref;
39373         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39374         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39375         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
39376         *ret_conv = Pong_read(ser_ref);
39377         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39378         return tag_ptr(ret_conv, true);
39379 }
39380
39381 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
39382         LDKUnsignedChannelAnnouncement obj_conv;
39383         obj_conv.inner = untag_ptr(obj);
39384         obj_conv.is_owned = ptr_is_owned(obj);
39385         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39386         obj_conv.is_owned = false;
39387         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
39388         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39389         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39390         CVec_u8Z_free(ret_var);
39391         return ret_arr;
39392 }
39393
39394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39395         LDKu8slice ser_ref;
39396         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39397         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39398         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
39399         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
39400         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39401         return tag_ptr(ret_conv, true);
39402 }
39403
39404 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
39405         LDKChannelAnnouncement obj_conv;
39406         obj_conv.inner = untag_ptr(obj);
39407         obj_conv.is_owned = ptr_is_owned(obj);
39408         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39409         obj_conv.is_owned = false;
39410         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
39411         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39412         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39413         CVec_u8Z_free(ret_var);
39414         return ret_arr;
39415 }
39416
39417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39418         LDKu8slice ser_ref;
39419         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39420         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39421         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
39422         *ret_conv = ChannelAnnouncement_read(ser_ref);
39423         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39424         return tag_ptr(ret_conv, true);
39425 }
39426
39427 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
39428         LDKUnsignedChannelUpdate obj_conv;
39429         obj_conv.inner = untag_ptr(obj);
39430         obj_conv.is_owned = ptr_is_owned(obj);
39431         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39432         obj_conv.is_owned = false;
39433         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
39434         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39435         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39436         CVec_u8Z_free(ret_var);
39437         return ret_arr;
39438 }
39439
39440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39441         LDKu8slice ser_ref;
39442         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39443         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39444         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
39445         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
39446         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39447         return tag_ptr(ret_conv, true);
39448 }
39449
39450 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
39451         LDKChannelUpdate obj_conv;
39452         obj_conv.inner = untag_ptr(obj);
39453         obj_conv.is_owned = ptr_is_owned(obj);
39454         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39455         obj_conv.is_owned = false;
39456         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
39457         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39458         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39459         CVec_u8Z_free(ret_var);
39460         return ret_arr;
39461 }
39462
39463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39464         LDKu8slice ser_ref;
39465         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39466         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39467         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
39468         *ret_conv = ChannelUpdate_read(ser_ref);
39469         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39470         return tag_ptr(ret_conv, true);
39471 }
39472
39473 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
39474         LDKErrorMessage obj_conv;
39475         obj_conv.inner = untag_ptr(obj);
39476         obj_conv.is_owned = ptr_is_owned(obj);
39477         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39478         obj_conv.is_owned = false;
39479         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
39480         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39481         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39482         CVec_u8Z_free(ret_var);
39483         return ret_arr;
39484 }
39485
39486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39487         LDKu8slice ser_ref;
39488         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39489         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39490         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
39491         *ret_conv = ErrorMessage_read(ser_ref);
39492         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39493         return tag_ptr(ret_conv, true);
39494 }
39495
39496 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
39497         LDKWarningMessage obj_conv;
39498         obj_conv.inner = untag_ptr(obj);
39499         obj_conv.is_owned = ptr_is_owned(obj);
39500         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39501         obj_conv.is_owned = false;
39502         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
39503         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39504         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39505         CVec_u8Z_free(ret_var);
39506         return ret_arr;
39507 }
39508
39509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39510         LDKu8slice ser_ref;
39511         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39512         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39513         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
39514         *ret_conv = WarningMessage_read(ser_ref);
39515         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39516         return tag_ptr(ret_conv, true);
39517 }
39518
39519 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
39520         LDKUnsignedNodeAnnouncement obj_conv;
39521         obj_conv.inner = untag_ptr(obj);
39522         obj_conv.is_owned = ptr_is_owned(obj);
39523         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39524         obj_conv.is_owned = false;
39525         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
39526         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39527         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39528         CVec_u8Z_free(ret_var);
39529         return ret_arr;
39530 }
39531
39532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39533         LDKu8slice ser_ref;
39534         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39535         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39536         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
39537         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
39538         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39539         return tag_ptr(ret_conv, true);
39540 }
39541
39542 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
39543         LDKNodeAnnouncement obj_conv;
39544         obj_conv.inner = untag_ptr(obj);
39545         obj_conv.is_owned = ptr_is_owned(obj);
39546         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39547         obj_conv.is_owned = false;
39548         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
39549         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39550         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39551         CVec_u8Z_free(ret_var);
39552         return ret_arr;
39553 }
39554
39555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39556         LDKu8slice ser_ref;
39557         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39558         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39559         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
39560         *ret_conv = NodeAnnouncement_read(ser_ref);
39561         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39562         return tag_ptr(ret_conv, true);
39563 }
39564
39565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39566         LDKu8slice ser_ref;
39567         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39568         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39569         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
39570         *ret_conv = QueryShortChannelIds_read(ser_ref);
39571         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39572         return tag_ptr(ret_conv, true);
39573 }
39574
39575 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
39576         LDKQueryShortChannelIds obj_conv;
39577         obj_conv.inner = untag_ptr(obj);
39578         obj_conv.is_owned = ptr_is_owned(obj);
39579         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39580         obj_conv.is_owned = false;
39581         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
39582         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39583         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39584         CVec_u8Z_free(ret_var);
39585         return ret_arr;
39586 }
39587
39588 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
39589         LDKReplyShortChannelIdsEnd 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 = ReplyShortChannelIdsEnd_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_ReplyShortChannelIdsEnd_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_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
39606         *ret_conv = ReplyShortChannelIdsEnd_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 int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
39612         LDKQueryChannelRange this_arg_conv;
39613         this_arg_conv.inner = untag_ptr(this_arg);
39614         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39616         this_arg_conv.is_owned = false;
39617         int32_t ret_conv = QueryChannelRange_end_blocknum(&this_arg_conv);
39618         return ret_conv;
39619 }
39620
39621 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
39622         LDKQueryChannelRange obj_conv;
39623         obj_conv.inner = untag_ptr(obj);
39624         obj_conv.is_owned = ptr_is_owned(obj);
39625         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39626         obj_conv.is_owned = false;
39627         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
39628         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39629         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39630         CVec_u8Z_free(ret_var);
39631         return ret_arr;
39632 }
39633
39634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39635         LDKu8slice ser_ref;
39636         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39637         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39638         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
39639         *ret_conv = QueryChannelRange_read(ser_ref);
39640         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39641         return tag_ptr(ret_conv, true);
39642 }
39643
39644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39645         LDKu8slice ser_ref;
39646         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39647         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39648         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
39649         *ret_conv = ReplyChannelRange_read(ser_ref);
39650         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39651         return tag_ptr(ret_conv, true);
39652 }
39653
39654 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
39655         LDKReplyChannelRange obj_conv;
39656         obj_conv.inner = untag_ptr(obj);
39657         obj_conv.is_owned = ptr_is_owned(obj);
39658         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39659         obj_conv.is_owned = false;
39660         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
39661         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39662         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39663         CVec_u8Z_free(ret_var);
39664         return ret_arr;
39665 }
39666
39667 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
39668         LDKGossipTimestampFilter obj_conv;
39669         obj_conv.inner = untag_ptr(obj);
39670         obj_conv.is_owned = ptr_is_owned(obj);
39671         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39672         obj_conv.is_owned = false;
39673         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
39674         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39675         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39676         CVec_u8Z_free(ret_var);
39677         return ret_arr;
39678 }
39679
39680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39681         LDKu8slice ser_ref;
39682         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39683         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39684         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
39685         *ret_conv = GossipTimestampFilter_read(ser_ref);
39686         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39687         return tag_ptr(ret_conv, true);
39688 }
39689
39690 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39691         if (!ptr_is_owned(this_ptr)) return;
39692         void* this_ptr_ptr = untag_ptr(this_ptr);
39693         CHECK_ACCESS(this_ptr_ptr);
39694         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
39695         FREE(untag_ptr(this_ptr));
39696         CustomMessageHandler_free(this_ptr_conv);
39697 }
39698
39699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39700         LDKIgnoringMessageHandler this_obj_conv;
39701         this_obj_conv.inner = untag_ptr(this_obj);
39702         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39704         IgnoringMessageHandler_free(this_obj_conv);
39705 }
39706
39707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
39708         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
39709         int64_t ret_ref = 0;
39710         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39711         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39712         return ret_ref;
39713 }
39714
39715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
39716         LDKIgnoringMessageHandler this_arg_conv;
39717         this_arg_conv.inner = untag_ptr(this_arg);
39718         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39720         this_arg_conv.is_owned = false;
39721         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
39722         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
39723         return tag_ptr(ret_ret, true);
39724 }
39725
39726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
39727         LDKIgnoringMessageHandler this_arg_conv;
39728         this_arg_conv.inner = untag_ptr(this_arg);
39729         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39731         this_arg_conv.is_owned = false;
39732         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
39733         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
39734         return tag_ptr(ret_ret, true);
39735 }
39736
39737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1OnionMessageProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
39738         LDKIgnoringMessageHandler this_arg_conv;
39739         this_arg_conv.inner = untag_ptr(this_arg);
39740         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39742         this_arg_conv.is_owned = false;
39743         LDKOnionMessageProvider* ret_ret = MALLOC(sizeof(LDKOnionMessageProvider), "LDKOnionMessageProvider");
39744         *ret_ret = IgnoringMessageHandler_as_OnionMessageProvider(&this_arg_conv);
39745         return tag_ptr(ret_ret, true);
39746 }
39747
39748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1OnionMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
39749         LDKIgnoringMessageHandler this_arg_conv;
39750         this_arg_conv.inner = untag_ptr(this_arg);
39751         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39753         this_arg_conv.is_owned = false;
39754         LDKOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
39755         *ret_ret = IgnoringMessageHandler_as_OnionMessageHandler(&this_arg_conv);
39756         return tag_ptr(ret_ret, true);
39757 }
39758
39759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomOnionMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
39760         LDKIgnoringMessageHandler 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         LDKCustomOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomOnionMessageHandler), "LDKCustomOnionMessageHandler");
39766         *ret_ret = IgnoringMessageHandler_as_CustomOnionMessageHandler(&this_arg_conv);
39767         return tag_ptr(ret_ret, true);
39768 }
39769
39770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) {
39771         LDKIgnoringMessageHandler this_arg_conv;
39772         this_arg_conv.inner = untag_ptr(this_arg);
39773         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39775         this_arg_conv.is_owned = false;
39776         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
39777         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
39778         return tag_ptr(ret_ret, true);
39779 }
39780
39781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
39782         LDKIgnoringMessageHandler this_arg_conv;
39783         this_arg_conv.inner = untag_ptr(this_arg);
39784         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39786         this_arg_conv.is_owned = false;
39787         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
39788         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
39789         return tag_ptr(ret_ret, true);
39790 }
39791
39792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39793         LDKErroringMessageHandler this_obj_conv;
39794         this_obj_conv.inner = untag_ptr(this_obj);
39795         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39797         ErroringMessageHandler_free(this_obj_conv);
39798 }
39799
39800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
39801         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
39802         int64_t ret_ref = 0;
39803         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39804         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39805         return ret_ref;
39806 }
39807
39808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
39809         LDKErroringMessageHandler this_arg_conv;
39810         this_arg_conv.inner = untag_ptr(this_arg);
39811         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39813         this_arg_conv.is_owned = false;
39814         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
39815         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
39816         return tag_ptr(ret_ret, true);
39817 }
39818
39819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
39820         LDKErroringMessageHandler this_arg_conv;
39821         this_arg_conv.inner = untag_ptr(this_arg);
39822         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39824         this_arg_conv.is_owned = false;
39825         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
39826         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
39827         return tag_ptr(ret_ret, true);
39828 }
39829
39830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39831         LDKMessageHandler this_obj_conv;
39832         this_obj_conv.inner = untag_ptr(this_obj);
39833         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39835         MessageHandler_free(this_obj_conv);
39836 }
39837
39838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
39839         LDKMessageHandler this_ptr_conv;
39840         this_ptr_conv.inner = untag_ptr(this_ptr);
39841         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39843         this_ptr_conv.is_owned = false;
39844         // WARNING: This object doesn't live past this scope, needs clone!
39845         int64_t ret_ret = tag_ptr(MessageHandler_get_chan_handler(&this_ptr_conv), false);
39846         return ret_ret;
39847 }
39848
39849 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39850         LDKMessageHandler this_ptr_conv;
39851         this_ptr_conv.inner = untag_ptr(this_ptr);
39852         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39854         this_ptr_conv.is_owned = false;
39855         void* val_ptr = untag_ptr(val);
39856         CHECK_ACCESS(val_ptr);
39857         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
39858         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
39859                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39860                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
39861         }
39862         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
39863 }
39864
39865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
39866         LDKMessageHandler this_ptr_conv;
39867         this_ptr_conv.inner = untag_ptr(this_ptr);
39868         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39870         this_ptr_conv.is_owned = false;
39871         // WARNING: This object doesn't live past this scope, needs clone!
39872         int64_t ret_ret = tag_ptr(MessageHandler_get_route_handler(&this_ptr_conv), false);
39873         return ret_ret;
39874 }
39875
39876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39877         LDKMessageHandler this_ptr_conv;
39878         this_ptr_conv.inner = untag_ptr(this_ptr);
39879         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39881         this_ptr_conv.is_owned = false;
39882         void* val_ptr = untag_ptr(val);
39883         CHECK_ACCESS(val_ptr);
39884         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
39885         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
39886                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39887                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
39888         }
39889         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
39890 }
39891
39892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1onion_1message_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
39893         LDKMessageHandler this_ptr_conv;
39894         this_ptr_conv.inner = untag_ptr(this_ptr);
39895         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39897         this_ptr_conv.is_owned = false;
39898         // WARNING: This object doesn't live past this scope, needs clone!
39899         int64_t ret_ret = tag_ptr(MessageHandler_get_onion_message_handler(&this_ptr_conv), false);
39900         return ret_ret;
39901 }
39902
39903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1onion_1message_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39904         LDKMessageHandler this_ptr_conv;
39905         this_ptr_conv.inner = untag_ptr(this_ptr);
39906         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39908         this_ptr_conv.is_owned = false;
39909         void* val_ptr = untag_ptr(val);
39910         CHECK_ACCESS(val_ptr);
39911         LDKOnionMessageHandler val_conv = *(LDKOnionMessageHandler*)(val_ptr);
39912         if (val_conv.free == LDKOnionMessageHandler_JCalls_free) {
39913                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39914                 LDKOnionMessageHandler_JCalls_cloned(&val_conv);
39915         }
39916         MessageHandler_set_onion_message_handler(&this_ptr_conv, val_conv);
39917 }
39918
39919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1new(JNIEnv *env, jclass clz, int64_t chan_handler_arg, int64_t route_handler_arg, int64_t onion_message_handler_arg) {
39920         void* chan_handler_arg_ptr = untag_ptr(chan_handler_arg);
39921         CHECK_ACCESS(chan_handler_arg_ptr);
39922         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
39923         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
39924                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39925                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
39926         }
39927         void* route_handler_arg_ptr = untag_ptr(route_handler_arg);
39928         CHECK_ACCESS(route_handler_arg_ptr);
39929         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
39930         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
39931                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39932                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
39933         }
39934         void* onion_message_handler_arg_ptr = untag_ptr(onion_message_handler_arg);
39935         CHECK_ACCESS(onion_message_handler_arg_ptr);
39936         LDKOnionMessageHandler onion_message_handler_arg_conv = *(LDKOnionMessageHandler*)(onion_message_handler_arg_ptr);
39937         if (onion_message_handler_arg_conv.free == LDKOnionMessageHandler_JCalls_free) {
39938                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39939                 LDKOnionMessageHandler_JCalls_cloned(&onion_message_handler_arg_conv);
39940         }
39941         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv, onion_message_handler_arg_conv);
39942         int64_t ret_ref = 0;
39943         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39944         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39945         return ret_ref;
39946 }
39947
39948 static inline uint64_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
39949         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
39950         *ret_ret = SocketDescriptor_clone(arg);
39951         return tag_ptr(ret_ret, true);
39952 }
39953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39954         void* arg_ptr = untag_ptr(arg);
39955         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
39956         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
39957         int64_t ret_conv = SocketDescriptor_clone_ptr(arg_conv);
39958         return ret_conv;
39959 }
39960
39961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39962         void* orig_ptr = untag_ptr(orig);
39963         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
39964         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
39965         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
39966         *ret_ret = SocketDescriptor_clone(orig_conv);
39967         return tag_ptr(ret_ret, true);
39968 }
39969
39970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39971         if (!ptr_is_owned(this_ptr)) return;
39972         void* this_ptr_ptr = untag_ptr(this_ptr);
39973         CHECK_ACCESS(this_ptr_ptr);
39974         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
39975         FREE(untag_ptr(this_ptr));
39976         SocketDescriptor_free(this_ptr_conv);
39977 }
39978
39979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39980         LDKPeerHandleError this_obj_conv;
39981         this_obj_conv.inner = untag_ptr(this_obj);
39982         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39984         PeerHandleError_free(this_obj_conv);
39985 }
39986
39987 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
39988         LDKPeerHandleError this_ptr_conv;
39989         this_ptr_conv.inner = untag_ptr(this_ptr);
39990         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39992         this_ptr_conv.is_owned = false;
39993         jboolean ret_conv = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
39994         return ret_conv;
39995 }
39996
39997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
39998         LDKPeerHandleError this_ptr_conv;
39999         this_ptr_conv.inner = untag_ptr(this_ptr);
40000         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40002         this_ptr_conv.is_owned = false;
40003         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
40004 }
40005
40006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
40007         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
40008         int64_t ret_ref = 0;
40009         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40010         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40011         return ret_ref;
40012 }
40013
40014 static inline uint64_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
40015         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
40016         int64_t ret_ref = 0;
40017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40018         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40019         return ret_ref;
40020 }
40021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40022         LDKPeerHandleError arg_conv;
40023         arg_conv.inner = untag_ptr(arg);
40024         arg_conv.is_owned = ptr_is_owned(arg);
40025         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40026         arg_conv.is_owned = false;
40027         int64_t ret_conv = PeerHandleError_clone_ptr(&arg_conv);
40028         return ret_conv;
40029 }
40030
40031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40032         LDKPeerHandleError orig_conv;
40033         orig_conv.inner = untag_ptr(orig);
40034         orig_conv.is_owned = ptr_is_owned(orig);
40035         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40036         orig_conv.is_owned = false;
40037         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
40038         int64_t ret_ref = 0;
40039         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40040         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40041         return ret_ref;
40042 }
40043
40044 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40045         LDKPeerManager this_obj_conv;
40046         this_obj_conv.inner = untag_ptr(this_obj);
40047         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40049         PeerManager_free(this_obj_conv);
40050 }
40051
40052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new(JNIEnv *env, jclass clz, int64_t message_handler, int8_tArray our_node_secret, int32_t current_time, int8_tArray ephemeral_random_data, int64_t logger, int64_t custom_message_handler) {
40053         LDKMessageHandler message_handler_conv;
40054         message_handler_conv.inner = untag_ptr(message_handler);
40055         message_handler_conv.is_owned = ptr_is_owned(message_handler);
40056         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
40057         // WARNING: we need a move here but no clone is available for LDKMessageHandler
40058         
40059         LDKSecretKey our_node_secret_ref;
40060         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
40061         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
40062         unsigned char ephemeral_random_data_arr[32];
40063         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
40064         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
40065         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
40066         void* logger_ptr = untag_ptr(logger);
40067         CHECK_ACCESS(logger_ptr);
40068         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
40069         if (logger_conv.free == LDKLogger_JCalls_free) {
40070                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40071                 LDKLogger_JCalls_cloned(&logger_conv);
40072         }
40073         void* custom_message_handler_ptr = untag_ptr(custom_message_handler);
40074         CHECK_ACCESS(custom_message_handler_ptr);
40075         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
40076         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
40077                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40078                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
40079         }
40080         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, current_time, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
40081         int64_t ret_ref = 0;
40082         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40083         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40084         return ret_ref;
40085 }
40086
40087 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
40088         LDKPeerManager this_arg_conv;
40089         this_arg_conv.inner = untag_ptr(this_arg);
40090         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40092         this_arg_conv.is_owned = false;
40093         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
40094         jobjectArray ret_arr = NULL;
40095         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
40096         ;
40097         for (size_t i = 0; i < ret_var.datalen; i++) {
40098                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
40099                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
40100                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
40101         }
40102         
40103         FREE(ret_var.data);
40104         return ret_arr;
40105 }
40106
40107 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) {
40108         LDKPeerManager this_arg_conv;
40109         this_arg_conv.inner = untag_ptr(this_arg);
40110         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40112         this_arg_conv.is_owned = false;
40113         LDKPublicKey their_node_id_ref;
40114         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
40115         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
40116         void* descriptor_ptr = untag_ptr(descriptor);
40117         CHECK_ACCESS(descriptor_ptr);
40118         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
40119         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
40120                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40121                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
40122         }
40123         void* remote_network_address_ptr = untag_ptr(remote_network_address);
40124         CHECK_ACCESS(remote_network_address_ptr);
40125         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
40126         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
40127         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
40128         return tag_ptr(ret_conv, true);
40129 }
40130
40131 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) {
40132         LDKPeerManager this_arg_conv;
40133         this_arg_conv.inner = untag_ptr(this_arg);
40134         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40136         this_arg_conv.is_owned = false;
40137         void* descriptor_ptr = untag_ptr(descriptor);
40138         CHECK_ACCESS(descriptor_ptr);
40139         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
40140         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
40141                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40142                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
40143         }
40144         void* remote_network_address_ptr = untag_ptr(remote_network_address);
40145         CHECK_ACCESS(remote_network_address_ptr);
40146         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
40147         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
40148         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
40149         return tag_ptr(ret_conv, true);
40150 }
40151
40152 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) {
40153         LDKPeerManager this_arg_conv;
40154         this_arg_conv.inner = untag_ptr(this_arg);
40155         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40157         this_arg_conv.is_owned = false;
40158         void* descriptor_ptr = untag_ptr(descriptor);
40159         if (ptr_is_owned(descriptor)) { CHECK_ACCESS(descriptor_ptr); }
40160         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
40161         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
40162         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
40163         return tag_ptr(ret_conv, true);
40164 }
40165
40166 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) {
40167         LDKPeerManager this_arg_conv;
40168         this_arg_conv.inner = untag_ptr(this_arg);
40169         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40171         this_arg_conv.is_owned = false;
40172         void* peer_descriptor_ptr = untag_ptr(peer_descriptor);
40173         if (ptr_is_owned(peer_descriptor)) { CHECK_ACCESS(peer_descriptor_ptr); }
40174         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
40175         LDKu8slice data_ref;
40176         data_ref.datalen = (*env)->GetArrayLength(env, data);
40177         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
40178         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
40179         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
40180         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
40181         return tag_ptr(ret_conv, true);
40182 }
40183
40184 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
40185         LDKPeerManager this_arg_conv;
40186         this_arg_conv.inner = untag_ptr(this_arg);
40187         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40189         this_arg_conv.is_owned = false;
40190         PeerManager_process_events(&this_arg_conv);
40191 }
40192
40193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
40194         LDKPeerManager this_arg_conv;
40195         this_arg_conv.inner = untag_ptr(this_arg);
40196         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40198         this_arg_conv.is_owned = false;
40199         void* descriptor_ptr = untag_ptr(descriptor);
40200         if (ptr_is_owned(descriptor)) { CHECK_ACCESS(descriptor_ptr); }
40201         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
40202         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
40203 }
40204
40205 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) {
40206         LDKPeerManager 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         LDKPublicKey node_id_ref;
40212         CHECK((*env)->GetArrayLength(env, node_id) == 33);
40213         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
40214         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
40215 }
40216
40217 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1all_1peers(JNIEnv *env, jclass clz, int64_t this_arg) {
40218         LDKPeerManager this_arg_conv;
40219         this_arg_conv.inner = untag_ptr(this_arg);
40220         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40222         this_arg_conv.is_owned = false;
40223         PeerManager_disconnect_all_peers(&this_arg_conv);
40224 }
40225
40226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
40227         LDKPeerManager this_arg_conv;
40228         this_arg_conv.inner = untag_ptr(this_arg);
40229         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40231         this_arg_conv.is_owned = false;
40232         PeerManager_timer_tick_occurred(&this_arg_conv);
40233 }
40234
40235 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray rgb, int8_tArray alias, int64_tArray addresses) {
40236         LDKPeerManager this_arg_conv;
40237         this_arg_conv.inner = untag_ptr(this_arg);
40238         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40240         this_arg_conv.is_owned = false;
40241         LDKThreeBytes rgb_ref;
40242         CHECK((*env)->GetArrayLength(env, rgb) == 3);
40243         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
40244         LDKThirtyTwoBytes alias_ref;
40245         CHECK((*env)->GetArrayLength(env, alias) == 32);
40246         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
40247         LDKCVec_NetAddressZ addresses_constr;
40248         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
40249         if (addresses_constr.datalen > 0)
40250                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
40251         else
40252                 addresses_constr.data = NULL;
40253         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
40254         for (size_t m = 0; m < addresses_constr.datalen; m++) {
40255                 int64_t addresses_conv_12 = addresses_vals[m];
40256                 void* addresses_conv_12_ptr = untag_ptr(addresses_conv_12);
40257                 CHECK_ACCESS(addresses_conv_12_ptr);
40258                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
40259                 addresses_constr.data[m] = addresses_conv_12_conv;
40260         }
40261         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
40262         PeerManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
40263 }
40264
40265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1success_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
40266         int64_t ret_conv = htlc_success_tx_weight(opt_anchors);
40267         return ret_conv;
40268 }
40269
40270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1timeout_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
40271         int64_t ret_conv = htlc_timeout_tx_weight(opt_anchors);
40272         return ret_conv;
40273 }
40274
40275 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
40276         unsigned char commitment_seed_arr[32];
40277         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
40278         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
40279         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
40280         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40281         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
40282         return ret_arr;
40283 }
40284
40285 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) {
40286         LDKCVec_u8Z to_holder_script_ref;
40287         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
40288         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
40289         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
40290         LDKCVec_u8Z to_counterparty_script_ref;
40291         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
40292         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
40293         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
40294         LDKOutPoint funding_outpoint_conv;
40295         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
40296         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
40297         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
40298         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
40299         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);
40300         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40301         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40302         Transaction_free(ret_var);
40303         return ret_arr;
40304 }
40305
40306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40307         LDKCounterpartyCommitmentSecrets this_obj_conv;
40308         this_obj_conv.inner = untag_ptr(this_obj);
40309         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40311         CounterpartyCommitmentSecrets_free(this_obj_conv);
40312 }
40313
40314 static inline uint64_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
40315         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
40316         int64_t ret_ref = 0;
40317         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40318         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40319         return ret_ref;
40320 }
40321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40322         LDKCounterpartyCommitmentSecrets arg_conv;
40323         arg_conv.inner = untag_ptr(arg);
40324         arg_conv.is_owned = ptr_is_owned(arg);
40325         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40326         arg_conv.is_owned = false;
40327         int64_t ret_conv = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
40328         return ret_conv;
40329 }
40330
40331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40332         LDKCounterpartyCommitmentSecrets orig_conv;
40333         orig_conv.inner = untag_ptr(orig);
40334         orig_conv.is_owned = ptr_is_owned(orig);
40335         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40336         orig_conv.is_owned = false;
40337         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
40338         int64_t ret_ref = 0;
40339         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40340         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40341         return ret_ref;
40342 }
40343
40344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1new(JNIEnv *env, jclass clz) {
40345         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
40346         int64_t ret_ref = 0;
40347         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40348         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40349         return ret_ref;
40350 }
40351
40352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1min_1seen_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
40353         LDKCounterpartyCommitmentSecrets this_arg_conv;
40354         this_arg_conv.inner = untag_ptr(this_arg);
40355         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40357         this_arg_conv.is_owned = false;
40358         int64_t ret_conv = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
40359         return ret_conv;
40360 }
40361
40362 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) {
40363         LDKCounterpartyCommitmentSecrets this_arg_conv;
40364         this_arg_conv.inner = untag_ptr(this_arg);
40365         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40367         this_arg_conv.is_owned = false;
40368         LDKThirtyTwoBytes secret_ref;
40369         CHECK((*env)->GetArrayLength(env, secret) == 32);
40370         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_ref.data);
40371         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
40372         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
40373         return tag_ptr(ret_conv, true);
40374 }
40375
40376 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
40377         LDKCounterpartyCommitmentSecrets this_arg_conv;
40378         this_arg_conv.inner = untag_ptr(this_arg);
40379         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40381         this_arg_conv.is_owned = false;
40382         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40383         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data);
40384         return ret_arr;
40385 }
40386
40387 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1write(JNIEnv *env, jclass clz, int64_t obj) {
40388         LDKCounterpartyCommitmentSecrets obj_conv;
40389         obj_conv.inner = untag_ptr(obj);
40390         obj_conv.is_owned = ptr_is_owned(obj);
40391         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40392         obj_conv.is_owned = false;
40393         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
40394         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40395         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40396         CVec_u8Z_free(ret_var);
40397         return ret_arr;
40398 }
40399
40400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40401         LDKu8slice ser_ref;
40402         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40403         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40404         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
40405         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
40406         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40407         return tag_ptr(ret_conv, true);
40408 }
40409
40410 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) {
40411         LDKPublicKey per_commitment_point_ref;
40412         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
40413         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
40414         unsigned char base_secret_arr[32];
40415         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
40416         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
40417         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
40418         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
40419         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
40420         return tag_ptr(ret_conv, true);
40421 }
40422
40423 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) {
40424         LDKPublicKey per_commitment_point_ref;
40425         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
40426         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
40427         LDKPublicKey base_point_ref;
40428         CHECK((*env)->GetArrayLength(env, base_point) == 33);
40429         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
40430         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
40431         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
40432         return tag_ptr(ret_conv, true);
40433 }
40434
40435 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) {
40436         unsigned char per_commitment_secret_arr[32];
40437         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
40438         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
40439         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
40440         unsigned char countersignatory_revocation_base_secret_arr[32];
40441         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
40442         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
40443         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
40444         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
40445         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
40446         return tag_ptr(ret_conv, true);
40447 }
40448
40449 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) {
40450         LDKPublicKey per_commitment_point_ref;
40451         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
40452         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
40453         LDKPublicKey countersignatory_revocation_base_point_ref;
40454         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
40455         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
40456         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
40457         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
40458         return tag_ptr(ret_conv, true);
40459 }
40460
40461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40462         LDKTxCreationKeys this_obj_conv;
40463         this_obj_conv.inner = untag_ptr(this_obj);
40464         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40466         TxCreationKeys_free(this_obj_conv);
40467 }
40468
40469 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
40470         LDKTxCreationKeys this_ptr_conv;
40471         this_ptr_conv.inner = untag_ptr(this_ptr);
40472         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40474         this_ptr_conv.is_owned = false;
40475         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
40476         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
40477         return ret_arr;
40478 }
40479
40480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40481         LDKTxCreationKeys this_ptr_conv;
40482         this_ptr_conv.inner = untag_ptr(this_ptr);
40483         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40485         this_ptr_conv.is_owned = false;
40486         LDKPublicKey val_ref;
40487         CHECK((*env)->GetArrayLength(env, val) == 33);
40488         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
40489         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
40490 }
40491
40492 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
40493         LDKTxCreationKeys this_ptr_conv;
40494         this_ptr_conv.inner = untag_ptr(this_ptr);
40495         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40497         this_ptr_conv.is_owned = false;
40498         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
40499         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
40500         return ret_arr;
40501 }
40502
40503 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40504         LDKTxCreationKeys this_ptr_conv;
40505         this_ptr_conv.inner = untag_ptr(this_ptr);
40506         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40508         this_ptr_conv.is_owned = false;
40509         LDKPublicKey val_ref;
40510         CHECK((*env)->GetArrayLength(env, val) == 33);
40511         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
40512         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
40513 }
40514
40515 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
40516         LDKTxCreationKeys this_ptr_conv;
40517         this_ptr_conv.inner = untag_ptr(this_ptr);
40518         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40520         this_ptr_conv.is_owned = false;
40521         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
40522         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
40523         return ret_arr;
40524 }
40525
40526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40527         LDKTxCreationKeys this_ptr_conv;
40528         this_ptr_conv.inner = untag_ptr(this_ptr);
40529         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40531         this_ptr_conv.is_owned = false;
40532         LDKPublicKey val_ref;
40533         CHECK((*env)->GetArrayLength(env, val) == 33);
40534         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
40535         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
40536 }
40537
40538 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
40539         LDKTxCreationKeys this_ptr_conv;
40540         this_ptr_conv.inner = untag_ptr(this_ptr);
40541         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40543         this_ptr_conv.is_owned = false;
40544         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
40545         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
40546         return ret_arr;
40547 }
40548
40549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40550         LDKTxCreationKeys this_ptr_conv;
40551         this_ptr_conv.inner = untag_ptr(this_ptr);
40552         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40554         this_ptr_conv.is_owned = false;
40555         LDKPublicKey val_ref;
40556         CHECK((*env)->GetArrayLength(env, val) == 33);
40557         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
40558         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
40559 }
40560
40561 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
40562         LDKTxCreationKeys this_ptr_conv;
40563         this_ptr_conv.inner = untag_ptr(this_ptr);
40564         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40566         this_ptr_conv.is_owned = false;
40567         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
40568         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
40569         return ret_arr;
40570 }
40571
40572 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) {
40573         LDKTxCreationKeys this_ptr_conv;
40574         this_ptr_conv.inner = untag_ptr(this_ptr);
40575         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40577         this_ptr_conv.is_owned = false;
40578         LDKPublicKey val_ref;
40579         CHECK((*env)->GetArrayLength(env, val) == 33);
40580         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
40581         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
40582 }
40583
40584 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) {
40585         LDKPublicKey per_commitment_point_arg_ref;
40586         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
40587         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
40588         LDKPublicKey revocation_key_arg_ref;
40589         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
40590         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
40591         LDKPublicKey broadcaster_htlc_key_arg_ref;
40592         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
40593         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
40594         LDKPublicKey countersignatory_htlc_key_arg_ref;
40595         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
40596         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
40597         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
40598         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
40599         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
40600         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);
40601         int64_t ret_ref = 0;
40602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40603         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40604         return ret_ref;
40605 }
40606
40607 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40608         LDKTxCreationKeys a_conv;
40609         a_conv.inner = untag_ptr(a);
40610         a_conv.is_owned = ptr_is_owned(a);
40611         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40612         a_conv.is_owned = false;
40613         LDKTxCreationKeys b_conv;
40614         b_conv.inner = untag_ptr(b);
40615         b_conv.is_owned = ptr_is_owned(b);
40616         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40617         b_conv.is_owned = false;
40618         jboolean ret_conv = TxCreationKeys_eq(&a_conv, &b_conv);
40619         return ret_conv;
40620 }
40621
40622 static inline uint64_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
40623         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
40624         int64_t ret_ref = 0;
40625         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40626         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40627         return ret_ref;
40628 }
40629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40630         LDKTxCreationKeys arg_conv;
40631         arg_conv.inner = untag_ptr(arg);
40632         arg_conv.is_owned = ptr_is_owned(arg);
40633         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40634         arg_conv.is_owned = false;
40635         int64_t ret_conv = TxCreationKeys_clone_ptr(&arg_conv);
40636         return ret_conv;
40637 }
40638
40639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40640         LDKTxCreationKeys orig_conv;
40641         orig_conv.inner = untag_ptr(orig);
40642         orig_conv.is_owned = ptr_is_owned(orig);
40643         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40644         orig_conv.is_owned = false;
40645         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
40646         int64_t ret_ref = 0;
40647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40648         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40649         return ret_ref;
40650 }
40651
40652 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
40653         LDKTxCreationKeys obj_conv;
40654         obj_conv.inner = untag_ptr(obj);
40655         obj_conv.is_owned = ptr_is_owned(obj);
40656         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40657         obj_conv.is_owned = false;
40658         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
40659         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40660         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40661         CVec_u8Z_free(ret_var);
40662         return ret_arr;
40663 }
40664
40665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40666         LDKu8slice ser_ref;
40667         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40668         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40669         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
40670         *ret_conv = TxCreationKeys_read(ser_ref);
40671         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40672         return tag_ptr(ret_conv, true);
40673 }
40674
40675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40676         LDKChannelPublicKeys this_obj_conv;
40677         this_obj_conv.inner = untag_ptr(this_obj);
40678         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40680         ChannelPublicKeys_free(this_obj_conv);
40681 }
40682
40683 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
40684         LDKChannelPublicKeys this_ptr_conv;
40685         this_ptr_conv.inner = untag_ptr(this_ptr);
40686         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40688         this_ptr_conv.is_owned = false;
40689         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
40690         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
40691         return ret_arr;
40692 }
40693
40694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40695         LDKChannelPublicKeys this_ptr_conv;
40696         this_ptr_conv.inner = untag_ptr(this_ptr);
40697         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40699         this_ptr_conv.is_owned = false;
40700         LDKPublicKey val_ref;
40701         CHECK((*env)->GetArrayLength(env, val) == 33);
40702         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
40703         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
40704 }
40705
40706 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
40707         LDKChannelPublicKeys this_ptr_conv;
40708         this_ptr_conv.inner = untag_ptr(this_ptr);
40709         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40711         this_ptr_conv.is_owned = false;
40712         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
40713         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
40714         return ret_arr;
40715 }
40716
40717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40718         LDKChannelPublicKeys this_ptr_conv;
40719         this_ptr_conv.inner = untag_ptr(this_ptr);
40720         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40722         this_ptr_conv.is_owned = false;
40723         LDKPublicKey val_ref;
40724         CHECK((*env)->GetArrayLength(env, val) == 33);
40725         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
40726         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
40727 }
40728
40729 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
40730         LDKChannelPublicKeys this_ptr_conv;
40731         this_ptr_conv.inner = untag_ptr(this_ptr);
40732         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40734         this_ptr_conv.is_owned = false;
40735         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
40736         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
40737         return ret_arr;
40738 }
40739
40740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40741         LDKChannelPublicKeys this_ptr_conv;
40742         this_ptr_conv.inner = untag_ptr(this_ptr);
40743         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40745         this_ptr_conv.is_owned = false;
40746         LDKPublicKey val_ref;
40747         CHECK((*env)->GetArrayLength(env, val) == 33);
40748         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
40749         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
40750 }
40751
40752 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
40753         LDKChannelPublicKeys this_ptr_conv;
40754         this_ptr_conv.inner = untag_ptr(this_ptr);
40755         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40757         this_ptr_conv.is_owned = false;
40758         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
40759         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
40760         return ret_arr;
40761 }
40762
40763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40764         LDKChannelPublicKeys this_ptr_conv;
40765         this_ptr_conv.inner = untag_ptr(this_ptr);
40766         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40768         this_ptr_conv.is_owned = false;
40769         LDKPublicKey val_ref;
40770         CHECK((*env)->GetArrayLength(env, val) == 33);
40771         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
40772         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
40773 }
40774
40775 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
40776         LDKChannelPublicKeys this_ptr_conv;
40777         this_ptr_conv.inner = untag_ptr(this_ptr);
40778         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40780         this_ptr_conv.is_owned = false;
40781         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
40782         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
40783         return ret_arr;
40784 }
40785
40786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40787         LDKChannelPublicKeys this_ptr_conv;
40788         this_ptr_conv.inner = untag_ptr(this_ptr);
40789         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40791         this_ptr_conv.is_owned = false;
40792         LDKPublicKey val_ref;
40793         CHECK((*env)->GetArrayLength(env, val) == 33);
40794         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
40795         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
40796 }
40797
40798 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) {
40799         LDKPublicKey funding_pubkey_arg_ref;
40800         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
40801         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
40802         LDKPublicKey revocation_basepoint_arg_ref;
40803         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
40804         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
40805         LDKPublicKey payment_point_arg_ref;
40806         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
40807         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
40808         LDKPublicKey delayed_payment_basepoint_arg_ref;
40809         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
40810         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
40811         LDKPublicKey htlc_basepoint_arg_ref;
40812         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
40813         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
40814         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);
40815         int64_t ret_ref = 0;
40816         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40817         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40818         return ret_ref;
40819 }
40820
40821 static inline uint64_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
40822         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
40823         int64_t ret_ref = 0;
40824         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40825         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40826         return ret_ref;
40827 }
40828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40829         LDKChannelPublicKeys arg_conv;
40830         arg_conv.inner = untag_ptr(arg);
40831         arg_conv.is_owned = ptr_is_owned(arg);
40832         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40833         arg_conv.is_owned = false;
40834         int64_t ret_conv = ChannelPublicKeys_clone_ptr(&arg_conv);
40835         return ret_conv;
40836 }
40837
40838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40839         LDKChannelPublicKeys orig_conv;
40840         orig_conv.inner = untag_ptr(orig);
40841         orig_conv.is_owned = ptr_is_owned(orig);
40842         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40843         orig_conv.is_owned = false;
40844         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
40845         int64_t ret_ref = 0;
40846         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40847         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40848         return ret_ref;
40849 }
40850
40851 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40852         LDKChannelPublicKeys a_conv;
40853         a_conv.inner = untag_ptr(a);
40854         a_conv.is_owned = ptr_is_owned(a);
40855         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40856         a_conv.is_owned = false;
40857         LDKChannelPublicKeys b_conv;
40858         b_conv.inner = untag_ptr(b);
40859         b_conv.is_owned = ptr_is_owned(b);
40860         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40861         b_conv.is_owned = false;
40862         jboolean ret_conv = ChannelPublicKeys_eq(&a_conv, &b_conv);
40863         return ret_conv;
40864 }
40865
40866 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
40867         LDKChannelPublicKeys obj_conv;
40868         obj_conv.inner = untag_ptr(obj);
40869         obj_conv.is_owned = ptr_is_owned(obj);
40870         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40871         obj_conv.is_owned = false;
40872         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
40873         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40874         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40875         CVec_u8Z_free(ret_var);
40876         return ret_arr;
40877 }
40878
40879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40880         LDKu8slice ser_ref;
40881         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40882         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40883         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
40884         *ret_conv = ChannelPublicKeys_read(ser_ref);
40885         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40886         return tag_ptr(ret_conv, true);
40887 }
40888
40889 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) {
40890         LDKPublicKey per_commitment_point_ref;
40891         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
40892         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
40893         LDKPublicKey broadcaster_delayed_payment_base_ref;
40894         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
40895         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
40896         LDKPublicKey broadcaster_htlc_base_ref;
40897         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
40898         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
40899         LDKPublicKey countersignatory_revocation_base_ref;
40900         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
40901         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
40902         LDKPublicKey countersignatory_htlc_base_ref;
40903         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
40904         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
40905         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
40906         *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);
40907         return tag_ptr(ret_conv, true);
40908 }
40909
40910 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) {
40911         LDKPublicKey per_commitment_point_ref;
40912         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
40913         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
40914         LDKChannelPublicKeys broadcaster_keys_conv;
40915         broadcaster_keys_conv.inner = untag_ptr(broadcaster_keys);
40916         broadcaster_keys_conv.is_owned = ptr_is_owned(broadcaster_keys);
40917         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
40918         broadcaster_keys_conv.is_owned = false;
40919         LDKChannelPublicKeys countersignatory_keys_conv;
40920         countersignatory_keys_conv.inner = untag_ptr(countersignatory_keys);
40921         countersignatory_keys_conv.is_owned = ptr_is_owned(countersignatory_keys);
40922         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
40923         countersignatory_keys_conv.is_owned = false;
40924         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
40925         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
40926         return tag_ptr(ret_conv, true);
40927 }
40928
40929 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) {
40930         LDKPublicKey revocation_key_ref;
40931         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
40932         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
40933         LDKPublicKey broadcaster_delayed_payment_key_ref;
40934         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
40935         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
40936         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
40937         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40938         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40939         CVec_u8Z_free(ret_var);
40940         return ret_arr;
40941 }
40942
40943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40944         LDKHTLCOutputInCommitment this_obj_conv;
40945         this_obj_conv.inner = untag_ptr(this_obj);
40946         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40948         HTLCOutputInCommitment_free(this_obj_conv);
40949 }
40950
40951 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
40952         LDKHTLCOutputInCommitment this_ptr_conv;
40953         this_ptr_conv.inner = untag_ptr(this_ptr);
40954         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40956         this_ptr_conv.is_owned = false;
40957         jboolean ret_conv = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
40958         return ret_conv;
40959 }
40960
40961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
40962         LDKHTLCOutputInCommitment this_ptr_conv;
40963         this_ptr_conv.inner = untag_ptr(this_ptr);
40964         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40966         this_ptr_conv.is_owned = false;
40967         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
40968 }
40969
40970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
40971         LDKHTLCOutputInCommitment this_ptr_conv;
40972         this_ptr_conv.inner = untag_ptr(this_ptr);
40973         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40975         this_ptr_conv.is_owned = false;
40976         int64_t ret_conv = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
40977         return ret_conv;
40978 }
40979
40980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40981         LDKHTLCOutputInCommitment this_ptr_conv;
40982         this_ptr_conv.inner = untag_ptr(this_ptr);
40983         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40985         this_ptr_conv.is_owned = false;
40986         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
40987 }
40988
40989 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
40990         LDKHTLCOutputInCommitment this_ptr_conv;
40991         this_ptr_conv.inner = untag_ptr(this_ptr);
40992         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40994         this_ptr_conv.is_owned = false;
40995         int32_t ret_conv = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
40996         return ret_conv;
40997 }
40998
40999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
41000         LDKHTLCOutputInCommitment this_ptr_conv;
41001         this_ptr_conv.inner = untag_ptr(this_ptr);
41002         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41004         this_ptr_conv.is_owned = false;
41005         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
41006 }
41007
41008 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
41009         LDKHTLCOutputInCommitment this_ptr_conv;
41010         this_ptr_conv.inner = untag_ptr(this_ptr);
41011         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41013         this_ptr_conv.is_owned = false;
41014         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
41015         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
41016         return ret_arr;
41017 }
41018
41019 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41020         LDKHTLCOutputInCommitment this_ptr_conv;
41021         this_ptr_conv.inner = untag_ptr(this_ptr);
41022         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41024         this_ptr_conv.is_owned = false;
41025         LDKThirtyTwoBytes val_ref;
41026         CHECK((*env)->GetArrayLength(env, val) == 32);
41027         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
41028         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
41029 }
41030
41031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
41032         LDKHTLCOutputInCommitment this_ptr_conv;
41033         this_ptr_conv.inner = untag_ptr(this_ptr);
41034         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41036         this_ptr_conv.is_owned = false;
41037         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
41038         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
41039         int64_t ret_ref = tag_ptr(ret_copy, true);
41040         return ret_ref;
41041 }
41042
41043 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41044         LDKHTLCOutputInCommitment this_ptr_conv;
41045         this_ptr_conv.inner = untag_ptr(this_ptr);
41046         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41048         this_ptr_conv.is_owned = false;
41049         void* val_ptr = untag_ptr(val);
41050         CHECK_ACCESS(val_ptr);
41051         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
41052         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
41053         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
41054 }
41055
41056 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) {
41057         LDKThirtyTwoBytes payment_hash_arg_ref;
41058         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
41059         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
41060         void* transaction_output_index_arg_ptr = untag_ptr(transaction_output_index_arg);
41061         CHECK_ACCESS(transaction_output_index_arg_ptr);
41062         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
41063         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(transaction_output_index_arg));
41064         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
41065         int64_t ret_ref = 0;
41066         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41067         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41068         return ret_ref;
41069 }
41070
41071 static inline uint64_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
41072         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
41073         int64_t ret_ref = 0;
41074         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41075         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41076         return ret_ref;
41077 }
41078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41079         LDKHTLCOutputInCommitment arg_conv;
41080         arg_conv.inner = untag_ptr(arg);
41081         arg_conv.is_owned = ptr_is_owned(arg);
41082         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41083         arg_conv.is_owned = false;
41084         int64_t ret_conv = HTLCOutputInCommitment_clone_ptr(&arg_conv);
41085         return ret_conv;
41086 }
41087
41088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41089         LDKHTLCOutputInCommitment orig_conv;
41090         orig_conv.inner = untag_ptr(orig);
41091         orig_conv.is_owned = ptr_is_owned(orig);
41092         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41093         orig_conv.is_owned = false;
41094         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
41095         int64_t ret_ref = 0;
41096         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41097         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41098         return ret_ref;
41099 }
41100
41101 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41102         LDKHTLCOutputInCommitment a_conv;
41103         a_conv.inner = untag_ptr(a);
41104         a_conv.is_owned = ptr_is_owned(a);
41105         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41106         a_conv.is_owned = false;
41107         LDKHTLCOutputInCommitment b_conv;
41108         b_conv.inner = untag_ptr(b);
41109         b_conv.is_owned = ptr_is_owned(b);
41110         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41111         b_conv.is_owned = false;
41112         jboolean ret_conv = HTLCOutputInCommitment_eq(&a_conv, &b_conv);
41113         return ret_conv;
41114 }
41115
41116 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
41117         LDKHTLCOutputInCommitment obj_conv;
41118         obj_conv.inner = untag_ptr(obj);
41119         obj_conv.is_owned = ptr_is_owned(obj);
41120         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41121         obj_conv.is_owned = false;
41122         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
41123         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41124         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41125         CVec_u8Z_free(ret_var);
41126         return ret_arr;
41127 }
41128
41129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41130         LDKu8slice ser_ref;
41131         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41132         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41133         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
41134         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
41135         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41136         return tag_ptr(ret_conv, true);
41137 }
41138
41139 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) {
41140         LDKHTLCOutputInCommitment htlc_conv;
41141         htlc_conv.inner = untag_ptr(htlc);
41142         htlc_conv.is_owned = ptr_is_owned(htlc);
41143         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
41144         htlc_conv.is_owned = false;
41145         LDKTxCreationKeys keys_conv;
41146         keys_conv.inner = untag_ptr(keys);
41147         keys_conv.is_owned = ptr_is_owned(keys);
41148         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
41149         keys_conv.is_owned = false;
41150         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
41151         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41152         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41153         CVec_u8Z_free(ret_var);
41154         return ret_arr;
41155 }
41156
41157 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
41158         LDKPublicKey broadcaster_ref;
41159         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
41160         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
41161         LDKPublicKey countersignatory_ref;
41162         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
41163         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
41164         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
41165         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41166         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41167         CVec_u8Z_free(ret_var);
41168         return ret_arr;
41169 }
41170
41171 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) {
41172         unsigned char commitment_txid_arr[32];
41173         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
41174         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
41175         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
41176         LDKHTLCOutputInCommitment htlc_conv;
41177         htlc_conv.inner = untag_ptr(htlc);
41178         htlc_conv.is_owned = ptr_is_owned(htlc);
41179         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
41180         htlc_conv.is_owned = false;
41181         LDKPublicKey broadcaster_delayed_payment_key_ref;
41182         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
41183         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
41184         LDKPublicKey revocation_key_ref;
41185         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
41186         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
41187         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);
41188         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41189         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41190         Transaction_free(ret_var);
41191         return ret_arr;
41192 }
41193
41194 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1anchor_1redeemscript(JNIEnv *env, jclass clz, int8_tArray funding_pubkey) {
41195         LDKPublicKey funding_pubkey_ref;
41196         CHECK((*env)->GetArrayLength(env, funding_pubkey) == 33);
41197         (*env)->GetByteArrayRegion(env, funding_pubkey, 0, 33, funding_pubkey_ref.compressed_form);
41198         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
41199         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41200         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41201         CVec_u8Z_free(ret_var);
41202         return ret_arr;
41203 }
41204
41205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41206         LDKChannelTransactionParameters this_obj_conv;
41207         this_obj_conv.inner = untag_ptr(this_obj);
41208         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41210         ChannelTransactionParameters_free(this_obj_conv);
41211 }
41212
41213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
41214         LDKChannelTransactionParameters this_ptr_conv;
41215         this_ptr_conv.inner = untag_ptr(this_ptr);
41216         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41218         this_ptr_conv.is_owned = false;
41219         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
41220         int64_t ret_ref = 0;
41221         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41222         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41223         return ret_ref;
41224 }
41225
41226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41227         LDKChannelTransactionParameters this_ptr_conv;
41228         this_ptr_conv.inner = untag_ptr(this_ptr);
41229         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41231         this_ptr_conv.is_owned = false;
41232         LDKChannelPublicKeys val_conv;
41233         val_conv.inner = untag_ptr(val);
41234         val_conv.is_owned = ptr_is_owned(val);
41235         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41236         val_conv = ChannelPublicKeys_clone(&val_conv);
41237         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
41238 }
41239
41240 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
41241         LDKChannelTransactionParameters this_ptr_conv;
41242         this_ptr_conv.inner = untag_ptr(this_ptr);
41243         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41245         this_ptr_conv.is_owned = false;
41246         int16_t ret_conv = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
41247         return ret_conv;
41248 }
41249
41250 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) {
41251         LDKChannelTransactionParameters this_ptr_conv;
41252         this_ptr_conv.inner = untag_ptr(this_ptr);
41253         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41255         this_ptr_conv.is_owned = false;
41256         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
41257 }
41258
41259 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
41260         LDKChannelTransactionParameters this_ptr_conv;
41261         this_ptr_conv.inner = untag_ptr(this_ptr);
41262         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41264         this_ptr_conv.is_owned = false;
41265         jboolean ret_conv = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
41266         return ret_conv;
41267 }
41268
41269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
41270         LDKChannelTransactionParameters this_ptr_conv;
41271         this_ptr_conv.inner = untag_ptr(this_ptr);
41272         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41274         this_ptr_conv.is_owned = false;
41275         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
41276 }
41277
41278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
41279         LDKChannelTransactionParameters this_ptr_conv;
41280         this_ptr_conv.inner = untag_ptr(this_ptr);
41281         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41283         this_ptr_conv.is_owned = false;
41284         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
41285         int64_t ret_ref = 0;
41286         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41287         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41288         return ret_ref;
41289 }
41290
41291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41292         LDKChannelTransactionParameters this_ptr_conv;
41293         this_ptr_conv.inner = untag_ptr(this_ptr);
41294         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41296         this_ptr_conv.is_owned = false;
41297         LDKCounterpartyChannelTransactionParameters val_conv;
41298         val_conv.inner = untag_ptr(val);
41299         val_conv.is_owned = ptr_is_owned(val);
41300         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41301         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
41302         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
41303 }
41304
41305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
41306         LDKChannelTransactionParameters this_ptr_conv;
41307         this_ptr_conv.inner = untag_ptr(this_ptr);
41308         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41310         this_ptr_conv.is_owned = false;
41311         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
41312         int64_t ret_ref = 0;
41313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41314         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41315         return ret_ref;
41316 }
41317
41318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41319         LDKChannelTransactionParameters this_ptr_conv;
41320         this_ptr_conv.inner = untag_ptr(this_ptr);
41321         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41323         this_ptr_conv.is_owned = false;
41324         LDKOutPoint val_conv;
41325         val_conv.inner = untag_ptr(val);
41326         val_conv.is_owned = ptr_is_owned(val);
41327         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41328         val_conv = OutPoint_clone(&val_conv);
41329         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
41330 }
41331
41332 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr) {
41333         LDKChannelTransactionParameters this_ptr_conv;
41334         this_ptr_conv.inner = untag_ptr(this_ptr);
41335         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41337         this_ptr_conv.is_owned = false;
41338         jclass ret_conv = LDKCOption_NoneZ_to_java(env, ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
41339         return ret_conv;
41340 }
41341
41342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
41343         LDKChannelTransactionParameters this_ptr_conv;
41344         this_ptr_conv.inner = untag_ptr(this_ptr);
41345         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41347         this_ptr_conv.is_owned = false;
41348         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_java(env, val);
41349         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
41350 }
41351
41352 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) {
41353         LDKChannelPublicKeys holder_pubkeys_arg_conv;
41354         holder_pubkeys_arg_conv.inner = untag_ptr(holder_pubkeys_arg);
41355         holder_pubkeys_arg_conv.is_owned = ptr_is_owned(holder_pubkeys_arg);
41356         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
41357         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
41358         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
41359         counterparty_parameters_arg_conv.inner = untag_ptr(counterparty_parameters_arg);
41360         counterparty_parameters_arg_conv.is_owned = ptr_is_owned(counterparty_parameters_arg);
41361         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
41362         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
41363         LDKOutPoint funding_outpoint_arg_conv;
41364         funding_outpoint_arg_conv.inner = untag_ptr(funding_outpoint_arg);
41365         funding_outpoint_arg_conv.is_owned = ptr_is_owned(funding_outpoint_arg);
41366         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
41367         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
41368         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_anchors_arg);
41369         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);
41370         int64_t ret_ref = 0;
41371         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41372         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41373         return ret_ref;
41374 }
41375
41376 static inline uint64_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
41377         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
41378         int64_t ret_ref = 0;
41379         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41380         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41381         return ret_ref;
41382 }
41383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41384         LDKChannelTransactionParameters arg_conv;
41385         arg_conv.inner = untag_ptr(arg);
41386         arg_conv.is_owned = ptr_is_owned(arg);
41387         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41388         arg_conv.is_owned = false;
41389         int64_t ret_conv = ChannelTransactionParameters_clone_ptr(&arg_conv);
41390         return ret_conv;
41391 }
41392
41393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41394         LDKChannelTransactionParameters orig_conv;
41395         orig_conv.inner = untag_ptr(orig);
41396         orig_conv.is_owned = ptr_is_owned(orig);
41397         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41398         orig_conv.is_owned = false;
41399         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
41400         int64_t ret_ref = 0;
41401         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41402         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41403         return ret_ref;
41404 }
41405
41406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41407         LDKCounterpartyChannelTransactionParameters this_obj_conv;
41408         this_obj_conv.inner = untag_ptr(this_obj);
41409         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41411         CounterpartyChannelTransactionParameters_free(this_obj_conv);
41412 }
41413
41414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
41415         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
41416         this_ptr_conv.inner = untag_ptr(this_ptr);
41417         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41419         this_ptr_conv.is_owned = false;
41420         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
41421         int64_t ret_ref = 0;
41422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41423         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41424         return ret_ref;
41425 }
41426
41427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41428         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
41429         this_ptr_conv.inner = untag_ptr(this_ptr);
41430         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41432         this_ptr_conv.is_owned = false;
41433         LDKChannelPublicKeys val_conv;
41434         val_conv.inner = untag_ptr(val);
41435         val_conv.is_owned = ptr_is_owned(val);
41436         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41437         val_conv = ChannelPublicKeys_clone(&val_conv);
41438         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
41439 }
41440
41441 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
41442         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
41443         this_ptr_conv.inner = untag_ptr(this_ptr);
41444         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41446         this_ptr_conv.is_owned = false;
41447         int16_t ret_conv = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
41448         return ret_conv;
41449 }
41450
41451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
41452         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
41453         this_ptr_conv.inner = untag_ptr(this_ptr);
41454         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41456         this_ptr_conv.is_owned = false;
41457         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
41458 }
41459
41460 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) {
41461         LDKChannelPublicKeys pubkeys_arg_conv;
41462         pubkeys_arg_conv.inner = untag_ptr(pubkeys_arg);
41463         pubkeys_arg_conv.is_owned = ptr_is_owned(pubkeys_arg);
41464         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
41465         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
41466         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
41467         int64_t ret_ref = 0;
41468         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41469         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41470         return ret_ref;
41471 }
41472
41473 static inline uint64_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
41474         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
41475         int64_t ret_ref = 0;
41476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41477         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41478         return ret_ref;
41479 }
41480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41481         LDKCounterpartyChannelTransactionParameters arg_conv;
41482         arg_conv.inner = untag_ptr(arg);
41483         arg_conv.is_owned = ptr_is_owned(arg);
41484         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41485         arg_conv.is_owned = false;
41486         int64_t ret_conv = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
41487         return ret_conv;
41488 }
41489
41490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41491         LDKCounterpartyChannelTransactionParameters orig_conv;
41492         orig_conv.inner = untag_ptr(orig);
41493         orig_conv.is_owned = ptr_is_owned(orig);
41494         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41495         orig_conv.is_owned = false;
41496         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
41497         int64_t ret_ref = 0;
41498         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41499         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41500         return ret_ref;
41501 }
41502
41503 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
41504         LDKChannelTransactionParameters this_arg_conv;
41505         this_arg_conv.inner = untag_ptr(this_arg);
41506         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41508         this_arg_conv.is_owned = false;
41509         jboolean ret_conv = ChannelTransactionParameters_is_populated(&this_arg_conv);
41510         return ret_conv;
41511 }
41512
41513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
41514         LDKChannelTransactionParameters this_arg_conv;
41515         this_arg_conv.inner = untag_ptr(this_arg);
41516         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41518         this_arg_conv.is_owned = false;
41519         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
41520         int64_t ret_ref = 0;
41521         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41522         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41523         return ret_ref;
41524 }
41525
41526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
41527         LDKChannelTransactionParameters this_arg_conv;
41528         this_arg_conv.inner = untag_ptr(this_arg);
41529         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41531         this_arg_conv.is_owned = false;
41532         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
41533         int64_t ret_ref = 0;
41534         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41535         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41536         return ret_ref;
41537 }
41538
41539 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
41540         LDKCounterpartyChannelTransactionParameters obj_conv;
41541         obj_conv.inner = untag_ptr(obj);
41542         obj_conv.is_owned = ptr_is_owned(obj);
41543         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41544         obj_conv.is_owned = false;
41545         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
41546         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41547         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41548         CVec_u8Z_free(ret_var);
41549         return ret_arr;
41550 }
41551
41552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41553         LDKu8slice ser_ref;
41554         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41555         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41556         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
41557         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
41558         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41559         return tag_ptr(ret_conv, true);
41560 }
41561
41562 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
41563         LDKChannelTransactionParameters obj_conv;
41564         obj_conv.inner = untag_ptr(obj);
41565         obj_conv.is_owned = ptr_is_owned(obj);
41566         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41567         obj_conv.is_owned = false;
41568         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
41569         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41570         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41571         CVec_u8Z_free(ret_var);
41572         return ret_arr;
41573 }
41574
41575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41576         LDKu8slice ser_ref;
41577         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41578         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41579         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
41580         *ret_conv = ChannelTransactionParameters_read(ser_ref);
41581         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41582         return tag_ptr(ret_conv, true);
41583 }
41584
41585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41586         LDKDirectedChannelTransactionParameters this_obj_conv;
41587         this_obj_conv.inner = untag_ptr(this_obj);
41588         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41590         DirectedChannelTransactionParameters_free(this_obj_conv);
41591 }
41592
41593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
41594         LDKDirectedChannelTransactionParameters this_arg_conv;
41595         this_arg_conv.inner = untag_ptr(this_arg);
41596         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41598         this_arg_conv.is_owned = false;
41599         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
41600         int64_t ret_ref = 0;
41601         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41602         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41603         return ret_ref;
41604 }
41605
41606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
41607         LDKDirectedChannelTransactionParameters this_arg_conv;
41608         this_arg_conv.inner = untag_ptr(this_arg);
41609         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41611         this_arg_conv.is_owned = false;
41612         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
41613         int64_t ret_ref = 0;
41614         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41615         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41616         return ret_ref;
41617 }
41618
41619 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
41620         LDKDirectedChannelTransactionParameters this_arg_conv;
41621         this_arg_conv.inner = untag_ptr(this_arg);
41622         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41624         this_arg_conv.is_owned = false;
41625         int16_t ret_conv = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
41626         return ret_conv;
41627 }
41628
41629 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
41630         LDKDirectedChannelTransactionParameters this_arg_conv;
41631         this_arg_conv.inner = untag_ptr(this_arg);
41632         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41634         this_arg_conv.is_owned = false;
41635         jboolean ret_conv = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
41636         return ret_conv;
41637 }
41638
41639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
41640         LDKDirectedChannelTransactionParameters this_arg_conv;
41641         this_arg_conv.inner = untag_ptr(this_arg);
41642         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41644         this_arg_conv.is_owned = false;
41645         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
41646         int64_t ret_ref = 0;
41647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41648         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41649         return ret_ref;
41650 }
41651
41652 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
41653         LDKDirectedChannelTransactionParameters this_arg_conv;
41654         this_arg_conv.inner = untag_ptr(this_arg);
41655         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41657         this_arg_conv.is_owned = false;
41658         jboolean ret_conv = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
41659         return ret_conv;
41660 }
41661
41662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41663         LDKHolderCommitmentTransaction this_obj_conv;
41664         this_obj_conv.inner = untag_ptr(this_obj);
41665         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41667         HolderCommitmentTransaction_free(this_obj_conv);
41668 }
41669
41670 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
41671         LDKHolderCommitmentTransaction this_ptr_conv;
41672         this_ptr_conv.inner = untag_ptr(this_ptr);
41673         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41675         this_ptr_conv.is_owned = false;
41676         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
41677         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
41678         return ret_arr;
41679 }
41680
41681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41682         LDKHolderCommitmentTransaction this_ptr_conv;
41683         this_ptr_conv.inner = untag_ptr(this_ptr);
41684         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41686         this_ptr_conv.is_owned = false;
41687         LDKSignature val_ref;
41688         CHECK((*env)->GetArrayLength(env, val) == 64);
41689         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
41690         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
41691 }
41692
41693 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr) {
41694         LDKHolderCommitmentTransaction this_ptr_conv;
41695         this_ptr_conv.inner = untag_ptr(this_ptr);
41696         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41698         this_ptr_conv.is_owned = false;
41699         LDKCVec_SignatureZ ret_var = HolderCommitmentTransaction_get_counterparty_htlc_sigs(&this_ptr_conv);
41700         jobjectArray ret_arr = NULL;
41701         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
41702         ;
41703         for (size_t i = 0; i < ret_var.datalen; i++) {
41704                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
41705                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
41706                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
41707         }
41708         
41709         FREE(ret_var.data);
41710         return ret_arr;
41711 }
41712
41713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
41714         LDKHolderCommitmentTransaction this_ptr_conv;
41715         this_ptr_conv.inner = untag_ptr(this_ptr);
41716         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41718         this_ptr_conv.is_owned = false;
41719         LDKCVec_SignatureZ val_constr;
41720         val_constr.datalen = (*env)->GetArrayLength(env, val);
41721         if (val_constr.datalen > 0)
41722                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
41723         else
41724                 val_constr.data = NULL;
41725         for (size_t i = 0; i < val_constr.datalen; i++) {
41726                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
41727                 LDKSignature val_conv_8_ref;
41728                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
41729                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
41730                 val_constr.data[i] = val_conv_8_ref;
41731         }
41732         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
41733 }
41734
41735 static inline uint64_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
41736         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
41737         int64_t ret_ref = 0;
41738         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41739         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41740         return ret_ref;
41741 }
41742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41743         LDKHolderCommitmentTransaction arg_conv;
41744         arg_conv.inner = untag_ptr(arg);
41745         arg_conv.is_owned = ptr_is_owned(arg);
41746         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41747         arg_conv.is_owned = false;
41748         int64_t ret_conv = HolderCommitmentTransaction_clone_ptr(&arg_conv);
41749         return ret_conv;
41750 }
41751
41752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41753         LDKHolderCommitmentTransaction orig_conv;
41754         orig_conv.inner = untag_ptr(orig);
41755         orig_conv.is_owned = ptr_is_owned(orig);
41756         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41757         orig_conv.is_owned = false;
41758         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
41759         int64_t ret_ref = 0;
41760         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41761         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41762         return ret_ref;
41763 }
41764
41765 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
41766         LDKHolderCommitmentTransaction obj_conv;
41767         obj_conv.inner = untag_ptr(obj);
41768         obj_conv.is_owned = ptr_is_owned(obj);
41769         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41770         obj_conv.is_owned = false;
41771         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
41772         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41773         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41774         CVec_u8Z_free(ret_var);
41775         return ret_arr;
41776 }
41777
41778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41779         LDKu8slice ser_ref;
41780         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41781         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41782         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
41783         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
41784         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41785         return tag_ptr(ret_conv, true);
41786 }
41787
41788 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) {
41789         LDKCommitmentTransaction commitment_tx_conv;
41790         commitment_tx_conv.inner = untag_ptr(commitment_tx);
41791         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
41792         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
41793         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
41794         LDKSignature counterparty_sig_ref;
41795         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
41796         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
41797         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
41798         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
41799         if (counterparty_htlc_sigs_constr.datalen > 0)
41800                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
41801         else
41802                 counterparty_htlc_sigs_constr.data = NULL;
41803         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
41804                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
41805                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
41806                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
41807                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
41808                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
41809         }
41810         LDKPublicKey holder_funding_key_ref;
41811         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
41812         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
41813         LDKPublicKey counterparty_funding_key_ref;
41814         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
41815         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
41816         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
41817         int64_t ret_ref = 0;
41818         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41819         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41820         return ret_ref;
41821 }
41822
41823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41824         LDKBuiltCommitmentTransaction this_obj_conv;
41825         this_obj_conv.inner = untag_ptr(this_obj);
41826         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41828         BuiltCommitmentTransaction_free(this_obj_conv);
41829 }
41830
41831 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
41832         LDKBuiltCommitmentTransaction this_ptr_conv;
41833         this_ptr_conv.inner = untag_ptr(this_ptr);
41834         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41836         this_ptr_conv.is_owned = false;
41837         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
41838         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41839         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41840         Transaction_free(ret_var);
41841         return ret_arr;
41842 }
41843
41844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41845         LDKBuiltCommitmentTransaction this_ptr_conv;
41846         this_ptr_conv.inner = untag_ptr(this_ptr);
41847         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41849         this_ptr_conv.is_owned = false;
41850         LDKTransaction val_ref;
41851         val_ref.datalen = (*env)->GetArrayLength(env, val);
41852         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
41853         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
41854         val_ref.data_is_owned = true;
41855         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
41856 }
41857
41858 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
41859         LDKBuiltCommitmentTransaction this_ptr_conv;
41860         this_ptr_conv.inner = untag_ptr(this_ptr);
41861         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41863         this_ptr_conv.is_owned = false;
41864         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
41865         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
41866         return ret_arr;
41867 }
41868
41869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41870         LDKBuiltCommitmentTransaction this_ptr_conv;
41871         this_ptr_conv.inner = untag_ptr(this_ptr);
41872         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41874         this_ptr_conv.is_owned = false;
41875         LDKThirtyTwoBytes val_ref;
41876         CHECK((*env)->GetArrayLength(env, val) == 32);
41877         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
41878         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
41879 }
41880
41881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
41882         LDKTransaction transaction_arg_ref;
41883         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
41884         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
41885         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
41886         transaction_arg_ref.data_is_owned = true;
41887         LDKThirtyTwoBytes txid_arg_ref;
41888         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
41889         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
41890         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
41891         int64_t ret_ref = 0;
41892         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41893         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41894         return ret_ref;
41895 }
41896
41897 static inline uint64_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
41898         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
41899         int64_t ret_ref = 0;
41900         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41901         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41902         return ret_ref;
41903 }
41904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41905         LDKBuiltCommitmentTransaction arg_conv;
41906         arg_conv.inner = untag_ptr(arg);
41907         arg_conv.is_owned = ptr_is_owned(arg);
41908         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41909         arg_conv.is_owned = false;
41910         int64_t ret_conv = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
41911         return ret_conv;
41912 }
41913
41914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41915         LDKBuiltCommitmentTransaction orig_conv;
41916         orig_conv.inner = untag_ptr(orig);
41917         orig_conv.is_owned = ptr_is_owned(orig);
41918         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41919         orig_conv.is_owned = false;
41920         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
41921         int64_t ret_ref = 0;
41922         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41923         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41924         return ret_ref;
41925 }
41926
41927 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
41928         LDKBuiltCommitmentTransaction obj_conv;
41929         obj_conv.inner = untag_ptr(obj);
41930         obj_conv.is_owned = ptr_is_owned(obj);
41931         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41932         obj_conv.is_owned = false;
41933         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
41934         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41935         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41936         CVec_u8Z_free(ret_var);
41937         return ret_arr;
41938 }
41939
41940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41941         LDKu8slice ser_ref;
41942         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41943         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41944         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
41945         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
41946         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41947         return tag_ptr(ret_conv, true);
41948 }
41949
41950 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) {
41951         LDKBuiltCommitmentTransaction this_arg_conv;
41952         this_arg_conv.inner = untag_ptr(this_arg);
41953         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41955         this_arg_conv.is_owned = false;
41956         LDKu8slice funding_redeemscript_ref;
41957         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
41958         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
41959         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
41960         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
41961         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
41962         return ret_arr;
41963 }
41964
41965 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) {
41966         LDKBuiltCommitmentTransaction 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         unsigned char funding_key_arr[32];
41972         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
41973         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
41974         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
41975         LDKu8slice funding_redeemscript_ref;
41976         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
41977         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
41978         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
41979         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
41980         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
41981         return ret_arr;
41982 }
41983
41984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41985         LDKClosingTransaction this_obj_conv;
41986         this_obj_conv.inner = untag_ptr(this_obj);
41987         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41989         ClosingTransaction_free(this_obj_conv);
41990 }
41991
41992 static inline uint64_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
41993         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
41994         int64_t ret_ref = 0;
41995         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41996         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41997         return ret_ref;
41998 }
41999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42000         LDKClosingTransaction arg_conv;
42001         arg_conv.inner = untag_ptr(arg);
42002         arg_conv.is_owned = ptr_is_owned(arg);
42003         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42004         arg_conv.is_owned = false;
42005         int64_t ret_conv = ClosingTransaction_clone_ptr(&arg_conv);
42006         return ret_conv;
42007 }
42008
42009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42010         LDKClosingTransaction orig_conv;
42011         orig_conv.inner = untag_ptr(orig);
42012         orig_conv.is_owned = ptr_is_owned(orig);
42013         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42014         orig_conv.is_owned = false;
42015         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
42016         int64_t ret_ref = 0;
42017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42018         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42019         return ret_ref;
42020 }
42021
42022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1hash(JNIEnv *env, jclass clz, int64_t o) {
42023         LDKClosingTransaction o_conv;
42024         o_conv.inner = untag_ptr(o);
42025         o_conv.is_owned = ptr_is_owned(o);
42026         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42027         o_conv.is_owned = false;
42028         int64_t ret_conv = ClosingTransaction_hash(&o_conv);
42029         return ret_conv;
42030 }
42031
42032 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42033         LDKClosingTransaction a_conv;
42034         a_conv.inner = untag_ptr(a);
42035         a_conv.is_owned = ptr_is_owned(a);
42036         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42037         a_conv.is_owned = false;
42038         LDKClosingTransaction b_conv;
42039         b_conv.inner = untag_ptr(b);
42040         b_conv.is_owned = ptr_is_owned(b);
42041         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42042         b_conv.is_owned = false;
42043         jboolean ret_conv = ClosingTransaction_eq(&a_conv, &b_conv);
42044         return ret_conv;
42045 }
42046
42047 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) {
42048         LDKCVec_u8Z to_holder_script_ref;
42049         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
42050         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
42051         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
42052         LDKCVec_u8Z to_counterparty_script_ref;
42053         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
42054         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
42055         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
42056         LDKOutPoint funding_outpoint_conv;
42057         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
42058         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
42059         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
42060         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
42061         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
42062         int64_t ret_ref = 0;
42063         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42064         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42065         return ret_ref;
42066 }
42067
42068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
42069         LDKClosingTransaction this_arg_conv;
42070         this_arg_conv.inner = untag_ptr(this_arg);
42071         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42073         this_arg_conv.is_owned = false;
42074         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
42075         int64_t ret_ref = 0;
42076         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42077         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42078         return ret_ref;
42079 }
42080
42081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) {
42082         LDKClosingTransaction this_arg_conv;
42083         this_arg_conv.inner = untag_ptr(this_arg);
42084         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42086         this_arg_conv.is_owned = false;
42087         LDKOutPoint funding_outpoint_conv;
42088         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
42089         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
42090         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
42091         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
42092         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
42093         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
42094         return tag_ptr(ret_conv, true);
42095 }
42096
42097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
42098         LDKClosingTransaction this_arg_conv;
42099         this_arg_conv.inner = untag_ptr(this_arg);
42100         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42102         this_arg_conv.is_owned = false;
42103         int64_t ret_conv = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
42104         return ret_conv;
42105 }
42106
42107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
42108         LDKClosingTransaction this_arg_conv;
42109         this_arg_conv.inner = untag_ptr(this_arg);
42110         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42112         this_arg_conv.is_owned = false;
42113         int64_t ret_conv = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
42114         return ret_conv;
42115 }
42116
42117 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
42118         LDKClosingTransaction this_arg_conv;
42119         this_arg_conv.inner = untag_ptr(this_arg);
42120         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42122         this_arg_conv.is_owned = false;
42123         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
42124         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42125         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42126         return ret_arr;
42127 }
42128
42129 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
42130         LDKClosingTransaction this_arg_conv;
42131         this_arg_conv.inner = untag_ptr(this_arg);
42132         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42134         this_arg_conv.is_owned = false;
42135         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
42136         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42137         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42138         return ret_arr;
42139 }
42140
42141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42142         LDKTrustedClosingTransaction this_obj_conv;
42143         this_obj_conv.inner = untag_ptr(this_obj);
42144         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42146         TrustedClosingTransaction_free(this_obj_conv);
42147 }
42148
42149 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
42150         LDKTrustedClosingTransaction this_arg_conv;
42151         this_arg_conv.inner = untag_ptr(this_arg);
42152         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42154         this_arg_conv.is_owned = false;
42155         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
42156         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42157         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42158         Transaction_free(ret_var);
42159         return ret_arr;
42160 }
42161
42162 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) {
42163         LDKTrustedClosingTransaction this_arg_conv;
42164         this_arg_conv.inner = untag_ptr(this_arg);
42165         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42167         this_arg_conv.is_owned = false;
42168         LDKu8slice funding_redeemscript_ref;
42169         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
42170         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
42171         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42172         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
42173         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
42174         return ret_arr;
42175 }
42176
42177 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) {
42178         LDKTrustedClosingTransaction this_arg_conv;
42179         this_arg_conv.inner = untag_ptr(this_arg);
42180         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42182         this_arg_conv.is_owned = false;
42183         unsigned char funding_key_arr[32];
42184         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
42185         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
42186         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
42187         LDKu8slice funding_redeemscript_ref;
42188         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
42189         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
42190         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
42191         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
42192         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
42193         return ret_arr;
42194 }
42195
42196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42197         LDKCommitmentTransaction this_obj_conv;
42198         this_obj_conv.inner = untag_ptr(this_obj);
42199         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42201         CommitmentTransaction_free(this_obj_conv);
42202 }
42203
42204 static inline uint64_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
42205         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
42206         int64_t ret_ref = 0;
42207         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42208         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42209         return ret_ref;
42210 }
42211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42212         LDKCommitmentTransaction arg_conv;
42213         arg_conv.inner = untag_ptr(arg);
42214         arg_conv.is_owned = ptr_is_owned(arg);
42215         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42216         arg_conv.is_owned = false;
42217         int64_t ret_conv = CommitmentTransaction_clone_ptr(&arg_conv);
42218         return ret_conv;
42219 }
42220
42221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42222         LDKCommitmentTransaction orig_conv;
42223         orig_conv.inner = untag_ptr(orig);
42224         orig_conv.is_owned = ptr_is_owned(orig);
42225         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42226         orig_conv.is_owned = false;
42227         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
42228         int64_t ret_ref = 0;
42229         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42230         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42231         return ret_ref;
42232 }
42233
42234 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
42235         LDKCommitmentTransaction obj_conv;
42236         obj_conv.inner = untag_ptr(obj);
42237         obj_conv.is_owned = ptr_is_owned(obj);
42238         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42239         obj_conv.is_owned = false;
42240         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
42241         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42242         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42243         CVec_u8Z_free(ret_var);
42244         return ret_arr;
42245 }
42246
42247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42248         LDKu8slice ser_ref;
42249         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42250         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42251         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
42252         *ret_conv = CommitmentTransaction_read(ser_ref);
42253         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42254         return tag_ptr(ret_conv, true);
42255 }
42256
42257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
42258         LDKCommitmentTransaction this_arg_conv;
42259         this_arg_conv.inner = untag_ptr(this_arg);
42260         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42262         this_arg_conv.is_owned = false;
42263         int64_t ret_conv = CommitmentTransaction_commitment_number(&this_arg_conv);
42264         return ret_conv;
42265 }
42266
42267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
42268         LDKCommitmentTransaction this_arg_conv;
42269         this_arg_conv.inner = untag_ptr(this_arg);
42270         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42272         this_arg_conv.is_owned = false;
42273         int64_t ret_conv = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
42274         return ret_conv;
42275 }
42276
42277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
42278         LDKCommitmentTransaction this_arg_conv;
42279         this_arg_conv.inner = untag_ptr(this_arg);
42280         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42282         this_arg_conv.is_owned = false;
42283         int64_t ret_conv = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
42284         return ret_conv;
42285 }
42286
42287 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
42288         LDKCommitmentTransaction this_arg_conv;
42289         this_arg_conv.inner = untag_ptr(this_arg);
42290         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42292         this_arg_conv.is_owned = false;
42293         int32_t ret_conv = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
42294         return ret_conv;
42295 }
42296
42297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
42298         LDKCommitmentTransaction this_arg_conv;
42299         this_arg_conv.inner = untag_ptr(this_arg);
42300         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42302         this_arg_conv.is_owned = false;
42303         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
42304         int64_t ret_ref = 0;
42305         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42306         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42307         return ret_ref;
42308 }
42309
42310 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) {
42311         LDKCommitmentTransaction this_arg_conv;
42312         this_arg_conv.inner = untag_ptr(this_arg);
42313         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42315         this_arg_conv.is_owned = false;
42316         LDKDirectedChannelTransactionParameters channel_parameters_conv;
42317         channel_parameters_conv.inner = untag_ptr(channel_parameters);
42318         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
42319         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
42320         channel_parameters_conv.is_owned = false;
42321         LDKChannelPublicKeys broadcaster_keys_conv;
42322         broadcaster_keys_conv.inner = untag_ptr(broadcaster_keys);
42323         broadcaster_keys_conv.is_owned = ptr_is_owned(broadcaster_keys);
42324         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
42325         broadcaster_keys_conv.is_owned = false;
42326         LDKChannelPublicKeys countersignatory_keys_conv;
42327         countersignatory_keys_conv.inner = untag_ptr(countersignatory_keys);
42328         countersignatory_keys_conv.is_owned = ptr_is_owned(countersignatory_keys);
42329         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
42330         countersignatory_keys_conv.is_owned = false;
42331         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
42332         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
42333         return tag_ptr(ret_conv, true);
42334 }
42335
42336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42337         LDKTrustedCommitmentTransaction this_obj_conv;
42338         this_obj_conv.inner = untag_ptr(this_obj);
42339         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42341         TrustedCommitmentTransaction_free(this_obj_conv);
42342 }
42343
42344 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
42345         LDKTrustedCommitmentTransaction this_arg_conv;
42346         this_arg_conv.inner = untag_ptr(this_arg);
42347         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42349         this_arg_conv.is_owned = false;
42350         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42351         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
42352         return ret_arr;
42353 }
42354
42355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
42356         LDKTrustedCommitmentTransaction this_arg_conv;
42357         this_arg_conv.inner = untag_ptr(this_arg);
42358         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42360         this_arg_conv.is_owned = false;
42361         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
42362         int64_t ret_ref = 0;
42363         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42364         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42365         return ret_ref;
42366 }
42367
42368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
42369         LDKTrustedCommitmentTransaction this_arg_conv;
42370         this_arg_conv.inner = untag_ptr(this_arg);
42371         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42373         this_arg_conv.is_owned = false;
42374         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
42375         int64_t ret_ref = 0;
42376         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42377         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42378         return ret_ref;
42379 }
42380
42381 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
42382         LDKTrustedCommitmentTransaction this_arg_conv;
42383         this_arg_conv.inner = untag_ptr(this_arg);
42384         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42386         this_arg_conv.is_owned = false;
42387         jboolean ret_conv = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
42388         return ret_conv;
42389 }
42390
42391 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) {
42392         LDKTrustedCommitmentTransaction this_arg_conv;
42393         this_arg_conv.inner = untag_ptr(this_arg);
42394         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42396         this_arg_conv.is_owned = false;
42397         unsigned char htlc_base_key_arr[32];
42398         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
42399         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
42400         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
42401         LDKDirectedChannelTransactionParameters channel_parameters_conv;
42402         channel_parameters_conv.inner = untag_ptr(channel_parameters);
42403         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
42404         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
42405         channel_parameters_conv.is_owned = false;
42406         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
42407         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
42408         return tag_ptr(ret_conv, true);
42409 }
42410
42411 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) {
42412         LDKPublicKey broadcaster_payment_basepoint_ref;
42413         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
42414         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
42415         LDKPublicKey countersignatory_payment_basepoint_ref;
42416         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
42417         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
42418         int64_t ret_conv = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
42419         return ret_conv;
42420 }
42421
42422 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42423         LDKInitFeatures a_conv;
42424         a_conv.inner = untag_ptr(a);
42425         a_conv.is_owned = ptr_is_owned(a);
42426         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42427         a_conv.is_owned = false;
42428         LDKInitFeatures b_conv;
42429         b_conv.inner = untag_ptr(b);
42430         b_conv.is_owned = ptr_is_owned(b);
42431         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42432         b_conv.is_owned = false;
42433         jboolean ret_conv = InitFeatures_eq(&a_conv, &b_conv);
42434         return ret_conv;
42435 }
42436
42437 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42438         LDKNodeFeatures a_conv;
42439         a_conv.inner = untag_ptr(a);
42440         a_conv.is_owned = ptr_is_owned(a);
42441         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42442         a_conv.is_owned = false;
42443         LDKNodeFeatures b_conv;
42444         b_conv.inner = untag_ptr(b);
42445         b_conv.is_owned = ptr_is_owned(b);
42446         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42447         b_conv.is_owned = false;
42448         jboolean ret_conv = NodeFeatures_eq(&a_conv, &b_conv);
42449         return ret_conv;
42450 }
42451
42452 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42453         LDKChannelFeatures a_conv;
42454         a_conv.inner = untag_ptr(a);
42455         a_conv.is_owned = ptr_is_owned(a);
42456         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42457         a_conv.is_owned = false;
42458         LDKChannelFeatures b_conv;
42459         b_conv.inner = untag_ptr(b);
42460         b_conv.is_owned = ptr_is_owned(b);
42461         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42462         b_conv.is_owned = false;
42463         jboolean ret_conv = ChannelFeatures_eq(&a_conv, &b_conv);
42464         return ret_conv;
42465 }
42466
42467 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42468         LDKInvoiceFeatures a_conv;
42469         a_conv.inner = untag_ptr(a);
42470         a_conv.is_owned = ptr_is_owned(a);
42471         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42472         a_conv.is_owned = false;
42473         LDKInvoiceFeatures b_conv;
42474         b_conv.inner = untag_ptr(b);
42475         b_conv.is_owned = ptr_is_owned(b);
42476         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42477         b_conv.is_owned = false;
42478         jboolean ret_conv = InvoiceFeatures_eq(&a_conv, &b_conv);
42479         return ret_conv;
42480 }
42481
42482 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42483         LDKChannelTypeFeatures a_conv;
42484         a_conv.inner = untag_ptr(a);
42485         a_conv.is_owned = ptr_is_owned(a);
42486         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42487         a_conv.is_owned = false;
42488         LDKChannelTypeFeatures b_conv;
42489         b_conv.inner = untag_ptr(b);
42490         b_conv.is_owned = ptr_is_owned(b);
42491         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42492         b_conv.is_owned = false;
42493         jboolean ret_conv = ChannelTypeFeatures_eq(&a_conv, &b_conv);
42494         return ret_conv;
42495 }
42496
42497 static inline uint64_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
42498         LDKInitFeatures ret_var = InitFeatures_clone(arg);
42499         int64_t ret_ref = 0;
42500         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42501         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42502         return ret_ref;
42503 }
42504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42505         LDKInitFeatures arg_conv;
42506         arg_conv.inner = untag_ptr(arg);
42507         arg_conv.is_owned = ptr_is_owned(arg);
42508         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42509         arg_conv.is_owned = false;
42510         int64_t ret_conv = InitFeatures_clone_ptr(&arg_conv);
42511         return ret_conv;
42512 }
42513
42514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42515         LDKInitFeatures orig_conv;
42516         orig_conv.inner = untag_ptr(orig);
42517         orig_conv.is_owned = ptr_is_owned(orig);
42518         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42519         orig_conv.is_owned = false;
42520         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
42521         int64_t ret_ref = 0;
42522         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42523         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42524         return ret_ref;
42525 }
42526
42527 static inline uint64_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
42528         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
42529         int64_t ret_ref = 0;
42530         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42531         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42532         return ret_ref;
42533 }
42534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42535         LDKNodeFeatures arg_conv;
42536         arg_conv.inner = untag_ptr(arg);
42537         arg_conv.is_owned = ptr_is_owned(arg);
42538         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42539         arg_conv.is_owned = false;
42540         int64_t ret_conv = NodeFeatures_clone_ptr(&arg_conv);
42541         return ret_conv;
42542 }
42543
42544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42545         LDKNodeFeatures orig_conv;
42546         orig_conv.inner = untag_ptr(orig);
42547         orig_conv.is_owned = ptr_is_owned(orig);
42548         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42549         orig_conv.is_owned = false;
42550         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
42551         int64_t ret_ref = 0;
42552         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42553         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42554         return ret_ref;
42555 }
42556
42557 static inline uint64_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
42558         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
42559         int64_t ret_ref = 0;
42560         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42561         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42562         return ret_ref;
42563 }
42564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42565         LDKChannelFeatures arg_conv;
42566         arg_conv.inner = untag_ptr(arg);
42567         arg_conv.is_owned = ptr_is_owned(arg);
42568         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42569         arg_conv.is_owned = false;
42570         int64_t ret_conv = ChannelFeatures_clone_ptr(&arg_conv);
42571         return ret_conv;
42572 }
42573
42574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42575         LDKChannelFeatures orig_conv;
42576         orig_conv.inner = untag_ptr(orig);
42577         orig_conv.is_owned = ptr_is_owned(orig);
42578         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42579         orig_conv.is_owned = false;
42580         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
42581         int64_t ret_ref = 0;
42582         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42583         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42584         return ret_ref;
42585 }
42586
42587 static inline uint64_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
42588         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
42589         int64_t ret_ref = 0;
42590         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42591         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42592         return ret_ref;
42593 }
42594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42595         LDKInvoiceFeatures arg_conv;
42596         arg_conv.inner = untag_ptr(arg);
42597         arg_conv.is_owned = ptr_is_owned(arg);
42598         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42599         arg_conv.is_owned = false;
42600         int64_t ret_conv = InvoiceFeatures_clone_ptr(&arg_conv);
42601         return ret_conv;
42602 }
42603
42604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42605         LDKInvoiceFeatures orig_conv;
42606         orig_conv.inner = untag_ptr(orig);
42607         orig_conv.is_owned = ptr_is_owned(orig);
42608         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42609         orig_conv.is_owned = false;
42610         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
42611         int64_t ret_ref = 0;
42612         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42613         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42614         return ret_ref;
42615 }
42616
42617 static inline uint64_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
42618         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
42619         int64_t ret_ref = 0;
42620         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42621         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42622         return ret_ref;
42623 }
42624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42625         LDKChannelTypeFeatures arg_conv;
42626         arg_conv.inner = untag_ptr(arg);
42627         arg_conv.is_owned = ptr_is_owned(arg);
42628         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42629         arg_conv.is_owned = false;
42630         int64_t ret_conv = ChannelTypeFeatures_clone_ptr(&arg_conv);
42631         return ret_conv;
42632 }
42633
42634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42635         LDKChannelTypeFeatures orig_conv;
42636         orig_conv.inner = untag_ptr(orig);
42637         orig_conv.is_owned = ptr_is_owned(orig);
42638         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42639         orig_conv.is_owned = false;
42640         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
42641         int64_t ret_ref = 0;
42642         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42643         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42644         return ret_ref;
42645 }
42646
42647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42648         LDKInitFeatures this_obj_conv;
42649         this_obj_conv.inner = untag_ptr(this_obj);
42650         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42652         InitFeatures_free(this_obj_conv);
42653 }
42654
42655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42656         LDKNodeFeatures this_obj_conv;
42657         this_obj_conv.inner = untag_ptr(this_obj);
42658         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42660         NodeFeatures_free(this_obj_conv);
42661 }
42662
42663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42664         LDKChannelFeatures this_obj_conv;
42665         this_obj_conv.inner = untag_ptr(this_obj);
42666         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42668         ChannelFeatures_free(this_obj_conv);
42669 }
42670
42671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42672         LDKInvoiceFeatures this_obj_conv;
42673         this_obj_conv.inner = untag_ptr(this_obj);
42674         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42676         InvoiceFeatures_free(this_obj_conv);
42677 }
42678
42679 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42680         LDKChannelTypeFeatures this_obj_conv;
42681         this_obj_conv.inner = untag_ptr(this_obj);
42682         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42684         ChannelTypeFeatures_free(this_obj_conv);
42685 }
42686
42687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
42688         LDKInitFeatures ret_var = InitFeatures_empty();
42689         int64_t ret_ref = 0;
42690         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42691         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42692         return ret_ref;
42693 }
42694
42695 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
42696         LDKInitFeatures this_arg_conv;
42697         this_arg_conv.inner = untag_ptr(this_arg);
42698         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42700         this_arg_conv.is_owned = false;
42701         jboolean ret_conv = InitFeatures_requires_unknown_bits(&this_arg_conv);
42702         return ret_conv;
42703 }
42704
42705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
42706         LDKNodeFeatures ret_var = NodeFeatures_empty();
42707         int64_t ret_ref = 0;
42708         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42709         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42710         return ret_ref;
42711 }
42712
42713 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
42714         LDKNodeFeatures this_arg_conv;
42715         this_arg_conv.inner = untag_ptr(this_arg);
42716         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42718         this_arg_conv.is_owned = false;
42719         jboolean ret_conv = NodeFeatures_requires_unknown_bits(&this_arg_conv);
42720         return ret_conv;
42721 }
42722
42723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
42724         LDKChannelFeatures ret_var = ChannelFeatures_empty();
42725         int64_t ret_ref = 0;
42726         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42727         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42728         return ret_ref;
42729 }
42730
42731 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
42732         LDKChannelFeatures this_arg_conv;
42733         this_arg_conv.inner = untag_ptr(this_arg);
42734         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42736         this_arg_conv.is_owned = false;
42737         jboolean ret_conv = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
42738         return ret_conv;
42739 }
42740
42741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
42742         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
42743         int64_t ret_ref = 0;
42744         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42745         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42746         return ret_ref;
42747 }
42748
42749 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
42750         LDKInvoiceFeatures this_arg_conv;
42751         this_arg_conv.inner = untag_ptr(this_arg);
42752         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42754         this_arg_conv.is_owned = false;
42755         jboolean ret_conv = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
42756         return ret_conv;
42757 }
42758
42759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1empty(JNIEnv *env, jclass clz) {
42760         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
42761         int64_t ret_ref = 0;
42762         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42763         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42764         return ret_ref;
42765 }
42766
42767 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
42768         LDKChannelTypeFeatures this_arg_conv;
42769         this_arg_conv.inner = untag_ptr(this_arg);
42770         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42772         this_arg_conv.is_owned = false;
42773         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
42774         return ret_conv;
42775 }
42776
42777 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
42778         LDKInitFeatures obj_conv;
42779         obj_conv.inner = untag_ptr(obj);
42780         obj_conv.is_owned = ptr_is_owned(obj);
42781         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42782         obj_conv.is_owned = false;
42783         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
42784         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42785         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42786         CVec_u8Z_free(ret_var);
42787         return ret_arr;
42788 }
42789
42790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42791         LDKu8slice ser_ref;
42792         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42793         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42794         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
42795         *ret_conv = InitFeatures_read(ser_ref);
42796         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42797         return tag_ptr(ret_conv, true);
42798 }
42799
42800 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
42801         LDKChannelFeatures obj_conv;
42802         obj_conv.inner = untag_ptr(obj);
42803         obj_conv.is_owned = ptr_is_owned(obj);
42804         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42805         obj_conv.is_owned = false;
42806         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
42807         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42808         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42809         CVec_u8Z_free(ret_var);
42810         return ret_arr;
42811 }
42812
42813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42814         LDKu8slice ser_ref;
42815         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42816         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42817         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
42818         *ret_conv = ChannelFeatures_read(ser_ref);
42819         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42820         return tag_ptr(ret_conv, true);
42821 }
42822
42823 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
42824         LDKNodeFeatures obj_conv;
42825         obj_conv.inner = untag_ptr(obj);
42826         obj_conv.is_owned = ptr_is_owned(obj);
42827         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42828         obj_conv.is_owned = false;
42829         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
42830         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42831         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42832         CVec_u8Z_free(ret_var);
42833         return ret_arr;
42834 }
42835
42836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42837         LDKu8slice ser_ref;
42838         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42839         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42840         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
42841         *ret_conv = NodeFeatures_read(ser_ref);
42842         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42843         return tag_ptr(ret_conv, true);
42844 }
42845
42846 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
42847         LDKInvoiceFeatures obj_conv;
42848         obj_conv.inner = untag_ptr(obj);
42849         obj_conv.is_owned = ptr_is_owned(obj);
42850         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42851         obj_conv.is_owned = false;
42852         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
42853         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42854         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42855         CVec_u8Z_free(ret_var);
42856         return ret_arr;
42857 }
42858
42859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42860         LDKu8slice ser_ref;
42861         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42862         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42863         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
42864         *ret_conv = InvoiceFeatures_read(ser_ref);
42865         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42866         return tag_ptr(ret_conv, true);
42867 }
42868
42869 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
42870         LDKChannelTypeFeatures obj_conv;
42871         obj_conv.inner = untag_ptr(obj);
42872         obj_conv.is_owned = ptr_is_owned(obj);
42873         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42874         obj_conv.is_owned = false;
42875         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
42876         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42877         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42878         CVec_u8Z_free(ret_var);
42879         return ret_arr;
42880 }
42881
42882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42883         LDKu8slice ser_ref;
42884         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42885         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42886         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
42887         *ret_conv = ChannelTypeFeatures_read(ser_ref);
42888         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42889         return tag_ptr(ret_conv, true);
42890 }
42891
42892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42893         LDKInitFeatures this_arg_conv;
42894         this_arg_conv.inner = untag_ptr(this_arg);
42895         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42897         this_arg_conv.is_owned = false;
42898         InitFeatures_set_data_loss_protect_optional(&this_arg_conv);
42899 }
42900
42901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42902         LDKInitFeatures this_arg_conv;
42903         this_arg_conv.inner = untag_ptr(this_arg);
42904         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42906         this_arg_conv.is_owned = false;
42907         InitFeatures_set_data_loss_protect_required(&this_arg_conv);
42908 }
42909
42910 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
42911         LDKInitFeatures this_arg_conv;
42912         this_arg_conv.inner = untag_ptr(this_arg);
42913         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42915         this_arg_conv.is_owned = false;
42916         jboolean ret_conv = InitFeatures_supports_data_loss_protect(&this_arg_conv);
42917         return ret_conv;
42918 }
42919
42920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42921         LDKNodeFeatures this_arg_conv;
42922         this_arg_conv.inner = untag_ptr(this_arg);
42923         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42925         this_arg_conv.is_owned = false;
42926         NodeFeatures_set_data_loss_protect_optional(&this_arg_conv);
42927 }
42928
42929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42930         LDKNodeFeatures this_arg_conv;
42931         this_arg_conv.inner = untag_ptr(this_arg);
42932         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42934         this_arg_conv.is_owned = false;
42935         NodeFeatures_set_data_loss_protect_required(&this_arg_conv);
42936 }
42937
42938 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
42939         LDKNodeFeatures 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         jboolean ret_conv = NodeFeatures_supports_data_loss_protect(&this_arg_conv);
42945         return ret_conv;
42946 }
42947
42948 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
42949         LDKInitFeatures this_arg_conv;
42950         this_arg_conv.inner = untag_ptr(this_arg);
42951         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42953         this_arg_conv.is_owned = false;
42954         jboolean ret_conv = InitFeatures_requires_data_loss_protect(&this_arg_conv);
42955         return ret_conv;
42956 }
42957
42958 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
42959         LDKNodeFeatures this_arg_conv;
42960         this_arg_conv.inner = untag_ptr(this_arg);
42961         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42963         this_arg_conv.is_owned = false;
42964         jboolean ret_conv = NodeFeatures_requires_data_loss_protect(&this_arg_conv);
42965         return ret_conv;
42966 }
42967
42968 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42969         LDKInitFeatures this_arg_conv;
42970         this_arg_conv.inner = untag_ptr(this_arg);
42971         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42973         this_arg_conv.is_owned = false;
42974         InitFeatures_set_initial_routing_sync_optional(&this_arg_conv);
42975 }
42976
42977 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42978         LDKInitFeatures this_arg_conv;
42979         this_arg_conv.inner = untag_ptr(this_arg);
42980         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42982         this_arg_conv.is_owned = false;
42983         InitFeatures_set_initial_routing_sync_required(&this_arg_conv);
42984 }
42985
42986 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1initial_1routing_1sync(JNIEnv *env, jclass clz, int64_t this_arg) {
42987         LDKInitFeatures this_arg_conv;
42988         this_arg_conv.inner = untag_ptr(this_arg);
42989         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42991         this_arg_conv.is_owned = false;
42992         jboolean ret_conv = InitFeatures_initial_routing_sync(&this_arg_conv);
42993         return ret_conv;
42994 }
42995
42996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42997         LDKInitFeatures this_arg_conv;
42998         this_arg_conv.inner = untag_ptr(this_arg);
42999         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43001         this_arg_conv.is_owned = false;
43002         InitFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
43003 }
43004
43005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43006         LDKInitFeatures this_arg_conv;
43007         this_arg_conv.inner = untag_ptr(this_arg);
43008         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43010         this_arg_conv.is_owned = false;
43011         InitFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
43012 }
43013
43014 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
43015         LDKInitFeatures this_arg_conv;
43016         this_arg_conv.inner = untag_ptr(this_arg);
43017         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43019         this_arg_conv.is_owned = false;
43020         jboolean ret_conv = InitFeatures_supports_upfront_shutdown_script(&this_arg_conv);
43021         return ret_conv;
43022 }
43023
43024 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43025         LDKNodeFeatures this_arg_conv;
43026         this_arg_conv.inner = untag_ptr(this_arg);
43027         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43029         this_arg_conv.is_owned = false;
43030         NodeFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
43031 }
43032
43033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43034         LDKNodeFeatures this_arg_conv;
43035         this_arg_conv.inner = untag_ptr(this_arg);
43036         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43038         this_arg_conv.is_owned = false;
43039         NodeFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
43040 }
43041
43042 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
43043         LDKNodeFeatures this_arg_conv;
43044         this_arg_conv.inner = untag_ptr(this_arg);
43045         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43047         this_arg_conv.is_owned = false;
43048         jboolean ret_conv = NodeFeatures_supports_upfront_shutdown_script(&this_arg_conv);
43049         return ret_conv;
43050 }
43051
43052 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
43053         LDKInitFeatures this_arg_conv;
43054         this_arg_conv.inner = untag_ptr(this_arg);
43055         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43057         this_arg_conv.is_owned = false;
43058         jboolean ret_conv = InitFeatures_requires_upfront_shutdown_script(&this_arg_conv);
43059         return ret_conv;
43060 }
43061
43062 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
43063         LDKNodeFeatures this_arg_conv;
43064         this_arg_conv.inner = untag_ptr(this_arg);
43065         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43067         this_arg_conv.is_owned = false;
43068         jboolean ret_conv = NodeFeatures_requires_upfront_shutdown_script(&this_arg_conv);
43069         return ret_conv;
43070 }
43071
43072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43073         LDKInitFeatures this_arg_conv;
43074         this_arg_conv.inner = untag_ptr(this_arg);
43075         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43077         this_arg_conv.is_owned = false;
43078         InitFeatures_set_gossip_queries_optional(&this_arg_conv);
43079 }
43080
43081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43082         LDKInitFeatures 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         InitFeatures_set_gossip_queries_required(&this_arg_conv);
43088 }
43089
43090 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
43091         LDKInitFeatures this_arg_conv;
43092         this_arg_conv.inner = untag_ptr(this_arg);
43093         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43095         this_arg_conv.is_owned = false;
43096         jboolean ret_conv = InitFeatures_supports_gossip_queries(&this_arg_conv);
43097         return ret_conv;
43098 }
43099
43100 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43101         LDKNodeFeatures this_arg_conv;
43102         this_arg_conv.inner = untag_ptr(this_arg);
43103         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43105         this_arg_conv.is_owned = false;
43106         NodeFeatures_set_gossip_queries_optional(&this_arg_conv);
43107 }
43108
43109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43110         LDKNodeFeatures this_arg_conv;
43111         this_arg_conv.inner = untag_ptr(this_arg);
43112         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43114         this_arg_conv.is_owned = false;
43115         NodeFeatures_set_gossip_queries_required(&this_arg_conv);
43116 }
43117
43118 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
43119         LDKNodeFeatures this_arg_conv;
43120         this_arg_conv.inner = untag_ptr(this_arg);
43121         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43123         this_arg_conv.is_owned = false;
43124         jboolean ret_conv = NodeFeatures_supports_gossip_queries(&this_arg_conv);
43125         return ret_conv;
43126 }
43127
43128 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
43129         LDKInitFeatures this_arg_conv;
43130         this_arg_conv.inner = untag_ptr(this_arg);
43131         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43133         this_arg_conv.is_owned = false;
43134         jboolean ret_conv = InitFeatures_requires_gossip_queries(&this_arg_conv);
43135         return ret_conv;
43136 }
43137
43138 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
43139         LDKNodeFeatures this_arg_conv;
43140         this_arg_conv.inner = untag_ptr(this_arg);
43141         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43143         this_arg_conv.is_owned = false;
43144         jboolean ret_conv = NodeFeatures_requires_gossip_queries(&this_arg_conv);
43145         return ret_conv;
43146 }
43147
43148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43149         LDKInitFeatures this_arg_conv;
43150         this_arg_conv.inner = untag_ptr(this_arg);
43151         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43153         this_arg_conv.is_owned = false;
43154         InitFeatures_set_variable_length_onion_optional(&this_arg_conv);
43155 }
43156
43157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43158         LDKInitFeatures this_arg_conv;
43159         this_arg_conv.inner = untag_ptr(this_arg);
43160         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43162         this_arg_conv.is_owned = false;
43163         InitFeatures_set_variable_length_onion_required(&this_arg_conv);
43164 }
43165
43166 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
43167         LDKInitFeatures this_arg_conv;
43168         this_arg_conv.inner = untag_ptr(this_arg);
43169         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43171         this_arg_conv.is_owned = false;
43172         jboolean ret_conv = InitFeatures_supports_variable_length_onion(&this_arg_conv);
43173         return ret_conv;
43174 }
43175
43176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43177         LDKNodeFeatures this_arg_conv;
43178         this_arg_conv.inner = untag_ptr(this_arg);
43179         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43181         this_arg_conv.is_owned = false;
43182         NodeFeatures_set_variable_length_onion_optional(&this_arg_conv);
43183 }
43184
43185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43186         LDKNodeFeatures this_arg_conv;
43187         this_arg_conv.inner = untag_ptr(this_arg);
43188         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43190         this_arg_conv.is_owned = false;
43191         NodeFeatures_set_variable_length_onion_required(&this_arg_conv);
43192 }
43193
43194 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
43195         LDKNodeFeatures this_arg_conv;
43196         this_arg_conv.inner = untag_ptr(this_arg);
43197         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43199         this_arg_conv.is_owned = false;
43200         jboolean ret_conv = NodeFeatures_supports_variable_length_onion(&this_arg_conv);
43201         return ret_conv;
43202 }
43203
43204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43205         LDKInvoiceFeatures this_arg_conv;
43206         this_arg_conv.inner = untag_ptr(this_arg);
43207         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43209         this_arg_conv.is_owned = false;
43210         InvoiceFeatures_set_variable_length_onion_optional(&this_arg_conv);
43211 }
43212
43213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43214         LDKInvoiceFeatures this_arg_conv;
43215         this_arg_conv.inner = untag_ptr(this_arg);
43216         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43218         this_arg_conv.is_owned = false;
43219         InvoiceFeatures_set_variable_length_onion_required(&this_arg_conv);
43220 }
43221
43222 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
43223         LDKInvoiceFeatures this_arg_conv;
43224         this_arg_conv.inner = untag_ptr(this_arg);
43225         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43227         this_arg_conv.is_owned = false;
43228         jboolean ret_conv = InvoiceFeatures_supports_variable_length_onion(&this_arg_conv);
43229         return ret_conv;
43230 }
43231
43232 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
43233         LDKInitFeatures this_arg_conv;
43234         this_arg_conv.inner = untag_ptr(this_arg);
43235         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43237         this_arg_conv.is_owned = false;
43238         jboolean ret_conv = InitFeatures_requires_variable_length_onion(&this_arg_conv);
43239         return ret_conv;
43240 }
43241
43242 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
43243         LDKNodeFeatures this_arg_conv;
43244         this_arg_conv.inner = untag_ptr(this_arg);
43245         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43247         this_arg_conv.is_owned = false;
43248         jboolean ret_conv = NodeFeatures_requires_variable_length_onion(&this_arg_conv);
43249         return ret_conv;
43250 }
43251
43252 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
43253         LDKInvoiceFeatures this_arg_conv;
43254         this_arg_conv.inner = untag_ptr(this_arg);
43255         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43257         this_arg_conv.is_owned = false;
43258         jboolean ret_conv = InvoiceFeatures_requires_variable_length_onion(&this_arg_conv);
43259         return ret_conv;
43260 }
43261
43262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43263         LDKInitFeatures this_arg_conv;
43264         this_arg_conv.inner = untag_ptr(this_arg);
43265         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43267         this_arg_conv.is_owned = false;
43268         InitFeatures_set_static_remote_key_optional(&this_arg_conv);
43269 }
43270
43271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43272         LDKInitFeatures this_arg_conv;
43273         this_arg_conv.inner = untag_ptr(this_arg);
43274         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43276         this_arg_conv.is_owned = false;
43277         InitFeatures_set_static_remote_key_required(&this_arg_conv);
43278 }
43279
43280 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
43281         LDKInitFeatures this_arg_conv;
43282         this_arg_conv.inner = untag_ptr(this_arg);
43283         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43285         this_arg_conv.is_owned = false;
43286         jboolean ret_conv = InitFeatures_supports_static_remote_key(&this_arg_conv);
43287         return ret_conv;
43288 }
43289
43290 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43291         LDKNodeFeatures this_arg_conv;
43292         this_arg_conv.inner = untag_ptr(this_arg);
43293         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43295         this_arg_conv.is_owned = false;
43296         NodeFeatures_set_static_remote_key_optional(&this_arg_conv);
43297 }
43298
43299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43300         LDKNodeFeatures this_arg_conv;
43301         this_arg_conv.inner = untag_ptr(this_arg);
43302         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43304         this_arg_conv.is_owned = false;
43305         NodeFeatures_set_static_remote_key_required(&this_arg_conv);
43306 }
43307
43308 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
43309         LDKNodeFeatures this_arg_conv;
43310         this_arg_conv.inner = untag_ptr(this_arg);
43311         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43313         this_arg_conv.is_owned = false;
43314         jboolean ret_conv = NodeFeatures_supports_static_remote_key(&this_arg_conv);
43315         return ret_conv;
43316 }
43317
43318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43319         LDKChannelTypeFeatures this_arg_conv;
43320         this_arg_conv.inner = untag_ptr(this_arg);
43321         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43323         this_arg_conv.is_owned = false;
43324         ChannelTypeFeatures_set_static_remote_key_optional(&this_arg_conv);
43325 }
43326
43327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43328         LDKChannelTypeFeatures this_arg_conv;
43329         this_arg_conv.inner = untag_ptr(this_arg);
43330         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43332         this_arg_conv.is_owned = false;
43333         ChannelTypeFeatures_set_static_remote_key_required(&this_arg_conv);
43334 }
43335
43336 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
43337         LDKChannelTypeFeatures this_arg_conv;
43338         this_arg_conv.inner = untag_ptr(this_arg);
43339         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43341         this_arg_conv.is_owned = false;
43342         jboolean ret_conv = ChannelTypeFeatures_supports_static_remote_key(&this_arg_conv);
43343         return ret_conv;
43344 }
43345
43346 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
43347         LDKInitFeatures this_arg_conv;
43348         this_arg_conv.inner = untag_ptr(this_arg);
43349         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43351         this_arg_conv.is_owned = false;
43352         jboolean ret_conv = InitFeatures_requires_static_remote_key(&this_arg_conv);
43353         return ret_conv;
43354 }
43355
43356 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
43357         LDKNodeFeatures this_arg_conv;
43358         this_arg_conv.inner = untag_ptr(this_arg);
43359         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43361         this_arg_conv.is_owned = false;
43362         jboolean ret_conv = NodeFeatures_requires_static_remote_key(&this_arg_conv);
43363         return ret_conv;
43364 }
43365
43366 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
43367         LDKChannelTypeFeatures this_arg_conv;
43368         this_arg_conv.inner = untag_ptr(this_arg);
43369         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43371         this_arg_conv.is_owned = false;
43372         jboolean ret_conv = ChannelTypeFeatures_requires_static_remote_key(&this_arg_conv);
43373         return ret_conv;
43374 }
43375
43376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43377         LDKInitFeatures this_arg_conv;
43378         this_arg_conv.inner = untag_ptr(this_arg);
43379         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43381         this_arg_conv.is_owned = false;
43382         InitFeatures_set_payment_secret_optional(&this_arg_conv);
43383 }
43384
43385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43386         LDKInitFeatures this_arg_conv;
43387         this_arg_conv.inner = untag_ptr(this_arg);
43388         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43390         this_arg_conv.is_owned = false;
43391         InitFeatures_set_payment_secret_required(&this_arg_conv);
43392 }
43393
43394 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
43395         LDKInitFeatures this_arg_conv;
43396         this_arg_conv.inner = untag_ptr(this_arg);
43397         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43399         this_arg_conv.is_owned = false;
43400         jboolean ret_conv = InitFeatures_supports_payment_secret(&this_arg_conv);
43401         return ret_conv;
43402 }
43403
43404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43405         LDKNodeFeatures this_arg_conv;
43406         this_arg_conv.inner = untag_ptr(this_arg);
43407         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43409         this_arg_conv.is_owned = false;
43410         NodeFeatures_set_payment_secret_optional(&this_arg_conv);
43411 }
43412
43413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43414         LDKNodeFeatures this_arg_conv;
43415         this_arg_conv.inner = untag_ptr(this_arg);
43416         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43418         this_arg_conv.is_owned = false;
43419         NodeFeatures_set_payment_secret_required(&this_arg_conv);
43420 }
43421
43422 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
43423         LDKNodeFeatures this_arg_conv;
43424         this_arg_conv.inner = untag_ptr(this_arg);
43425         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43427         this_arg_conv.is_owned = false;
43428         jboolean ret_conv = NodeFeatures_supports_payment_secret(&this_arg_conv);
43429         return ret_conv;
43430 }
43431
43432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43433         LDKInvoiceFeatures this_arg_conv;
43434         this_arg_conv.inner = untag_ptr(this_arg);
43435         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43437         this_arg_conv.is_owned = false;
43438         InvoiceFeatures_set_payment_secret_optional(&this_arg_conv);
43439 }
43440
43441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43442         LDKInvoiceFeatures this_arg_conv;
43443         this_arg_conv.inner = untag_ptr(this_arg);
43444         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43446         this_arg_conv.is_owned = false;
43447         InvoiceFeatures_set_payment_secret_required(&this_arg_conv);
43448 }
43449
43450 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
43451         LDKInvoiceFeatures this_arg_conv;
43452         this_arg_conv.inner = untag_ptr(this_arg);
43453         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43455         this_arg_conv.is_owned = false;
43456         jboolean ret_conv = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
43457         return ret_conv;
43458 }
43459
43460 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
43461         LDKInitFeatures this_arg_conv;
43462         this_arg_conv.inner = untag_ptr(this_arg);
43463         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43465         this_arg_conv.is_owned = false;
43466         jboolean ret_conv = InitFeatures_requires_payment_secret(&this_arg_conv);
43467         return ret_conv;
43468 }
43469
43470 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
43471         LDKNodeFeatures this_arg_conv;
43472         this_arg_conv.inner = untag_ptr(this_arg);
43473         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43475         this_arg_conv.is_owned = false;
43476         jboolean ret_conv = NodeFeatures_requires_payment_secret(&this_arg_conv);
43477         return ret_conv;
43478 }
43479
43480 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
43481         LDKInvoiceFeatures this_arg_conv;
43482         this_arg_conv.inner = untag_ptr(this_arg);
43483         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43485         this_arg_conv.is_owned = false;
43486         jboolean ret_conv = InvoiceFeatures_requires_payment_secret(&this_arg_conv);
43487         return ret_conv;
43488 }
43489
43490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43491         LDKInitFeatures this_arg_conv;
43492         this_arg_conv.inner = untag_ptr(this_arg);
43493         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43495         this_arg_conv.is_owned = false;
43496         InitFeatures_set_basic_mpp_optional(&this_arg_conv);
43497 }
43498
43499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43500         LDKInitFeatures this_arg_conv;
43501         this_arg_conv.inner = untag_ptr(this_arg);
43502         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43504         this_arg_conv.is_owned = false;
43505         InitFeatures_set_basic_mpp_required(&this_arg_conv);
43506 }
43507
43508 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
43509         LDKInitFeatures this_arg_conv;
43510         this_arg_conv.inner = untag_ptr(this_arg);
43511         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43513         this_arg_conv.is_owned = false;
43514         jboolean ret_conv = InitFeatures_supports_basic_mpp(&this_arg_conv);
43515         return ret_conv;
43516 }
43517
43518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43519         LDKNodeFeatures this_arg_conv;
43520         this_arg_conv.inner = untag_ptr(this_arg);
43521         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43523         this_arg_conv.is_owned = false;
43524         NodeFeatures_set_basic_mpp_optional(&this_arg_conv);
43525 }
43526
43527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43528         LDKNodeFeatures this_arg_conv;
43529         this_arg_conv.inner = untag_ptr(this_arg);
43530         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43532         this_arg_conv.is_owned = false;
43533         NodeFeatures_set_basic_mpp_required(&this_arg_conv);
43534 }
43535
43536 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
43537         LDKNodeFeatures this_arg_conv;
43538         this_arg_conv.inner = untag_ptr(this_arg);
43539         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43541         this_arg_conv.is_owned = false;
43542         jboolean ret_conv = NodeFeatures_supports_basic_mpp(&this_arg_conv);
43543         return ret_conv;
43544 }
43545
43546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43547         LDKInvoiceFeatures this_arg_conv;
43548         this_arg_conv.inner = untag_ptr(this_arg);
43549         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43551         this_arg_conv.is_owned = false;
43552         InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
43553 }
43554
43555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43556         LDKInvoiceFeatures this_arg_conv;
43557         this_arg_conv.inner = untag_ptr(this_arg);
43558         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43560         this_arg_conv.is_owned = false;
43561         InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
43562 }
43563
43564 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
43565         LDKInvoiceFeatures this_arg_conv;
43566         this_arg_conv.inner = untag_ptr(this_arg);
43567         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43569         this_arg_conv.is_owned = false;
43570         jboolean ret_conv = InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
43571         return ret_conv;
43572 }
43573
43574 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
43575         LDKInitFeatures this_arg_conv;
43576         this_arg_conv.inner = untag_ptr(this_arg);
43577         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43579         this_arg_conv.is_owned = false;
43580         jboolean ret_conv = InitFeatures_requires_basic_mpp(&this_arg_conv);
43581         return ret_conv;
43582 }
43583
43584 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
43585         LDKNodeFeatures this_arg_conv;
43586         this_arg_conv.inner = untag_ptr(this_arg);
43587         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43589         this_arg_conv.is_owned = false;
43590         jboolean ret_conv = NodeFeatures_requires_basic_mpp(&this_arg_conv);
43591         return ret_conv;
43592 }
43593
43594 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
43595         LDKInvoiceFeatures this_arg_conv;
43596         this_arg_conv.inner = untag_ptr(this_arg);
43597         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43599         this_arg_conv.is_owned = false;
43600         jboolean ret_conv = InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
43601         return ret_conv;
43602 }
43603
43604 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43605         LDKInitFeatures this_arg_conv;
43606         this_arg_conv.inner = untag_ptr(this_arg);
43607         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43609         this_arg_conv.is_owned = false;
43610         InitFeatures_set_wumbo_optional(&this_arg_conv);
43611 }
43612
43613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43614         LDKInitFeatures this_arg_conv;
43615         this_arg_conv.inner = untag_ptr(this_arg);
43616         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43618         this_arg_conv.is_owned = false;
43619         InitFeatures_set_wumbo_required(&this_arg_conv);
43620 }
43621
43622 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
43623         LDKInitFeatures this_arg_conv;
43624         this_arg_conv.inner = untag_ptr(this_arg);
43625         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43627         this_arg_conv.is_owned = false;
43628         jboolean ret_conv = InitFeatures_supports_wumbo(&this_arg_conv);
43629         return ret_conv;
43630 }
43631
43632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43633         LDKNodeFeatures this_arg_conv;
43634         this_arg_conv.inner = untag_ptr(this_arg);
43635         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43637         this_arg_conv.is_owned = false;
43638         NodeFeatures_set_wumbo_optional(&this_arg_conv);
43639 }
43640
43641 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43642         LDKNodeFeatures this_arg_conv;
43643         this_arg_conv.inner = untag_ptr(this_arg);
43644         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43646         this_arg_conv.is_owned = false;
43647         NodeFeatures_set_wumbo_required(&this_arg_conv);
43648 }
43649
43650 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
43651         LDKNodeFeatures this_arg_conv;
43652         this_arg_conv.inner = untag_ptr(this_arg);
43653         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43655         this_arg_conv.is_owned = false;
43656         jboolean ret_conv = NodeFeatures_supports_wumbo(&this_arg_conv);
43657         return ret_conv;
43658 }
43659
43660 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
43661         LDKInitFeatures this_arg_conv;
43662         this_arg_conv.inner = untag_ptr(this_arg);
43663         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43665         this_arg_conv.is_owned = false;
43666         jboolean ret_conv = InitFeatures_requires_wumbo(&this_arg_conv);
43667         return ret_conv;
43668 }
43669
43670 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
43671         LDKNodeFeatures this_arg_conv;
43672         this_arg_conv.inner = untag_ptr(this_arg);
43673         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43675         this_arg_conv.is_owned = false;
43676         jboolean ret_conv = NodeFeatures_requires_wumbo(&this_arg_conv);
43677         return ret_conv;
43678 }
43679
43680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43681         LDKInitFeatures this_arg_conv;
43682         this_arg_conv.inner = untag_ptr(this_arg);
43683         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43685         this_arg_conv.is_owned = false;
43686         InitFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
43687 }
43688
43689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43690         LDKInitFeatures this_arg_conv;
43691         this_arg_conv.inner = untag_ptr(this_arg);
43692         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43694         this_arg_conv.is_owned = false;
43695         InitFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
43696 }
43697
43698 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
43699         LDKInitFeatures this_arg_conv;
43700         this_arg_conv.inner = untag_ptr(this_arg);
43701         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43703         this_arg_conv.is_owned = false;
43704         jboolean ret_conv = InitFeatures_supports_shutdown_anysegwit(&this_arg_conv);
43705         return ret_conv;
43706 }
43707
43708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43709         LDKNodeFeatures this_arg_conv;
43710         this_arg_conv.inner = untag_ptr(this_arg);
43711         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43713         this_arg_conv.is_owned = false;
43714         NodeFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
43715 }
43716
43717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43718         LDKNodeFeatures this_arg_conv;
43719         this_arg_conv.inner = untag_ptr(this_arg);
43720         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43722         this_arg_conv.is_owned = false;
43723         NodeFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
43724 }
43725
43726 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
43727         LDKNodeFeatures this_arg_conv;
43728         this_arg_conv.inner = untag_ptr(this_arg);
43729         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43731         this_arg_conv.is_owned = false;
43732         jboolean ret_conv = NodeFeatures_supports_shutdown_anysegwit(&this_arg_conv);
43733         return ret_conv;
43734 }
43735
43736 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
43737         LDKInitFeatures this_arg_conv;
43738         this_arg_conv.inner = untag_ptr(this_arg);
43739         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43741         this_arg_conv.is_owned = false;
43742         jboolean ret_conv = InitFeatures_requires_shutdown_anysegwit(&this_arg_conv);
43743         return ret_conv;
43744 }
43745
43746 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
43747         LDKNodeFeatures this_arg_conv;
43748         this_arg_conv.inner = untag_ptr(this_arg);
43749         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43751         this_arg_conv.is_owned = false;
43752         jboolean ret_conv = NodeFeatures_requires_shutdown_anysegwit(&this_arg_conv);
43753         return ret_conv;
43754 }
43755
43756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1onion_1messages_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43757         LDKInitFeatures this_arg_conv;
43758         this_arg_conv.inner = untag_ptr(this_arg);
43759         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43761         this_arg_conv.is_owned = false;
43762         InitFeatures_set_onion_messages_optional(&this_arg_conv);
43763 }
43764
43765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1onion_1messages_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43766         LDKInitFeatures this_arg_conv;
43767         this_arg_conv.inner = untag_ptr(this_arg);
43768         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43770         this_arg_conv.is_owned = false;
43771         InitFeatures_set_onion_messages_required(&this_arg_conv);
43772 }
43773
43774 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
43775         LDKInitFeatures this_arg_conv;
43776         this_arg_conv.inner = untag_ptr(this_arg);
43777         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43779         this_arg_conv.is_owned = false;
43780         jboolean ret_conv = InitFeatures_supports_onion_messages(&this_arg_conv);
43781         return ret_conv;
43782 }
43783
43784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1onion_1messages_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43785         LDKNodeFeatures this_arg_conv;
43786         this_arg_conv.inner = untag_ptr(this_arg);
43787         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43789         this_arg_conv.is_owned = false;
43790         NodeFeatures_set_onion_messages_optional(&this_arg_conv);
43791 }
43792
43793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1onion_1messages_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43794         LDKNodeFeatures this_arg_conv;
43795         this_arg_conv.inner = untag_ptr(this_arg);
43796         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43798         this_arg_conv.is_owned = false;
43799         NodeFeatures_set_onion_messages_required(&this_arg_conv);
43800 }
43801
43802 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
43803         LDKNodeFeatures this_arg_conv;
43804         this_arg_conv.inner = untag_ptr(this_arg);
43805         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43807         this_arg_conv.is_owned = false;
43808         jboolean ret_conv = NodeFeatures_supports_onion_messages(&this_arg_conv);
43809         return ret_conv;
43810 }
43811
43812 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
43813         LDKInitFeatures this_arg_conv;
43814         this_arg_conv.inner = untag_ptr(this_arg);
43815         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43817         this_arg_conv.is_owned = false;
43818         jboolean ret_conv = InitFeatures_requires_onion_messages(&this_arg_conv);
43819         return ret_conv;
43820 }
43821
43822 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
43823         LDKNodeFeatures this_arg_conv;
43824         this_arg_conv.inner = untag_ptr(this_arg);
43825         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43827         this_arg_conv.is_owned = false;
43828         jboolean ret_conv = NodeFeatures_requires_onion_messages(&this_arg_conv);
43829         return ret_conv;
43830 }
43831
43832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43833         LDKInitFeatures this_arg_conv;
43834         this_arg_conv.inner = untag_ptr(this_arg);
43835         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43837         this_arg_conv.is_owned = false;
43838         InitFeatures_set_channel_type_optional(&this_arg_conv);
43839 }
43840
43841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43842         LDKInitFeatures this_arg_conv;
43843         this_arg_conv.inner = untag_ptr(this_arg);
43844         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43846         this_arg_conv.is_owned = false;
43847         InitFeatures_set_channel_type_required(&this_arg_conv);
43848 }
43849
43850 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
43851         LDKInitFeatures this_arg_conv;
43852         this_arg_conv.inner = untag_ptr(this_arg);
43853         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43855         this_arg_conv.is_owned = false;
43856         jboolean ret_conv = InitFeatures_supports_channel_type(&this_arg_conv);
43857         return ret_conv;
43858 }
43859
43860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43861         LDKNodeFeatures this_arg_conv;
43862         this_arg_conv.inner = untag_ptr(this_arg);
43863         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43865         this_arg_conv.is_owned = false;
43866         NodeFeatures_set_channel_type_optional(&this_arg_conv);
43867 }
43868
43869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43870         LDKNodeFeatures this_arg_conv;
43871         this_arg_conv.inner = untag_ptr(this_arg);
43872         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43874         this_arg_conv.is_owned = false;
43875         NodeFeatures_set_channel_type_required(&this_arg_conv);
43876 }
43877
43878 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
43879         LDKNodeFeatures this_arg_conv;
43880         this_arg_conv.inner = untag_ptr(this_arg);
43881         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43883         this_arg_conv.is_owned = false;
43884         jboolean ret_conv = NodeFeatures_supports_channel_type(&this_arg_conv);
43885         return ret_conv;
43886 }
43887
43888 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
43889         LDKInitFeatures this_arg_conv;
43890         this_arg_conv.inner = untag_ptr(this_arg);
43891         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43893         this_arg_conv.is_owned = false;
43894         jboolean ret_conv = InitFeatures_requires_channel_type(&this_arg_conv);
43895         return ret_conv;
43896 }
43897
43898 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
43899         LDKNodeFeatures this_arg_conv;
43900         this_arg_conv.inner = untag_ptr(this_arg);
43901         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43903         this_arg_conv.is_owned = false;
43904         jboolean ret_conv = NodeFeatures_requires_channel_type(&this_arg_conv);
43905         return ret_conv;
43906 }
43907
43908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43909         LDKInitFeatures this_arg_conv;
43910         this_arg_conv.inner = untag_ptr(this_arg);
43911         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43913         this_arg_conv.is_owned = false;
43914         InitFeatures_set_scid_privacy_optional(&this_arg_conv);
43915 }
43916
43917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43918         LDKInitFeatures this_arg_conv;
43919         this_arg_conv.inner = untag_ptr(this_arg);
43920         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43922         this_arg_conv.is_owned = false;
43923         InitFeatures_set_scid_privacy_required(&this_arg_conv);
43924 }
43925
43926 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
43927         LDKInitFeatures this_arg_conv;
43928         this_arg_conv.inner = untag_ptr(this_arg);
43929         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43931         this_arg_conv.is_owned = false;
43932         jboolean ret_conv = InitFeatures_supports_scid_privacy(&this_arg_conv);
43933         return ret_conv;
43934 }
43935
43936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43937         LDKNodeFeatures this_arg_conv;
43938         this_arg_conv.inner = untag_ptr(this_arg);
43939         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43941         this_arg_conv.is_owned = false;
43942         NodeFeatures_set_scid_privacy_optional(&this_arg_conv);
43943 }
43944
43945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43946         LDKNodeFeatures this_arg_conv;
43947         this_arg_conv.inner = untag_ptr(this_arg);
43948         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43950         this_arg_conv.is_owned = false;
43951         NodeFeatures_set_scid_privacy_required(&this_arg_conv);
43952 }
43953
43954 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
43955         LDKNodeFeatures this_arg_conv;
43956         this_arg_conv.inner = untag_ptr(this_arg);
43957         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43959         this_arg_conv.is_owned = false;
43960         jboolean ret_conv = NodeFeatures_supports_scid_privacy(&this_arg_conv);
43961         return ret_conv;
43962 }
43963
43964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43965         LDKChannelTypeFeatures this_arg_conv;
43966         this_arg_conv.inner = untag_ptr(this_arg);
43967         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43969         this_arg_conv.is_owned = false;
43970         ChannelTypeFeatures_set_scid_privacy_optional(&this_arg_conv);
43971 }
43972
43973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43974         LDKChannelTypeFeatures this_arg_conv;
43975         this_arg_conv.inner = untag_ptr(this_arg);
43976         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43978         this_arg_conv.is_owned = false;
43979         ChannelTypeFeatures_set_scid_privacy_required(&this_arg_conv);
43980 }
43981
43982 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
43983         LDKChannelTypeFeatures this_arg_conv;
43984         this_arg_conv.inner = untag_ptr(this_arg);
43985         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43987         this_arg_conv.is_owned = false;
43988         jboolean ret_conv = ChannelTypeFeatures_supports_scid_privacy(&this_arg_conv);
43989         return ret_conv;
43990 }
43991
43992 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
43993         LDKInitFeatures this_arg_conv;
43994         this_arg_conv.inner = untag_ptr(this_arg);
43995         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43997         this_arg_conv.is_owned = false;
43998         jboolean ret_conv = InitFeatures_requires_scid_privacy(&this_arg_conv);
43999         return ret_conv;
44000 }
44001
44002 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
44003         LDKNodeFeatures this_arg_conv;
44004         this_arg_conv.inner = untag_ptr(this_arg);
44005         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44007         this_arg_conv.is_owned = false;
44008         jboolean ret_conv = NodeFeatures_requires_scid_privacy(&this_arg_conv);
44009         return ret_conv;
44010 }
44011
44012 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
44013         LDKChannelTypeFeatures this_arg_conv;
44014         this_arg_conv.inner = untag_ptr(this_arg);
44015         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44017         this_arg_conv.is_owned = false;
44018         jboolean ret_conv = ChannelTypeFeatures_requires_scid_privacy(&this_arg_conv);
44019         return ret_conv;
44020 }
44021
44022 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44023         LDKInitFeatures this_arg_conv;
44024         this_arg_conv.inner = untag_ptr(this_arg);
44025         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44027         this_arg_conv.is_owned = false;
44028         InitFeatures_set_zero_conf_optional(&this_arg_conv);
44029 }
44030
44031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44032         LDKInitFeatures this_arg_conv;
44033         this_arg_conv.inner = untag_ptr(this_arg);
44034         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44036         this_arg_conv.is_owned = false;
44037         InitFeatures_set_zero_conf_required(&this_arg_conv);
44038 }
44039
44040 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
44041         LDKInitFeatures this_arg_conv;
44042         this_arg_conv.inner = untag_ptr(this_arg);
44043         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44045         this_arg_conv.is_owned = false;
44046         jboolean ret_conv = InitFeatures_supports_zero_conf(&this_arg_conv);
44047         return ret_conv;
44048 }
44049
44050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44051         LDKNodeFeatures this_arg_conv;
44052         this_arg_conv.inner = untag_ptr(this_arg);
44053         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44055         this_arg_conv.is_owned = false;
44056         NodeFeatures_set_zero_conf_optional(&this_arg_conv);
44057 }
44058
44059 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44060         LDKNodeFeatures this_arg_conv;
44061         this_arg_conv.inner = untag_ptr(this_arg);
44062         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44064         this_arg_conv.is_owned = false;
44065         NodeFeatures_set_zero_conf_required(&this_arg_conv);
44066 }
44067
44068 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
44069         LDKNodeFeatures this_arg_conv;
44070         this_arg_conv.inner = untag_ptr(this_arg);
44071         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44073         this_arg_conv.is_owned = false;
44074         jboolean ret_conv = NodeFeatures_supports_zero_conf(&this_arg_conv);
44075         return ret_conv;
44076 }
44077
44078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44079         LDKChannelTypeFeatures this_arg_conv;
44080         this_arg_conv.inner = untag_ptr(this_arg);
44081         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44083         this_arg_conv.is_owned = false;
44084         ChannelTypeFeatures_set_zero_conf_optional(&this_arg_conv);
44085 }
44086
44087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44088         LDKChannelTypeFeatures this_arg_conv;
44089         this_arg_conv.inner = untag_ptr(this_arg);
44090         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44092         this_arg_conv.is_owned = false;
44093         ChannelTypeFeatures_set_zero_conf_required(&this_arg_conv);
44094 }
44095
44096 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
44097         LDKChannelTypeFeatures this_arg_conv;
44098         this_arg_conv.inner = untag_ptr(this_arg);
44099         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44101         this_arg_conv.is_owned = false;
44102         jboolean ret_conv = ChannelTypeFeatures_supports_zero_conf(&this_arg_conv);
44103         return ret_conv;
44104 }
44105
44106 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
44107         LDKInitFeatures this_arg_conv;
44108         this_arg_conv.inner = untag_ptr(this_arg);
44109         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44111         this_arg_conv.is_owned = false;
44112         jboolean ret_conv = InitFeatures_requires_zero_conf(&this_arg_conv);
44113         return ret_conv;
44114 }
44115
44116 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
44117         LDKNodeFeatures this_arg_conv;
44118         this_arg_conv.inner = untag_ptr(this_arg);
44119         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44121         this_arg_conv.is_owned = false;
44122         jboolean ret_conv = NodeFeatures_requires_zero_conf(&this_arg_conv);
44123         return ret_conv;
44124 }
44125
44126 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
44127         LDKChannelTypeFeatures this_arg_conv;
44128         this_arg_conv.inner = untag_ptr(this_arg);
44129         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44131         this_arg_conv.is_owned = false;
44132         jboolean ret_conv = ChannelTypeFeatures_requires_zero_conf(&this_arg_conv);
44133         return ret_conv;
44134 }
44135
44136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44137         LDKNodeFeatures this_arg_conv;
44138         this_arg_conv.inner = untag_ptr(this_arg);
44139         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44141         this_arg_conv.is_owned = false;
44142         NodeFeatures_set_keysend_optional(&this_arg_conv);
44143 }
44144
44145 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44146         LDKNodeFeatures this_arg_conv;
44147         this_arg_conv.inner = untag_ptr(this_arg);
44148         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44150         this_arg_conv.is_owned = false;
44151         NodeFeatures_set_keysend_required(&this_arg_conv);
44152 }
44153
44154 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
44155         LDKNodeFeatures this_arg_conv;
44156         this_arg_conv.inner = untag_ptr(this_arg);
44157         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44159         this_arg_conv.is_owned = false;
44160         jboolean ret_conv = NodeFeatures_supports_keysend(&this_arg_conv);
44161         return ret_conv;
44162 }
44163
44164 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
44165         LDKNodeFeatures this_arg_conv;
44166         this_arg_conv.inner = untag_ptr(this_arg);
44167         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44169         this_arg_conv.is_owned = false;
44170         jboolean ret_conv = NodeFeatures_requires_keysend(&this_arg_conv);
44171         return ret_conv;
44172 }
44173
44174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44175         LDKShutdownScript this_obj_conv;
44176         this_obj_conv.inner = untag_ptr(this_obj);
44177         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44179         ShutdownScript_free(this_obj_conv);
44180 }
44181
44182 static inline uint64_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
44183         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
44184         int64_t ret_ref = 0;
44185         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44186         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44187         return ret_ref;
44188 }
44189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44190         LDKShutdownScript arg_conv;
44191         arg_conv.inner = untag_ptr(arg);
44192         arg_conv.is_owned = ptr_is_owned(arg);
44193         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44194         arg_conv.is_owned = false;
44195         int64_t ret_conv = ShutdownScript_clone_ptr(&arg_conv);
44196         return ret_conv;
44197 }
44198
44199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44200         LDKShutdownScript orig_conv;
44201         orig_conv.inner = untag_ptr(orig);
44202         orig_conv.is_owned = ptr_is_owned(orig);
44203         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44204         orig_conv.is_owned = false;
44205         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
44206         int64_t ret_ref = 0;
44207         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44208         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44209         return ret_ref;
44210 }
44211
44212 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44213         LDKShutdownScript a_conv;
44214         a_conv.inner = untag_ptr(a);
44215         a_conv.is_owned = ptr_is_owned(a);
44216         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44217         a_conv.is_owned = false;
44218         LDKShutdownScript b_conv;
44219         b_conv.inner = untag_ptr(b);
44220         b_conv.is_owned = ptr_is_owned(b);
44221         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44222         b_conv.is_owned = false;
44223         jboolean ret_conv = ShutdownScript_eq(&a_conv, &b_conv);
44224         return ret_conv;
44225 }
44226
44227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44228         LDKInvalidShutdownScript this_obj_conv;
44229         this_obj_conv.inner = untag_ptr(this_obj);
44230         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44232         InvalidShutdownScript_free(this_obj_conv);
44233 }
44234
44235 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
44236         LDKInvalidShutdownScript this_ptr_conv;
44237         this_ptr_conv.inner = untag_ptr(this_ptr);
44238         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44240         this_ptr_conv.is_owned = false;
44241         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
44242         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44243         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44244         return ret_arr;
44245 }
44246
44247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
44248         LDKInvalidShutdownScript this_ptr_conv;
44249         this_ptr_conv.inner = untag_ptr(this_ptr);
44250         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44252         this_ptr_conv.is_owned = false;
44253         LDKCVec_u8Z val_ref;
44254         val_ref.datalen = (*env)->GetArrayLength(env, val);
44255         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
44256         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
44257         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
44258 }
44259
44260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
44261         LDKCVec_u8Z script_arg_ref;
44262         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
44263         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
44264         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
44265         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
44266         int64_t ret_ref = 0;
44267         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44268         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44269         return ret_ref;
44270 }
44271
44272 static inline uint64_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
44273         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
44274         int64_t ret_ref = 0;
44275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44276         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44277         return ret_ref;
44278 }
44279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44280         LDKInvalidShutdownScript arg_conv;
44281         arg_conv.inner = untag_ptr(arg);
44282         arg_conv.is_owned = ptr_is_owned(arg);
44283         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44284         arg_conv.is_owned = false;
44285         int64_t ret_conv = InvalidShutdownScript_clone_ptr(&arg_conv);
44286         return ret_conv;
44287 }
44288
44289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44290         LDKInvalidShutdownScript orig_conv;
44291         orig_conv.inner = untag_ptr(orig);
44292         orig_conv.is_owned = ptr_is_owned(orig);
44293         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44294         orig_conv.is_owned = false;
44295         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
44296         int64_t ret_ref = 0;
44297         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44298         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44299         return ret_ref;
44300 }
44301
44302 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
44303         LDKShutdownScript obj_conv;
44304         obj_conv.inner = untag_ptr(obj);
44305         obj_conv.is_owned = ptr_is_owned(obj);
44306         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44307         obj_conv.is_owned = false;
44308         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
44309         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44310         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44311         CVec_u8Z_free(ret_var);
44312         return ret_arr;
44313 }
44314
44315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44316         LDKu8slice ser_ref;
44317         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44318         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44319         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
44320         *ret_conv = ShutdownScript_read(ser_ref);
44321         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44322         return tag_ptr(ret_conv, true);
44323 }
44324
44325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
44326         unsigned char pubkey_hash_arr[20];
44327         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
44328         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
44329         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
44330         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
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 int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
44338         unsigned char script_hash_arr[32];
44339         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
44340         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
44341         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
44342         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
44343         int64_t ret_ref = 0;
44344         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44345         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44346         return ret_ref;
44347 }
44348
44349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
44350         
44351         LDKu8slice program_ref;
44352         program_ref.datalen = (*env)->GetArrayLength(env, program);
44353         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
44354         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
44355         *ret_conv = ShutdownScript_new_witness_program((LDKWitnessVersion){ ._0 = version }, program_ref);
44356         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
44357         return tag_ptr(ret_conv, true);
44358 }
44359
44360 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
44361         LDKShutdownScript this_arg_conv;
44362         this_arg_conv.inner = untag_ptr(this_arg);
44363         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44365         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
44366         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
44367         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44368         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44369         CVec_u8Z_free(ret_var);
44370         return ret_arr;
44371 }
44372
44373 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
44374         LDKShutdownScript this_arg_conv;
44375         this_arg_conv.inner = untag_ptr(this_arg);
44376         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44378         this_arg_conv.is_owned = false;
44379         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
44380         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
44381         return ret_arr;
44382 }
44383
44384 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
44385         LDKShutdownScript this_arg_conv;
44386         this_arg_conv.inner = untag_ptr(this_arg);
44387         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44389         this_arg_conv.is_owned = false;
44390         LDKInitFeatures features_conv;
44391         features_conv.inner = untag_ptr(features);
44392         features_conv.is_owned = ptr_is_owned(features);
44393         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
44394         features_conv.is_owned = false;
44395         jboolean ret_conv = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
44396         return ret_conv;
44397 }
44398
44399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
44400         if (!ptr_is_owned(this_ptr)) return;
44401         void* this_ptr_ptr = untag_ptr(this_ptr);
44402         CHECK_ACCESS(this_ptr_ptr);
44403         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
44404         FREE(untag_ptr(this_ptr));
44405         CustomMessageReader_free(this_ptr_conv);
44406 }
44407
44408 static inline uint64_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
44409         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
44410         *ret_ret = Type_clone(arg);
44411         return tag_ptr(ret_ret, true);
44412 }
44413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44414         void* arg_ptr = untag_ptr(arg);
44415         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
44416         LDKType* arg_conv = (LDKType*)arg_ptr;
44417         int64_t ret_conv = Type_clone_ptr(arg_conv);
44418         return ret_conv;
44419 }
44420
44421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44422         void* orig_ptr = untag_ptr(orig);
44423         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
44424         LDKType* orig_conv = (LDKType*)orig_ptr;
44425         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
44426         *ret_ret = Type_clone(orig_conv);
44427         return tag_ptr(ret_ret, true);
44428 }
44429
44430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
44431         if (!ptr_is_owned(this_ptr)) return;
44432         void* this_ptr_ptr = untag_ptr(this_ptr);
44433         CHECK_ACCESS(this_ptr_ptr);
44434         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
44435         FREE(untag_ptr(this_ptr));
44436         Type_free(this_ptr_conv);
44437 }
44438
44439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44440         LDKNodeId this_obj_conv;
44441         this_obj_conv.inner = untag_ptr(this_obj);
44442         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44444         NodeId_free(this_obj_conv);
44445 }
44446
44447 static inline uint64_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
44448         LDKNodeId ret_var = NodeId_clone(arg);
44449         int64_t ret_ref = 0;
44450         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44451         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44452         return ret_ref;
44453 }
44454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44455         LDKNodeId arg_conv;
44456         arg_conv.inner = untag_ptr(arg);
44457         arg_conv.is_owned = ptr_is_owned(arg);
44458         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44459         arg_conv.is_owned = false;
44460         int64_t ret_conv = NodeId_clone_ptr(&arg_conv);
44461         return ret_conv;
44462 }
44463
44464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44465         LDKNodeId orig_conv;
44466         orig_conv.inner = untag_ptr(orig);
44467         orig_conv.is_owned = ptr_is_owned(orig);
44468         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44469         orig_conv.is_owned = false;
44470         LDKNodeId ret_var = NodeId_clone(&orig_conv);
44471         int64_t ret_ref = 0;
44472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44473         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44474         return ret_ref;
44475 }
44476
44477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv *env, jclass clz, int8_tArray pubkey) {
44478         LDKPublicKey pubkey_ref;
44479         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
44480         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
44481         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
44482         int64_t ret_ref = 0;
44483         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44484         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44485         return ret_ref;
44486 }
44487
44488 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1slice(JNIEnv *env, jclass clz, int64_t this_arg) {
44489         LDKNodeId this_arg_conv;
44490         this_arg_conv.inner = untag_ptr(this_arg);
44491         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44493         this_arg_conv.is_owned = false;
44494         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
44495         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44496         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44497         return ret_arr;
44498 }
44499
44500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1hash(JNIEnv *env, jclass clz, int64_t o) {
44501         LDKNodeId o_conv;
44502         o_conv.inner = untag_ptr(o);
44503         o_conv.is_owned = ptr_is_owned(o);
44504         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44505         o_conv.is_owned = false;
44506         int64_t ret_conv = NodeId_hash(&o_conv);
44507         return ret_conv;
44508 }
44509
44510 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1write(JNIEnv *env, jclass clz, int64_t obj) {
44511         LDKNodeId obj_conv;
44512         obj_conv.inner = untag_ptr(obj);
44513         obj_conv.is_owned = ptr_is_owned(obj);
44514         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44515         obj_conv.is_owned = false;
44516         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
44517         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44518         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44519         CVec_u8Z_free(ret_var);
44520         return ret_arr;
44521 }
44522
44523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44524         LDKu8slice ser_ref;
44525         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44526         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44527         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
44528         *ret_conv = NodeId_read(ser_ref);
44529         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44530         return tag_ptr(ret_conv, true);
44531 }
44532
44533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44534         LDKNetworkGraph this_obj_conv;
44535         this_obj_conv.inner = untag_ptr(this_obj);
44536         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44538         NetworkGraph_free(this_obj_conv);
44539 }
44540
44541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44542         LDKReadOnlyNetworkGraph this_obj_conv;
44543         this_obj_conv.inner = untag_ptr(this_obj);
44544         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44546         ReadOnlyNetworkGraph_free(this_obj_conv);
44547 }
44548
44549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
44550         if (!ptr_is_owned(this_ptr)) return;
44551         void* this_ptr_ptr = untag_ptr(this_ptr);
44552         CHECK_ACCESS(this_ptr_ptr);
44553         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
44554         FREE(untag_ptr(this_ptr));
44555         NetworkUpdate_free(this_ptr_conv);
44556 }
44557
44558 static inline uint64_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
44559         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
44560         *ret_copy = NetworkUpdate_clone(arg);
44561         int64_t ret_ref = tag_ptr(ret_copy, true);
44562         return ret_ref;
44563 }
44564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44565         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)untag_ptr(arg);
44566         int64_t ret_conv = NetworkUpdate_clone_ptr(arg_conv);
44567         return ret_conv;
44568 }
44569
44570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44571         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)untag_ptr(orig);
44572         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
44573         *ret_copy = NetworkUpdate_clone(orig_conv);
44574         int64_t ret_ref = tag_ptr(ret_copy, true);
44575         return ret_ref;
44576 }
44577
44578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
44579         LDKChannelUpdate msg_conv;
44580         msg_conv.inner = untag_ptr(msg);
44581         msg_conv.is_owned = ptr_is_owned(msg);
44582         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
44583         msg_conv = ChannelUpdate_clone(&msg_conv);
44584         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
44585         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
44586         int64_t ret_ref = tag_ptr(ret_copy, true);
44587         return ret_ref;
44588 }
44589
44590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1failure(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
44591         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
44592         *ret_copy = NetworkUpdate_channel_failure(short_channel_id, is_permanent);
44593         int64_t ret_ref = tag_ptr(ret_copy, true);
44594         return ret_ref;
44595 }
44596
44597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
44598         LDKPublicKey node_id_ref;
44599         CHECK((*env)->GetArrayLength(env, node_id) == 33);
44600         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
44601         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
44602         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
44603         int64_t ret_ref = tag_ptr(ret_copy, true);
44604         return ret_ref;
44605 }
44606
44607 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44608         LDKNetworkUpdate* a_conv = (LDKNetworkUpdate*)untag_ptr(a);
44609         LDKNetworkUpdate* b_conv = (LDKNetworkUpdate*)untag_ptr(b);
44610         jboolean ret_conv = NetworkUpdate_eq(a_conv, b_conv);
44611         return ret_conv;
44612 }
44613
44614 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
44615         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)untag_ptr(obj);
44616         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
44617         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44618         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44619         CVec_u8Z_free(ret_var);
44620         return ret_arr;
44621 }
44622
44623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44624         LDKu8slice ser_ref;
44625         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44626         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44627         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
44628         *ret_conv = NetworkUpdate_read(ser_ref);
44629         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44630         return tag_ptr(ret_conv, true);
44631 }
44632
44633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44634         LDKP2PGossipSync this_obj_conv;
44635         this_obj_conv.inner = untag_ptr(this_obj);
44636         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44638         P2PGossipSync_free(this_obj_conv);
44639 }
44640
44641 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) {
44642         LDKNetworkGraph network_graph_conv;
44643         network_graph_conv.inner = untag_ptr(network_graph);
44644         network_graph_conv.is_owned = ptr_is_owned(network_graph);
44645         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
44646         network_graph_conv.is_owned = false;
44647         void* chain_access_ptr = untag_ptr(chain_access);
44648         CHECK_ACCESS(chain_access_ptr);
44649         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
44650         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
44651         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
44652                 // Manually implement clone for Java trait instances
44653                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
44654                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44655                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
44656                 }
44657         }
44658         void* logger_ptr = untag_ptr(logger);
44659         CHECK_ACCESS(logger_ptr);
44660         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
44661         if (logger_conv.free == LDKLogger_JCalls_free) {
44662                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44663                 LDKLogger_JCalls_cloned(&logger_conv);
44664         }
44665         LDKP2PGossipSync ret_var = P2PGossipSync_new(&network_graph_conv, chain_access_conv, logger_conv);
44666         int64_t ret_ref = 0;
44667         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44668         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44669         return ret_ref;
44670 }
44671
44672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
44673         LDKP2PGossipSync this_arg_conv;
44674         this_arg_conv.inner = untag_ptr(this_arg);
44675         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44677         this_arg_conv.is_owned = false;
44678         void* chain_access_ptr = untag_ptr(chain_access);
44679         CHECK_ACCESS(chain_access_ptr);
44680         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
44681         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
44682         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
44683                 // Manually implement clone for Java trait instances
44684                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
44685                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44686                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
44687                 }
44688         }
44689         P2PGossipSync_add_chain_access(&this_arg_conv, chain_access_conv);
44690 }
44691
44692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
44693         LDKNetworkGraph this_arg_conv;
44694         this_arg_conv.inner = untag_ptr(this_arg);
44695         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44697         this_arg_conv.is_owned = false;
44698         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
44699         *ret_ret = NetworkGraph_as_EventHandler(&this_arg_conv);
44700         return tag_ptr(ret_ret, true);
44701 }
44702
44703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
44704         LDKP2PGossipSync this_arg_conv;
44705         this_arg_conv.inner = untag_ptr(this_arg);
44706         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44708         this_arg_conv.is_owned = false;
44709         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
44710         *ret_ret = P2PGossipSync_as_RoutingMessageHandler(&this_arg_conv);
44711         return tag_ptr(ret_ret, true);
44712 }
44713
44714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
44715         LDKP2PGossipSync this_arg_conv;
44716         this_arg_conv.inner = untag_ptr(this_arg);
44717         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44719         this_arg_conv.is_owned = false;
44720         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
44721         *ret_ret = P2PGossipSync_as_MessageSendEventsProvider(&this_arg_conv);
44722         return tag_ptr(ret_ret, true);
44723 }
44724
44725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44726         LDKChannelUpdateInfo this_obj_conv;
44727         this_obj_conv.inner = untag_ptr(this_obj);
44728         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44730         ChannelUpdateInfo_free(this_obj_conv);
44731 }
44732
44733 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
44734         LDKChannelUpdateInfo this_ptr_conv;
44735         this_ptr_conv.inner = untag_ptr(this_ptr);
44736         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44738         this_ptr_conv.is_owned = false;
44739         int32_t ret_conv = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
44740         return ret_conv;
44741 }
44742
44743 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
44744         LDKChannelUpdateInfo this_ptr_conv;
44745         this_ptr_conv.inner = untag_ptr(this_ptr);
44746         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44748         this_ptr_conv.is_owned = false;
44749         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
44750 }
44751
44752 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
44753         LDKChannelUpdateInfo this_ptr_conv;
44754         this_ptr_conv.inner = untag_ptr(this_ptr);
44755         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44757         this_ptr_conv.is_owned = false;
44758         jboolean ret_conv = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
44759         return ret_conv;
44760 }
44761
44762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
44763         LDKChannelUpdateInfo this_ptr_conv;
44764         this_ptr_conv.inner = untag_ptr(this_ptr);
44765         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44767         this_ptr_conv.is_owned = false;
44768         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
44769 }
44770
44771 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
44772         LDKChannelUpdateInfo this_ptr_conv;
44773         this_ptr_conv.inner = untag_ptr(this_ptr);
44774         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44776         this_ptr_conv.is_owned = false;
44777         int16_t ret_conv = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
44778         return ret_conv;
44779 }
44780
44781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
44782         LDKChannelUpdateInfo this_ptr_conv;
44783         this_ptr_conv.inner = untag_ptr(this_ptr);
44784         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44786         this_ptr_conv.is_owned = false;
44787         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
44788 }
44789
44790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
44791         LDKChannelUpdateInfo this_ptr_conv;
44792         this_ptr_conv.inner = untag_ptr(this_ptr);
44793         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44795         this_ptr_conv.is_owned = false;
44796         int64_t ret_conv = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
44797         return ret_conv;
44798 }
44799
44800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44801         LDKChannelUpdateInfo this_ptr_conv;
44802         this_ptr_conv.inner = untag_ptr(this_ptr);
44803         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44805         this_ptr_conv.is_owned = false;
44806         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
44807 }
44808
44809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
44810         LDKChannelUpdateInfo this_ptr_conv;
44811         this_ptr_conv.inner = untag_ptr(this_ptr);
44812         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44814         this_ptr_conv.is_owned = false;
44815         int64_t ret_conv = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
44816         return ret_conv;
44817 }
44818
44819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44820         LDKChannelUpdateInfo this_ptr_conv;
44821         this_ptr_conv.inner = untag_ptr(this_ptr);
44822         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44824         this_ptr_conv.is_owned = false;
44825         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val);
44826 }
44827
44828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
44829         LDKChannelUpdateInfo this_ptr_conv;
44830         this_ptr_conv.inner = untag_ptr(this_ptr);
44831         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44833         this_ptr_conv.is_owned = false;
44834         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
44835         int64_t ret_ref = 0;
44836         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44837         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44838         return ret_ref;
44839 }
44840
44841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44842         LDKChannelUpdateInfo this_ptr_conv;
44843         this_ptr_conv.inner = untag_ptr(this_ptr);
44844         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44846         this_ptr_conv.is_owned = false;
44847         LDKRoutingFees val_conv;
44848         val_conv.inner = untag_ptr(val);
44849         val_conv.is_owned = ptr_is_owned(val);
44850         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44851         val_conv = RoutingFees_clone(&val_conv);
44852         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
44853 }
44854
44855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
44856         LDKChannelUpdateInfo this_ptr_conv;
44857         this_ptr_conv.inner = untag_ptr(this_ptr);
44858         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44860         this_ptr_conv.is_owned = false;
44861         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
44862         int64_t ret_ref = 0;
44863         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44864         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44865         return ret_ref;
44866 }
44867
44868 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44869         LDKChannelUpdateInfo this_ptr_conv;
44870         this_ptr_conv.inner = untag_ptr(this_ptr);
44871         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44873         this_ptr_conv.is_owned = false;
44874         LDKChannelUpdate val_conv;
44875         val_conv.inner = untag_ptr(val);
44876         val_conv.is_owned = ptr_is_owned(val);
44877         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44878         val_conv = ChannelUpdate_clone(&val_conv);
44879         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
44880 }
44881
44882 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) {
44883         LDKRoutingFees fees_arg_conv;
44884         fees_arg_conv.inner = untag_ptr(fees_arg);
44885         fees_arg_conv.is_owned = ptr_is_owned(fees_arg);
44886         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
44887         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
44888         LDKChannelUpdate last_update_message_arg_conv;
44889         last_update_message_arg_conv.inner = untag_ptr(last_update_message_arg);
44890         last_update_message_arg_conv.is_owned = ptr_is_owned(last_update_message_arg);
44891         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
44892         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
44893         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);
44894         int64_t ret_ref = 0;
44895         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44896         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44897         return ret_ref;
44898 }
44899
44900 static inline uint64_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
44901         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
44902         int64_t ret_ref = 0;
44903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44904         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44905         return ret_ref;
44906 }
44907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44908         LDKChannelUpdateInfo arg_conv;
44909         arg_conv.inner = untag_ptr(arg);
44910         arg_conv.is_owned = ptr_is_owned(arg);
44911         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44912         arg_conv.is_owned = false;
44913         int64_t ret_conv = ChannelUpdateInfo_clone_ptr(&arg_conv);
44914         return ret_conv;
44915 }
44916
44917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44918         LDKChannelUpdateInfo orig_conv;
44919         orig_conv.inner = untag_ptr(orig);
44920         orig_conv.is_owned = ptr_is_owned(orig);
44921         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44922         orig_conv.is_owned = false;
44923         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
44924         int64_t ret_ref = 0;
44925         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44926         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44927         return ret_ref;
44928 }
44929
44930 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44931         LDKChannelUpdateInfo a_conv;
44932         a_conv.inner = untag_ptr(a);
44933         a_conv.is_owned = ptr_is_owned(a);
44934         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44935         a_conv.is_owned = false;
44936         LDKChannelUpdateInfo b_conv;
44937         b_conv.inner = untag_ptr(b);
44938         b_conv.is_owned = ptr_is_owned(b);
44939         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44940         b_conv.is_owned = false;
44941         jboolean ret_conv = ChannelUpdateInfo_eq(&a_conv, &b_conv);
44942         return ret_conv;
44943 }
44944
44945 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
44946         LDKChannelUpdateInfo obj_conv;
44947         obj_conv.inner = untag_ptr(obj);
44948         obj_conv.is_owned = ptr_is_owned(obj);
44949         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44950         obj_conv.is_owned = false;
44951         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
44952         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44953         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44954         CVec_u8Z_free(ret_var);
44955         return ret_arr;
44956 }
44957
44958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44959         LDKu8slice ser_ref;
44960         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44961         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44962         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
44963         *ret_conv = ChannelUpdateInfo_read(ser_ref);
44964         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44965         return tag_ptr(ret_conv, true);
44966 }
44967
44968 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44969         LDKChannelInfo this_obj_conv;
44970         this_obj_conv.inner = untag_ptr(this_obj);
44971         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44973         ChannelInfo_free(this_obj_conv);
44974 }
44975
44976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
44977         LDKChannelInfo this_ptr_conv;
44978         this_ptr_conv.inner = untag_ptr(this_ptr);
44979         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44981         this_ptr_conv.is_owned = false;
44982         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
44983         int64_t ret_ref = 0;
44984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44985         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44986         return ret_ref;
44987 }
44988
44989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44990         LDKChannelInfo this_ptr_conv;
44991         this_ptr_conv.inner = untag_ptr(this_ptr);
44992         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44994         this_ptr_conv.is_owned = false;
44995         LDKChannelFeatures val_conv;
44996         val_conv.inner = untag_ptr(val);
44997         val_conv.is_owned = ptr_is_owned(val);
44998         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44999         val_conv = ChannelFeatures_clone(&val_conv);
45000         ChannelInfo_set_features(&this_ptr_conv, val_conv);
45001 }
45002
45003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
45004         LDKChannelInfo this_ptr_conv;
45005         this_ptr_conv.inner = untag_ptr(this_ptr);
45006         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45008         this_ptr_conv.is_owned = false;
45009         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
45010         int64_t ret_ref = 0;
45011         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45012         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45013         return ret_ref;
45014 }
45015
45016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45017         LDKChannelInfo this_ptr_conv;
45018         this_ptr_conv.inner = untag_ptr(this_ptr);
45019         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45021         this_ptr_conv.is_owned = false;
45022         LDKNodeId val_conv;
45023         val_conv.inner = untag_ptr(val);
45024         val_conv.is_owned = ptr_is_owned(val);
45025         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45026         val_conv = NodeId_clone(&val_conv);
45027         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
45028 }
45029
45030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
45031         LDKChannelInfo this_ptr_conv;
45032         this_ptr_conv.inner = untag_ptr(this_ptr);
45033         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45035         this_ptr_conv.is_owned = false;
45036         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
45037         int64_t ret_ref = 0;
45038         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45039         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45040         return ret_ref;
45041 }
45042
45043 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45044         LDKChannelInfo this_ptr_conv;
45045         this_ptr_conv.inner = untag_ptr(this_ptr);
45046         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45048         this_ptr_conv.is_owned = false;
45049         LDKChannelUpdateInfo val_conv;
45050         val_conv.inner = untag_ptr(val);
45051         val_conv.is_owned = ptr_is_owned(val);
45052         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45053         val_conv = ChannelUpdateInfo_clone(&val_conv);
45054         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
45055 }
45056
45057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
45058         LDKChannelInfo this_ptr_conv;
45059         this_ptr_conv.inner = untag_ptr(this_ptr);
45060         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45062         this_ptr_conv.is_owned = false;
45063         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
45064         int64_t ret_ref = 0;
45065         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45066         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45067         return ret_ref;
45068 }
45069
45070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45071         LDKChannelInfo this_ptr_conv;
45072         this_ptr_conv.inner = untag_ptr(this_ptr);
45073         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45075         this_ptr_conv.is_owned = false;
45076         LDKNodeId val_conv;
45077         val_conv.inner = untag_ptr(val);
45078         val_conv.is_owned = ptr_is_owned(val);
45079         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45080         val_conv = NodeId_clone(&val_conv);
45081         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
45082 }
45083
45084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
45085         LDKChannelInfo this_ptr_conv;
45086         this_ptr_conv.inner = untag_ptr(this_ptr);
45087         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45089         this_ptr_conv.is_owned = false;
45090         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
45091         int64_t ret_ref = 0;
45092         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45093         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45094         return ret_ref;
45095 }
45096
45097 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45098         LDKChannelInfo this_ptr_conv;
45099         this_ptr_conv.inner = untag_ptr(this_ptr);
45100         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45102         this_ptr_conv.is_owned = false;
45103         LDKChannelUpdateInfo val_conv;
45104         val_conv.inner = untag_ptr(val);
45105         val_conv.is_owned = ptr_is_owned(val);
45106         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45107         val_conv = ChannelUpdateInfo_clone(&val_conv);
45108         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
45109 }
45110
45111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
45112         LDKChannelInfo this_ptr_conv;
45113         this_ptr_conv.inner = untag_ptr(this_ptr);
45114         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45116         this_ptr_conv.is_owned = false;
45117         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
45118         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
45119         int64_t ret_ref = tag_ptr(ret_copy, true);
45120         return ret_ref;
45121 }
45122
45123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45124         LDKChannelInfo this_ptr_conv;
45125         this_ptr_conv.inner = untag_ptr(this_ptr);
45126         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45128         this_ptr_conv.is_owned = false;
45129         void* val_ptr = untag_ptr(val);
45130         CHECK_ACCESS(val_ptr);
45131         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
45132         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
45133         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
45134 }
45135
45136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
45137         LDKChannelInfo this_ptr_conv;
45138         this_ptr_conv.inner = untag_ptr(this_ptr);
45139         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45141         this_ptr_conv.is_owned = false;
45142         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
45143         int64_t ret_ref = 0;
45144         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45145         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45146         return ret_ref;
45147 }
45148
45149 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45150         LDKChannelInfo this_ptr_conv;
45151         this_ptr_conv.inner = untag_ptr(this_ptr);
45152         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45154         this_ptr_conv.is_owned = false;
45155         LDKChannelAnnouncement val_conv;
45156         val_conv.inner = untag_ptr(val);
45157         val_conv.is_owned = ptr_is_owned(val);
45158         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45159         val_conv = ChannelAnnouncement_clone(&val_conv);
45160         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
45161 }
45162
45163 static inline uint64_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
45164         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
45165         int64_t ret_ref = 0;
45166         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45167         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45168         return ret_ref;
45169 }
45170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45171         LDKChannelInfo arg_conv;
45172         arg_conv.inner = untag_ptr(arg);
45173         arg_conv.is_owned = ptr_is_owned(arg);
45174         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45175         arg_conv.is_owned = false;
45176         int64_t ret_conv = ChannelInfo_clone_ptr(&arg_conv);
45177         return ret_conv;
45178 }
45179
45180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45181         LDKChannelInfo orig_conv;
45182         orig_conv.inner = untag_ptr(orig);
45183         orig_conv.is_owned = ptr_is_owned(orig);
45184         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45185         orig_conv.is_owned = false;
45186         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
45187         int64_t ret_ref = 0;
45188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45189         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45190         return ret_ref;
45191 }
45192
45193 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45194         LDKChannelInfo a_conv;
45195         a_conv.inner = untag_ptr(a);
45196         a_conv.is_owned = ptr_is_owned(a);
45197         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45198         a_conv.is_owned = false;
45199         LDKChannelInfo b_conv;
45200         b_conv.inner = untag_ptr(b);
45201         b_conv.is_owned = ptr_is_owned(b);
45202         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45203         b_conv.is_owned = false;
45204         jboolean ret_conv = ChannelInfo_eq(&a_conv, &b_conv);
45205         return ret_conv;
45206 }
45207
45208 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) {
45209         LDKChannelInfo this_arg_conv;
45210         this_arg_conv.inner = untag_ptr(this_arg);
45211         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45213         this_arg_conv.is_owned = false;
45214         LDKChannelUpdateInfo ret_var = ChannelInfo_get_directional_info(&this_arg_conv, channel_flags);
45215         int64_t ret_ref = 0;
45216         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45217         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45218         return ret_ref;
45219 }
45220
45221 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
45222         LDKChannelInfo obj_conv;
45223         obj_conv.inner = untag_ptr(obj);
45224         obj_conv.is_owned = ptr_is_owned(obj);
45225         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45226         obj_conv.is_owned = false;
45227         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
45228         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45229         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45230         CVec_u8Z_free(ret_var);
45231         return ret_arr;
45232 }
45233
45234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45235         LDKu8slice ser_ref;
45236         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45237         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45238         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
45239         *ret_conv = ChannelInfo_read(ser_ref);
45240         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45241         return tag_ptr(ret_conv, true);
45242 }
45243
45244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45245         LDKDirectedChannelInfo this_obj_conv;
45246         this_obj_conv.inner = untag_ptr(this_obj);
45247         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45249         DirectedChannelInfo_free(this_obj_conv);
45250 }
45251
45252 static inline uint64_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
45253         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
45254         int64_t ret_ref = 0;
45255         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45256         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45257         return ret_ref;
45258 }
45259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45260         LDKDirectedChannelInfo arg_conv;
45261         arg_conv.inner = untag_ptr(arg);
45262         arg_conv.is_owned = ptr_is_owned(arg);
45263         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45264         arg_conv.is_owned = false;
45265         int64_t ret_conv = DirectedChannelInfo_clone_ptr(&arg_conv);
45266         return ret_conv;
45267 }
45268
45269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45270         LDKDirectedChannelInfo orig_conv;
45271         orig_conv.inner = untag_ptr(orig);
45272         orig_conv.is_owned = ptr_is_owned(orig);
45273         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45274         orig_conv.is_owned = false;
45275         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
45276         int64_t ret_ref = 0;
45277         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45278         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45279         return ret_ref;
45280 }
45281
45282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1channel(JNIEnv *env, jclass clz, int64_t this_arg) {
45283         LDKDirectedChannelInfo this_arg_conv;
45284         this_arg_conv.inner = untag_ptr(this_arg);
45285         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45287         this_arg_conv.is_owned = false;
45288         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
45289         int64_t ret_ref = 0;
45290         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45291         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45292         return ret_ref;
45293 }
45294
45295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1direction(JNIEnv *env, jclass clz, int64_t this_arg) {
45296         LDKDirectedChannelInfo this_arg_conv;
45297         this_arg_conv.inner = untag_ptr(this_arg);
45298         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45300         this_arg_conv.is_owned = false;
45301         LDKChannelUpdateInfo ret_var = DirectedChannelInfo_direction(&this_arg_conv);
45302         int64_t ret_ref = 0;
45303         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45304         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45305         return ret_ref;
45306 }
45307
45308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
45309         LDKDirectedChannelInfo this_arg_conv;
45310         this_arg_conv.inner = untag_ptr(this_arg);
45311         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45313         this_arg_conv.is_owned = false;
45314         int64_t ret_conv = DirectedChannelInfo_htlc_maximum_msat(&this_arg_conv);
45315         return ret_conv;
45316 }
45317
45318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_arg) {
45319         LDKDirectedChannelInfo this_arg_conv;
45320         this_arg_conv.inner = untag_ptr(this_arg);
45321         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45323         this_arg_conv.is_owned = false;
45324         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
45325         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
45326         int64_t ret_ref = tag_ptr(ret_copy, true);
45327         return ret_ref;
45328 }
45329
45330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
45331         if (!ptr_is_owned(this_ptr)) return;
45332         void* this_ptr_ptr = untag_ptr(this_ptr);
45333         CHECK_ACCESS(this_ptr_ptr);
45334         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
45335         FREE(untag_ptr(this_ptr));
45336         EffectiveCapacity_free(this_ptr_conv);
45337 }
45338
45339 static inline uint64_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
45340         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
45341         *ret_copy = EffectiveCapacity_clone(arg);
45342         int64_t ret_ref = tag_ptr(ret_copy, true);
45343         return ret_ref;
45344 }
45345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45346         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)untag_ptr(arg);
45347         int64_t ret_conv = EffectiveCapacity_clone_ptr(arg_conv);
45348         return ret_conv;
45349 }
45350
45351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45352         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)untag_ptr(orig);
45353         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
45354         *ret_copy = EffectiveCapacity_clone(orig_conv);
45355         int64_t ret_ref = tag_ptr(ret_copy, true);
45356         return ret_ref;
45357 }
45358
45359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1exact_1liquidity(JNIEnv *env, jclass clz, int64_t liquidity_msat) {
45360         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
45361         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
45362         int64_t ret_ref = tag_ptr(ret_copy, true);
45363         return ret_ref;
45364 }
45365
45366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1maximum_1htlc(JNIEnv *env, jclass clz, int64_t amount_msat) {
45367         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
45368         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
45369         int64_t ret_ref = tag_ptr(ret_copy, true);
45370         return ret_ref;
45371 }
45372
45373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1total(JNIEnv *env, jclass clz, int64_t capacity_msat, int64_t htlc_maximum_msat) {
45374         void* htlc_maximum_msat_ptr = untag_ptr(htlc_maximum_msat);
45375         CHECK_ACCESS(htlc_maximum_msat_ptr);
45376         LDKCOption_u64Z htlc_maximum_msat_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_ptr);
45377         htlc_maximum_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_maximum_msat));
45378         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
45379         *ret_copy = EffectiveCapacity_total(capacity_msat, htlc_maximum_msat_conv);
45380         int64_t ret_ref = tag_ptr(ret_copy, true);
45381         return ret_ref;
45382 }
45383
45384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1infinite(JNIEnv *env, jclass clz) {
45385         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
45386         *ret_copy = EffectiveCapacity_infinite();
45387         int64_t ret_ref = tag_ptr(ret_copy, true);
45388         return ret_ref;
45389 }
45390
45391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1unknown(JNIEnv *env, jclass clz) {
45392         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
45393         *ret_copy = EffectiveCapacity_unknown();
45394         int64_t ret_ref = tag_ptr(ret_copy, true);
45395         return ret_ref;
45396 }
45397
45398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1as_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
45399         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)untag_ptr(this_arg);
45400         int64_t ret_conv = EffectiveCapacity_as_msat(this_arg_conv);
45401         return ret_conv;
45402 }
45403
45404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45405         LDKRoutingFees this_obj_conv;
45406         this_obj_conv.inner = untag_ptr(this_obj);
45407         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45409         RoutingFees_free(this_obj_conv);
45410 }
45411
45412 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
45413         LDKRoutingFees this_ptr_conv;
45414         this_ptr_conv.inner = untag_ptr(this_ptr);
45415         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45417         this_ptr_conv.is_owned = false;
45418         int32_t ret_conv = RoutingFees_get_base_msat(&this_ptr_conv);
45419         return ret_conv;
45420 }
45421
45422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
45423         LDKRoutingFees this_ptr_conv;
45424         this_ptr_conv.inner = untag_ptr(this_ptr);
45425         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45427         this_ptr_conv.is_owned = false;
45428         RoutingFees_set_base_msat(&this_ptr_conv, val);
45429 }
45430
45431 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
45432         LDKRoutingFees this_ptr_conv;
45433         this_ptr_conv.inner = untag_ptr(this_ptr);
45434         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45436         this_ptr_conv.is_owned = false;
45437         int32_t ret_conv = RoutingFees_get_proportional_millionths(&this_ptr_conv);
45438         return ret_conv;
45439 }
45440
45441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
45442         LDKRoutingFees this_ptr_conv;
45443         this_ptr_conv.inner = untag_ptr(this_ptr);
45444         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45446         this_ptr_conv.is_owned = false;
45447         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
45448 }
45449
45450 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) {
45451         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
45452         int64_t ret_ref = 0;
45453         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45454         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45455         return ret_ref;
45456 }
45457
45458 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45459         LDKRoutingFees a_conv;
45460         a_conv.inner = untag_ptr(a);
45461         a_conv.is_owned = ptr_is_owned(a);
45462         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45463         a_conv.is_owned = false;
45464         LDKRoutingFees b_conv;
45465         b_conv.inner = untag_ptr(b);
45466         b_conv.is_owned = ptr_is_owned(b);
45467         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45468         b_conv.is_owned = false;
45469         jboolean ret_conv = RoutingFees_eq(&a_conv, &b_conv);
45470         return ret_conv;
45471 }
45472
45473 static inline uint64_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
45474         LDKRoutingFees ret_var = RoutingFees_clone(arg);
45475         int64_t ret_ref = 0;
45476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45477         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45478         return ret_ref;
45479 }
45480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45481         LDKRoutingFees arg_conv;
45482         arg_conv.inner = untag_ptr(arg);
45483         arg_conv.is_owned = ptr_is_owned(arg);
45484         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45485         arg_conv.is_owned = false;
45486         int64_t ret_conv = RoutingFees_clone_ptr(&arg_conv);
45487         return ret_conv;
45488 }
45489
45490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45491         LDKRoutingFees orig_conv;
45492         orig_conv.inner = untag_ptr(orig);
45493         orig_conv.is_owned = ptr_is_owned(orig);
45494         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45495         orig_conv.is_owned = false;
45496         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
45497         int64_t ret_ref = 0;
45498         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45499         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45500         return ret_ref;
45501 }
45502
45503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) {
45504         LDKRoutingFees o_conv;
45505         o_conv.inner = untag_ptr(o);
45506         o_conv.is_owned = ptr_is_owned(o);
45507         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45508         o_conv.is_owned = false;
45509         int64_t ret_conv = RoutingFees_hash(&o_conv);
45510         return ret_conv;
45511 }
45512
45513 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
45514         LDKRoutingFees obj_conv;
45515         obj_conv.inner = untag_ptr(obj);
45516         obj_conv.is_owned = ptr_is_owned(obj);
45517         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45518         obj_conv.is_owned = false;
45519         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
45520         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45521         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45522         CVec_u8Z_free(ret_var);
45523         return ret_arr;
45524 }
45525
45526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45527         LDKu8slice ser_ref;
45528         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45529         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45530         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
45531         *ret_conv = RoutingFees_read(ser_ref);
45532         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45533         return tag_ptr(ret_conv, true);
45534 }
45535
45536 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45537         LDKNodeAnnouncementInfo this_obj_conv;
45538         this_obj_conv.inner = untag_ptr(this_obj);
45539         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45541         NodeAnnouncementInfo_free(this_obj_conv);
45542 }
45543
45544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
45545         LDKNodeAnnouncementInfo this_ptr_conv;
45546         this_ptr_conv.inner = untag_ptr(this_ptr);
45547         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45549         this_ptr_conv.is_owned = false;
45550         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
45551         int64_t ret_ref = 0;
45552         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45553         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45554         return ret_ref;
45555 }
45556
45557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45558         LDKNodeAnnouncementInfo this_ptr_conv;
45559         this_ptr_conv.inner = untag_ptr(this_ptr);
45560         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45562         this_ptr_conv.is_owned = false;
45563         LDKNodeFeatures val_conv;
45564         val_conv.inner = untag_ptr(val);
45565         val_conv.is_owned = ptr_is_owned(val);
45566         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45567         val_conv = NodeFeatures_clone(&val_conv);
45568         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
45569 }
45570
45571 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
45572         LDKNodeAnnouncementInfo this_ptr_conv;
45573         this_ptr_conv.inner = untag_ptr(this_ptr);
45574         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45576         this_ptr_conv.is_owned = false;
45577         int32_t ret_conv = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
45578         return ret_conv;
45579 }
45580
45581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
45582         LDKNodeAnnouncementInfo this_ptr_conv;
45583         this_ptr_conv.inner = untag_ptr(this_ptr);
45584         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45586         this_ptr_conv.is_owned = false;
45587         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
45588 }
45589
45590 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
45591         LDKNodeAnnouncementInfo this_ptr_conv;
45592         this_ptr_conv.inner = untag_ptr(this_ptr);
45593         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45595         this_ptr_conv.is_owned = false;
45596         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
45597         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
45598         return ret_arr;
45599 }
45600
45601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
45602         LDKNodeAnnouncementInfo this_ptr_conv;
45603         this_ptr_conv.inner = untag_ptr(this_ptr);
45604         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45606         this_ptr_conv.is_owned = false;
45607         LDKThreeBytes val_ref;
45608         CHECK((*env)->GetArrayLength(env, val) == 3);
45609         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
45610         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
45611 }
45612
45613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
45614         LDKNodeAnnouncementInfo this_ptr_conv;
45615         this_ptr_conv.inner = untag_ptr(this_ptr);
45616         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45618         this_ptr_conv.is_owned = false;
45619         LDKNodeAlias ret_var = NodeAnnouncementInfo_get_alias(&this_ptr_conv);
45620         int64_t ret_ref = 0;
45621         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45622         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45623         return ret_ref;
45624 }
45625
45626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45627         LDKNodeAnnouncementInfo this_ptr_conv;
45628         this_ptr_conv.inner = untag_ptr(this_ptr);
45629         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45631         this_ptr_conv.is_owned = false;
45632         LDKNodeAlias val_conv;
45633         val_conv.inner = untag_ptr(val);
45634         val_conv.is_owned = ptr_is_owned(val);
45635         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45636         val_conv = NodeAlias_clone(&val_conv);
45637         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_conv);
45638 }
45639
45640 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr) {
45641         LDKNodeAnnouncementInfo this_ptr_conv;
45642         this_ptr_conv.inner = untag_ptr(this_ptr);
45643         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45645         this_ptr_conv.is_owned = false;
45646         LDKCVec_NetAddressZ ret_var = NodeAnnouncementInfo_get_addresses(&this_ptr_conv);
45647         int64_tArray ret_arr = NULL;
45648         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
45649         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
45650         for (size_t m = 0; m < ret_var.datalen; m++) {
45651                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
45652                 *ret_conv_12_copy = ret_var.data[m];
45653                 int64_t ret_conv_12_ref = tag_ptr(ret_conv_12_copy, true);
45654                 ret_arr_ptr[m] = ret_conv_12_ref;
45655         }
45656         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
45657         FREE(ret_var.data);
45658         return ret_arr;
45659 }
45660
45661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
45662         LDKNodeAnnouncementInfo this_ptr_conv;
45663         this_ptr_conv.inner = untag_ptr(this_ptr);
45664         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45666         this_ptr_conv.is_owned = false;
45667         LDKCVec_NetAddressZ val_constr;
45668         val_constr.datalen = (*env)->GetArrayLength(env, val);
45669         if (val_constr.datalen > 0)
45670                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
45671         else
45672                 val_constr.data = NULL;
45673         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
45674         for (size_t m = 0; m < val_constr.datalen; m++) {
45675                 int64_t val_conv_12 = val_vals[m];
45676                 void* val_conv_12_ptr = untag_ptr(val_conv_12);
45677                 CHECK_ACCESS(val_conv_12_ptr);
45678                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
45679                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(val_conv_12));
45680                 val_constr.data[m] = val_conv_12_conv;
45681         }
45682         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
45683         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
45684 }
45685
45686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
45687         LDKNodeAnnouncementInfo this_ptr_conv;
45688         this_ptr_conv.inner = untag_ptr(this_ptr);
45689         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45691         this_ptr_conv.is_owned = false;
45692         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
45693         int64_t ret_ref = 0;
45694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45695         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45696         return ret_ref;
45697 }
45698
45699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45700         LDKNodeAnnouncementInfo this_ptr_conv;
45701         this_ptr_conv.inner = untag_ptr(this_ptr);
45702         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45704         this_ptr_conv.is_owned = false;
45705         LDKNodeAnnouncement val_conv;
45706         val_conv.inner = untag_ptr(val);
45707         val_conv.is_owned = ptr_is_owned(val);
45708         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45709         val_conv = NodeAnnouncement_clone(&val_conv);
45710         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
45711 }
45712
45713 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) {
45714         LDKNodeFeatures features_arg_conv;
45715         features_arg_conv.inner = untag_ptr(features_arg);
45716         features_arg_conv.is_owned = ptr_is_owned(features_arg);
45717         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
45718         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
45719         LDKThreeBytes rgb_arg_ref;
45720         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
45721         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
45722         LDKNodeAlias alias_arg_conv;
45723         alias_arg_conv.inner = untag_ptr(alias_arg);
45724         alias_arg_conv.is_owned = ptr_is_owned(alias_arg);
45725         CHECK_INNER_FIELD_ACCESS_OR_NULL(alias_arg_conv);
45726         alias_arg_conv = NodeAlias_clone(&alias_arg_conv);
45727         LDKCVec_NetAddressZ addresses_arg_constr;
45728         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
45729         if (addresses_arg_constr.datalen > 0)
45730                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
45731         else
45732                 addresses_arg_constr.data = NULL;
45733         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
45734         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
45735                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
45736                 void* addresses_arg_conv_12_ptr = untag_ptr(addresses_arg_conv_12);
45737                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
45738                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
45739                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
45740         }
45741         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
45742         LDKNodeAnnouncement announcement_message_arg_conv;
45743         announcement_message_arg_conv.inner = untag_ptr(announcement_message_arg);
45744         announcement_message_arg_conv.is_owned = ptr_is_owned(announcement_message_arg);
45745         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
45746         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
45747         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_conv, addresses_arg_constr, announcement_message_arg_conv);
45748         int64_t ret_ref = 0;
45749         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45750         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45751         return ret_ref;
45752 }
45753
45754 static inline uint64_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
45755         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
45756         int64_t ret_ref = 0;
45757         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45758         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45759         return ret_ref;
45760 }
45761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45762         LDKNodeAnnouncementInfo arg_conv;
45763         arg_conv.inner = untag_ptr(arg);
45764         arg_conv.is_owned = ptr_is_owned(arg);
45765         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45766         arg_conv.is_owned = false;
45767         int64_t ret_conv = NodeAnnouncementInfo_clone_ptr(&arg_conv);
45768         return ret_conv;
45769 }
45770
45771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45772         LDKNodeAnnouncementInfo orig_conv;
45773         orig_conv.inner = untag_ptr(orig);
45774         orig_conv.is_owned = ptr_is_owned(orig);
45775         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45776         orig_conv.is_owned = false;
45777         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
45778         int64_t ret_ref = 0;
45779         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45780         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45781         return ret_ref;
45782 }
45783
45784 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45785         LDKNodeAnnouncementInfo a_conv;
45786         a_conv.inner = untag_ptr(a);
45787         a_conv.is_owned = ptr_is_owned(a);
45788         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45789         a_conv.is_owned = false;
45790         LDKNodeAnnouncementInfo b_conv;
45791         b_conv.inner = untag_ptr(b);
45792         b_conv.is_owned = ptr_is_owned(b);
45793         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45794         b_conv.is_owned = false;
45795         jboolean ret_conv = NodeAnnouncementInfo_eq(&a_conv, &b_conv);
45796         return ret_conv;
45797 }
45798
45799 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
45800         LDKNodeAnnouncementInfo obj_conv;
45801         obj_conv.inner = untag_ptr(obj);
45802         obj_conv.is_owned = ptr_is_owned(obj);
45803         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45804         obj_conv.is_owned = false;
45805         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
45806         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45807         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45808         CVec_u8Z_free(ret_var);
45809         return ret_arr;
45810 }
45811
45812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45813         LDKu8slice ser_ref;
45814         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45815         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45816         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
45817         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
45818         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45819         return tag_ptr(ret_conv, true);
45820 }
45821
45822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45823         LDKNodeAlias this_obj_conv;
45824         this_obj_conv.inner = untag_ptr(this_obj);
45825         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45827         NodeAlias_free(this_obj_conv);
45828 }
45829
45830 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
45831         LDKNodeAlias this_ptr_conv;
45832         this_ptr_conv.inner = untag_ptr(this_ptr);
45833         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45835         this_ptr_conv.is_owned = false;
45836         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
45837         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAlias_get_a(&this_ptr_conv));
45838         return ret_arr;
45839 }
45840
45841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
45842         LDKNodeAlias this_ptr_conv;
45843         this_ptr_conv.inner = untag_ptr(this_ptr);
45844         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45846         this_ptr_conv.is_owned = false;
45847         LDKThirtyTwoBytes val_ref;
45848         CHECK((*env)->GetArrayLength(env, val) == 32);
45849         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
45850         NodeAlias_set_a(&this_ptr_conv, val_ref);
45851 }
45852
45853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
45854         LDKThirtyTwoBytes a_arg_ref;
45855         CHECK((*env)->GetArrayLength(env, a_arg) == 32);
45856         (*env)->GetByteArrayRegion(env, a_arg, 0, 32, a_arg_ref.data);
45857         LDKNodeAlias ret_var = NodeAlias_new(a_arg_ref);
45858         int64_t ret_ref = 0;
45859         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45860         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45861         return ret_ref;
45862 }
45863
45864 static inline uint64_t NodeAlias_clone_ptr(LDKNodeAlias *NONNULL_PTR arg) {
45865         LDKNodeAlias ret_var = NodeAlias_clone(arg);
45866         int64_t ret_ref = 0;
45867         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45868         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45869         return ret_ref;
45870 }
45871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45872         LDKNodeAlias arg_conv;
45873         arg_conv.inner = untag_ptr(arg);
45874         arg_conv.is_owned = ptr_is_owned(arg);
45875         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45876         arg_conv.is_owned = false;
45877         int64_t ret_conv = NodeAlias_clone_ptr(&arg_conv);
45878         return ret_conv;
45879 }
45880
45881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45882         LDKNodeAlias orig_conv;
45883         orig_conv.inner = untag_ptr(orig);
45884         orig_conv.is_owned = ptr_is_owned(orig);
45885         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45886         orig_conv.is_owned = false;
45887         LDKNodeAlias ret_var = NodeAlias_clone(&orig_conv);
45888         int64_t ret_ref = 0;
45889         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45890         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45891         return ret_ref;
45892 }
45893
45894 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeAlias_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45895         LDKNodeAlias a_conv;
45896         a_conv.inner = untag_ptr(a);
45897         a_conv.is_owned = ptr_is_owned(a);
45898         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45899         a_conv.is_owned = false;
45900         LDKNodeAlias b_conv;
45901         b_conv.inner = untag_ptr(b);
45902         b_conv.is_owned = ptr_is_owned(b);
45903         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45904         b_conv.is_owned = false;
45905         jboolean ret_conv = NodeAlias_eq(&a_conv, &b_conv);
45906         return ret_conv;
45907 }
45908
45909 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1write(JNIEnv *env, jclass clz, int64_t obj) {
45910         LDKNodeAlias obj_conv;
45911         obj_conv.inner = untag_ptr(obj);
45912         obj_conv.is_owned = ptr_is_owned(obj);
45913         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45914         obj_conv.is_owned = false;
45915         LDKCVec_u8Z ret_var = NodeAlias_write(&obj_conv);
45916         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45917         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45918         CVec_u8Z_free(ret_var);
45919         return ret_arr;
45920 }
45921
45922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45923         LDKu8slice ser_ref;
45924         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45925         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45926         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
45927         *ret_conv = NodeAlias_read(ser_ref);
45928         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45929         return tag_ptr(ret_conv, true);
45930 }
45931
45932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45933         LDKNodeInfo this_obj_conv;
45934         this_obj_conv.inner = untag_ptr(this_obj);
45935         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45937         NodeInfo_free(this_obj_conv);
45938 }
45939
45940 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
45941         LDKNodeInfo this_ptr_conv;
45942         this_ptr_conv.inner = untag_ptr(this_ptr);
45943         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45945         this_ptr_conv.is_owned = false;
45946         LDKCVec_u64Z ret_var = NodeInfo_get_channels(&this_ptr_conv);
45947         int64_tArray ret_arr = NULL;
45948         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
45949         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
45950         for (size_t g = 0; g < ret_var.datalen; g++) {
45951                 int64_t ret_conv_6_conv = ret_var.data[g];
45952                 ret_arr_ptr[g] = ret_conv_6_conv;
45953         }
45954         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
45955         FREE(ret_var.data);
45956         return ret_arr;
45957 }
45958
45959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
45960         LDKNodeInfo this_ptr_conv;
45961         this_ptr_conv.inner = untag_ptr(this_ptr);
45962         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45964         this_ptr_conv.is_owned = false;
45965         LDKCVec_u64Z val_constr;
45966         val_constr.datalen = (*env)->GetArrayLength(env, val);
45967         if (val_constr.datalen > 0)
45968                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
45969         else
45970                 val_constr.data = NULL;
45971         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
45972         for (size_t g = 0; g < val_constr.datalen; g++) {
45973                 int64_t val_conv_6 = val_vals[g];
45974                 val_constr.data[g] = val_conv_6;
45975         }
45976         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
45977         NodeInfo_set_channels(&this_ptr_conv, val_constr);
45978 }
45979
45980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
45981         LDKNodeInfo this_ptr_conv;
45982         this_ptr_conv.inner = untag_ptr(this_ptr);
45983         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45985         this_ptr_conv.is_owned = false;
45986         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
45987         int64_t ret_ref = 0;
45988         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45989         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45990         return ret_ref;
45991 }
45992
45993 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) {
45994         LDKNodeInfo this_ptr_conv;
45995         this_ptr_conv.inner = untag_ptr(this_ptr);
45996         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45998         this_ptr_conv.is_owned = false;
45999         LDKRoutingFees val_conv;
46000         val_conv.inner = untag_ptr(val);
46001         val_conv.is_owned = ptr_is_owned(val);
46002         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46003         val_conv = RoutingFees_clone(&val_conv);
46004         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
46005 }
46006
46007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
46008         LDKNodeInfo this_ptr_conv;
46009         this_ptr_conv.inner = untag_ptr(this_ptr);
46010         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46012         this_ptr_conv.is_owned = false;
46013         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
46014         int64_t ret_ref = 0;
46015         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46016         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46017         return ret_ref;
46018 }
46019
46020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46021         LDKNodeInfo this_ptr_conv;
46022         this_ptr_conv.inner = untag_ptr(this_ptr);
46023         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46025         this_ptr_conv.is_owned = false;
46026         LDKNodeAnnouncementInfo val_conv;
46027         val_conv.inner = untag_ptr(val);
46028         val_conv.is_owned = ptr_is_owned(val);
46029         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46030         val_conv = NodeAnnouncementInfo_clone(&val_conv);
46031         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
46032 }
46033
46034 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) {
46035         LDKCVec_u64Z channels_arg_constr;
46036         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
46037         if (channels_arg_constr.datalen > 0)
46038                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
46039         else
46040                 channels_arg_constr.data = NULL;
46041         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
46042         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
46043                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
46044                 channels_arg_constr.data[g] = channels_arg_conv_6;
46045         }
46046         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
46047         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
46048         lowest_inbound_channel_fees_arg_conv.inner = untag_ptr(lowest_inbound_channel_fees_arg);
46049         lowest_inbound_channel_fees_arg_conv.is_owned = ptr_is_owned(lowest_inbound_channel_fees_arg);
46050         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
46051         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
46052         LDKNodeAnnouncementInfo announcement_info_arg_conv;
46053         announcement_info_arg_conv.inner = untag_ptr(announcement_info_arg);
46054         announcement_info_arg_conv.is_owned = ptr_is_owned(announcement_info_arg);
46055         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
46056         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
46057         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
46058         int64_t ret_ref = 0;
46059         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46060         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46061         return ret_ref;
46062 }
46063
46064 static inline uint64_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
46065         LDKNodeInfo ret_var = NodeInfo_clone(arg);
46066         int64_t ret_ref = 0;
46067         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46068         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46069         return ret_ref;
46070 }
46071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46072         LDKNodeInfo arg_conv;
46073         arg_conv.inner = untag_ptr(arg);
46074         arg_conv.is_owned = ptr_is_owned(arg);
46075         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46076         arg_conv.is_owned = false;
46077         int64_t ret_conv = NodeInfo_clone_ptr(&arg_conv);
46078         return ret_conv;
46079 }
46080
46081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46082         LDKNodeInfo orig_conv;
46083         orig_conv.inner = untag_ptr(orig);
46084         orig_conv.is_owned = ptr_is_owned(orig);
46085         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46086         orig_conv.is_owned = false;
46087         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
46088         int64_t ret_ref = 0;
46089         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46090         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46091         return ret_ref;
46092 }
46093
46094 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46095         LDKNodeInfo a_conv;
46096         a_conv.inner = untag_ptr(a);
46097         a_conv.is_owned = ptr_is_owned(a);
46098         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46099         a_conv.is_owned = false;
46100         LDKNodeInfo b_conv;
46101         b_conv.inner = untag_ptr(b);
46102         b_conv.is_owned = ptr_is_owned(b);
46103         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46104         b_conv.is_owned = false;
46105         jboolean ret_conv = NodeInfo_eq(&a_conv, &b_conv);
46106         return ret_conv;
46107 }
46108
46109 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
46110         LDKNodeInfo obj_conv;
46111         obj_conv.inner = untag_ptr(obj);
46112         obj_conv.is_owned = ptr_is_owned(obj);
46113         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46114         obj_conv.is_owned = false;
46115         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
46116         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46117         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46118         CVec_u8Z_free(ret_var);
46119         return ret_arr;
46120 }
46121
46122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
46123         LDKu8slice ser_ref;
46124         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46125         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46126         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
46127         *ret_conv = NodeInfo_read(ser_ref);
46128         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46129         return tag_ptr(ret_conv, true);
46130 }
46131
46132 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
46133         LDKNetworkGraph obj_conv;
46134         obj_conv.inner = untag_ptr(obj);
46135         obj_conv.is_owned = ptr_is_owned(obj);
46136         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46137         obj_conv.is_owned = false;
46138         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
46139         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46140         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46141         CVec_u8Z_free(ret_var);
46142         return ret_arr;
46143 }
46144
46145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
46146         LDKu8slice ser_ref;
46147         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46148         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46149         void* arg_ptr = untag_ptr(arg);
46150         CHECK_ACCESS(arg_ptr);
46151         LDKLogger arg_conv = *(LDKLogger*)(arg_ptr);
46152         if (arg_conv.free == LDKLogger_JCalls_free) {
46153                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46154                 LDKLogger_JCalls_cloned(&arg_conv);
46155         }
46156         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
46157         *ret_conv = NetworkGraph_read(ser_ref, arg_conv);
46158         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46159         return tag_ptr(ret_conv, true);
46160 }
46161
46162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash, int64_t logger) {
46163         LDKThirtyTwoBytes genesis_hash_ref;
46164         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
46165         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
46166         void* logger_ptr = untag_ptr(logger);
46167         CHECK_ACCESS(logger_ptr);
46168         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
46169         if (logger_conv.free == LDKLogger_JCalls_free) {
46170                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46171                 LDKLogger_JCalls_cloned(&logger_conv);
46172         }
46173         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref, logger_conv);
46174         int64_t ret_ref = 0;
46175         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46176         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46177         return ret_ref;
46178 }
46179
46180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) {
46181         LDKNetworkGraph this_arg_conv;
46182         this_arg_conv.inner = untag_ptr(this_arg);
46183         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46185         this_arg_conv.is_owned = false;
46186         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
46187         int64_t ret_ref = 0;
46188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46189         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46190         return ret_ref;
46191 }
46192
46193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1get_1last_1rapid_1gossip_1sync_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
46194         LDKNetworkGraph this_arg_conv;
46195         this_arg_conv.inner = untag_ptr(this_arg);
46196         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46198         this_arg_conv.is_owned = false;
46199         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
46200         *ret_copy = NetworkGraph_get_last_rapid_gossip_sync_timestamp(&this_arg_conv);
46201         int64_t ret_ref = tag_ptr(ret_copy, true);
46202         return ret_ref;
46203 }
46204
46205 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) {
46206         LDKNetworkGraph this_arg_conv;
46207         this_arg_conv.inner = untag_ptr(this_arg);
46208         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46210         this_arg_conv.is_owned = false;
46211         NetworkGraph_set_last_rapid_gossip_sync_timestamp(&this_arg_conv, last_rapid_gossip_sync_timestamp);
46212 }
46213
46214 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) {
46215         LDKNetworkGraph this_arg_conv;
46216         this_arg_conv.inner = untag_ptr(this_arg);
46217         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46219         this_arg_conv.is_owned = false;
46220         LDKNodeAnnouncement msg_conv;
46221         msg_conv.inner = untag_ptr(msg);
46222         msg_conv.is_owned = ptr_is_owned(msg);
46223         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
46224         msg_conv.is_owned = false;
46225         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
46226         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
46227         return tag_ptr(ret_conv, true);
46228 }
46229
46230 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) {
46231         LDKNetworkGraph this_arg_conv;
46232         this_arg_conv.inner = untag_ptr(this_arg);
46233         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46235         this_arg_conv.is_owned = false;
46236         LDKUnsignedNodeAnnouncement msg_conv;
46237         msg_conv.inner = untag_ptr(msg);
46238         msg_conv.is_owned = ptr_is_owned(msg);
46239         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
46240         msg_conv.is_owned = false;
46241         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
46242         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
46243         return tag_ptr(ret_conv, true);
46244 }
46245
46246 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) {
46247         LDKNetworkGraph this_arg_conv;
46248         this_arg_conv.inner = untag_ptr(this_arg);
46249         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46251         this_arg_conv.is_owned = false;
46252         LDKChannelAnnouncement msg_conv;
46253         msg_conv.inner = untag_ptr(msg);
46254         msg_conv.is_owned = ptr_is_owned(msg);
46255         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
46256         msg_conv.is_owned = false;
46257         void* chain_access_ptr = untag_ptr(chain_access);
46258         CHECK_ACCESS(chain_access_ptr);
46259         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
46260         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
46261         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
46262                 // Manually implement clone for Java trait instances
46263                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
46264                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46265                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
46266                 }
46267         }
46268         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
46269         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
46270         return tag_ptr(ret_conv, true);
46271 }
46272
46273 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) {
46274         LDKNetworkGraph this_arg_conv;
46275         this_arg_conv.inner = untag_ptr(this_arg);
46276         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46278         this_arg_conv.is_owned = false;
46279         LDKUnsignedChannelAnnouncement msg_conv;
46280         msg_conv.inner = untag_ptr(msg);
46281         msg_conv.is_owned = ptr_is_owned(msg);
46282         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
46283         msg_conv.is_owned = false;
46284         void* chain_access_ptr = untag_ptr(chain_access);
46285         CHECK_ACCESS(chain_access_ptr);
46286         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
46287         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
46288         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
46289                 // Manually implement clone for Java trait instances
46290                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
46291                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46292                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
46293                 }
46294         }
46295         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
46296         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
46297         return tag_ptr(ret_conv, true);
46298 }
46299
46300 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) {
46301         LDKNetworkGraph this_arg_conv;
46302         this_arg_conv.inner = untag_ptr(this_arg);
46303         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46305         this_arg_conv.is_owned = false;
46306         LDKChannelFeatures features_conv;
46307         features_conv.inner = untag_ptr(features);
46308         features_conv.is_owned = ptr_is_owned(features);
46309         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
46310         features_conv = ChannelFeatures_clone(&features_conv);
46311         LDKPublicKey node_id_1_ref;
46312         CHECK((*env)->GetArrayLength(env, node_id_1) == 33);
46313         (*env)->GetByteArrayRegion(env, node_id_1, 0, 33, node_id_1_ref.compressed_form);
46314         LDKPublicKey node_id_2_ref;
46315         CHECK((*env)->GetArrayLength(env, node_id_2) == 33);
46316         (*env)->GetByteArrayRegion(env, node_id_2, 0, 33, node_id_2_ref.compressed_form);
46317         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
46318         *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);
46319         return tag_ptr(ret_conv, true);
46320 }
46321
46322 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) {
46323         LDKNetworkGraph this_arg_conv;
46324         this_arg_conv.inner = untag_ptr(this_arg);
46325         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46327         this_arg_conv.is_owned = false;
46328         NetworkGraph_channel_failed(&this_arg_conv, short_channel_id, is_permanent);
46329 }
46330
46331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1node_1failed_1permanent(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray node_id) {
46332         LDKNetworkGraph this_arg_conv;
46333         this_arg_conv.inner = untag_ptr(this_arg);
46334         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46336         this_arg_conv.is_owned = false;
46337         LDKPublicKey node_id_ref;
46338         CHECK((*env)->GetArrayLength(env, node_id) == 33);
46339         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
46340         NetworkGraph_node_failed_permanent(&this_arg_conv, node_id_ref);
46341 }
46342
46343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1remove_1stale_1channels_1and_1tracking(JNIEnv *env, jclass clz, int64_t this_arg) {
46344         LDKNetworkGraph this_arg_conv;
46345         this_arg_conv.inner = untag_ptr(this_arg);
46346         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46348         this_arg_conv.is_owned = false;
46349         NetworkGraph_remove_stale_channels_and_tracking(&this_arg_conv);
46350 }
46351
46352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1remove_1stale_1channels_1and_1tracking_1with_1time(JNIEnv *env, jclass clz, int64_t this_arg, int64_t current_time_unix) {
46353         LDKNetworkGraph this_arg_conv;
46354         this_arg_conv.inner = untag_ptr(this_arg);
46355         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46357         this_arg_conv.is_owned = false;
46358         NetworkGraph_remove_stale_channels_and_tracking_with_time(&this_arg_conv, current_time_unix);
46359 }
46360
46361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
46362         LDKNetworkGraph this_arg_conv;
46363         this_arg_conv.inner = untag_ptr(this_arg);
46364         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46366         this_arg_conv.is_owned = false;
46367         LDKChannelUpdate msg_conv;
46368         msg_conv.inner = untag_ptr(msg);
46369         msg_conv.is_owned = ptr_is_owned(msg);
46370         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
46371         msg_conv.is_owned = false;
46372         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
46373         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
46374         return tag_ptr(ret_conv, true);
46375 }
46376
46377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
46378         LDKNetworkGraph this_arg_conv;
46379         this_arg_conv.inner = untag_ptr(this_arg);
46380         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46382         this_arg_conv.is_owned = false;
46383         LDKUnsignedChannelUpdate msg_conv;
46384         msg_conv.inner = untag_ptr(msg);
46385         msg_conv.is_owned = ptr_is_owned(msg);
46386         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
46387         msg_conv.is_owned = false;
46388         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
46389         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
46390         return tag_ptr(ret_conv, true);
46391 }
46392
46393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id) {
46394         LDKReadOnlyNetworkGraph this_arg_conv;
46395         this_arg_conv.inner = untag_ptr(this_arg);
46396         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46398         this_arg_conv.is_owned = false;
46399         LDKChannelInfo ret_var = ReadOnlyNetworkGraph_channel(&this_arg_conv, short_channel_id);
46400         int64_t ret_ref = 0;
46401         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46402         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46403         return ret_ref;
46404 }
46405
46406 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
46407         LDKReadOnlyNetworkGraph this_arg_conv;
46408         this_arg_conv.inner = untag_ptr(this_arg);
46409         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46411         this_arg_conv.is_owned = false;
46412         LDKCVec_u64Z ret_var = ReadOnlyNetworkGraph_list_channels(&this_arg_conv);
46413         int64_tArray ret_arr = NULL;
46414         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
46415         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
46416         for (size_t g = 0; g < ret_var.datalen; g++) {
46417                 int64_t ret_conv_6_conv = ret_var.data[g];
46418                 ret_arr_ptr[g] = ret_conv_6_conv;
46419         }
46420         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
46421         FREE(ret_var.data);
46422         return ret_arr;
46423 }
46424
46425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1node(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
46426         LDKReadOnlyNetworkGraph this_arg_conv;
46427         this_arg_conv.inner = untag_ptr(this_arg);
46428         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46430         this_arg_conv.is_owned = false;
46431         LDKNodeId node_id_conv;
46432         node_id_conv.inner = untag_ptr(node_id);
46433         node_id_conv.is_owned = ptr_is_owned(node_id);
46434         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
46435         node_id_conv.is_owned = false;
46436         LDKNodeInfo ret_var = ReadOnlyNetworkGraph_node(&this_arg_conv, &node_id_conv);
46437         int64_t ret_ref = 0;
46438         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46439         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46440         return ret_ref;
46441 }
46442
46443 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1list_1nodes(JNIEnv *env, jclass clz, int64_t this_arg) {
46444         LDKReadOnlyNetworkGraph this_arg_conv;
46445         this_arg_conv.inner = untag_ptr(this_arg);
46446         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46448         this_arg_conv.is_owned = false;
46449         LDKCVec_NodeIdZ ret_var = ReadOnlyNetworkGraph_list_nodes(&this_arg_conv);
46450         int64_tArray ret_arr = NULL;
46451         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
46452         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
46453         for (size_t i = 0; i < ret_var.datalen; i++) {
46454                 LDKNodeId ret_conv_8_var = ret_var.data[i];
46455                 int64_t ret_conv_8_ref = 0;
46456                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_8_var);
46457                 ret_conv_8_ref = tag_ptr(ret_conv_8_var.inner, ret_conv_8_var.is_owned);
46458                 ret_arr_ptr[i] = ret_conv_8_ref;
46459         }
46460         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
46461         FREE(ret_var.data);
46462         return ret_arr;
46463 }
46464
46465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey) {
46466         LDKReadOnlyNetworkGraph this_arg_conv;
46467         this_arg_conv.inner = untag_ptr(this_arg);
46468         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46470         this_arg_conv.is_owned = false;
46471         LDKPublicKey pubkey_ref;
46472         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
46473         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
46474         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
46475         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
46476         int64_t ret_ref = tag_ptr(ret_copy, true);
46477         return ret_ref;
46478 }
46479
46480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46481         LDKRouteHop this_obj_conv;
46482         this_obj_conv.inner = untag_ptr(this_obj);
46483         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46485         RouteHop_free(this_obj_conv);
46486 }
46487
46488 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
46489         LDKRouteHop this_ptr_conv;
46490         this_ptr_conv.inner = untag_ptr(this_ptr);
46491         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46493         this_ptr_conv.is_owned = false;
46494         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
46495         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
46496         return ret_arr;
46497 }
46498
46499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
46500         LDKRouteHop this_ptr_conv;
46501         this_ptr_conv.inner = untag_ptr(this_ptr);
46502         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46504         this_ptr_conv.is_owned = false;
46505         LDKPublicKey val_ref;
46506         CHECK((*env)->GetArrayLength(env, val) == 33);
46507         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
46508         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
46509 }
46510
46511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
46512         LDKRouteHop this_ptr_conv;
46513         this_ptr_conv.inner = untag_ptr(this_ptr);
46514         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46516         this_ptr_conv.is_owned = false;
46517         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
46518         int64_t ret_ref = 0;
46519         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46520         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46521         return ret_ref;
46522 }
46523
46524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46525         LDKRouteHop this_ptr_conv;
46526         this_ptr_conv.inner = untag_ptr(this_ptr);
46527         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46529         this_ptr_conv.is_owned = false;
46530         LDKNodeFeatures val_conv;
46531         val_conv.inner = untag_ptr(val);
46532         val_conv.is_owned = ptr_is_owned(val);
46533         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46534         val_conv = NodeFeatures_clone(&val_conv);
46535         RouteHop_set_node_features(&this_ptr_conv, val_conv);
46536 }
46537
46538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
46539         LDKRouteHop this_ptr_conv;
46540         this_ptr_conv.inner = untag_ptr(this_ptr);
46541         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46543         this_ptr_conv.is_owned = false;
46544         int64_t ret_conv = RouteHop_get_short_channel_id(&this_ptr_conv);
46545         return ret_conv;
46546 }
46547
46548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46549         LDKRouteHop this_ptr_conv;
46550         this_ptr_conv.inner = untag_ptr(this_ptr);
46551         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46553         this_ptr_conv.is_owned = false;
46554         RouteHop_set_short_channel_id(&this_ptr_conv, val);
46555 }
46556
46557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
46558         LDKRouteHop this_ptr_conv;
46559         this_ptr_conv.inner = untag_ptr(this_ptr);
46560         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46562         this_ptr_conv.is_owned = false;
46563         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
46564         int64_t ret_ref = 0;
46565         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46566         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46567         return ret_ref;
46568 }
46569
46570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46571         LDKRouteHop this_ptr_conv;
46572         this_ptr_conv.inner = untag_ptr(this_ptr);
46573         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46575         this_ptr_conv.is_owned = false;
46576         LDKChannelFeatures val_conv;
46577         val_conv.inner = untag_ptr(val);
46578         val_conv.is_owned = ptr_is_owned(val);
46579         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46580         val_conv = ChannelFeatures_clone(&val_conv);
46581         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
46582 }
46583
46584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46585         LDKRouteHop this_ptr_conv;
46586         this_ptr_conv.inner = untag_ptr(this_ptr);
46587         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46589         this_ptr_conv.is_owned = false;
46590         int64_t ret_conv = RouteHop_get_fee_msat(&this_ptr_conv);
46591         return ret_conv;
46592 }
46593
46594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46595         LDKRouteHop this_ptr_conv;
46596         this_ptr_conv.inner = untag_ptr(this_ptr);
46597         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46599         this_ptr_conv.is_owned = false;
46600         RouteHop_set_fee_msat(&this_ptr_conv, val);
46601 }
46602
46603 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
46604         LDKRouteHop this_ptr_conv;
46605         this_ptr_conv.inner = untag_ptr(this_ptr);
46606         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46608         this_ptr_conv.is_owned = false;
46609         int32_t ret_conv = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
46610         return ret_conv;
46611 }
46612
46613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
46614         LDKRouteHop this_ptr_conv;
46615         this_ptr_conv.inner = untag_ptr(this_ptr);
46616         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46618         this_ptr_conv.is_owned = false;
46619         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
46620 }
46621
46622 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) {
46623         LDKPublicKey pubkey_arg_ref;
46624         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
46625         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
46626         LDKNodeFeatures node_features_arg_conv;
46627         node_features_arg_conv.inner = untag_ptr(node_features_arg);
46628         node_features_arg_conv.is_owned = ptr_is_owned(node_features_arg);
46629         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
46630         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
46631         LDKChannelFeatures channel_features_arg_conv;
46632         channel_features_arg_conv.inner = untag_ptr(channel_features_arg);
46633         channel_features_arg_conv.is_owned = ptr_is_owned(channel_features_arg);
46634         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
46635         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
46636         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);
46637         int64_t ret_ref = 0;
46638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46639         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46640         return ret_ref;
46641 }
46642
46643 static inline uint64_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
46644         LDKRouteHop ret_var = RouteHop_clone(arg);
46645         int64_t ret_ref = 0;
46646         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46647         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46648         return ret_ref;
46649 }
46650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46651         LDKRouteHop arg_conv;
46652         arg_conv.inner = untag_ptr(arg);
46653         arg_conv.is_owned = ptr_is_owned(arg);
46654         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46655         arg_conv.is_owned = false;
46656         int64_t ret_conv = RouteHop_clone_ptr(&arg_conv);
46657         return ret_conv;
46658 }
46659
46660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46661         LDKRouteHop orig_conv;
46662         orig_conv.inner = untag_ptr(orig);
46663         orig_conv.is_owned = ptr_is_owned(orig);
46664         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46665         orig_conv.is_owned = false;
46666         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
46667         int64_t ret_ref = 0;
46668         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46669         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46670         return ret_ref;
46671 }
46672
46673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
46674         LDKRouteHop o_conv;
46675         o_conv.inner = untag_ptr(o);
46676         o_conv.is_owned = ptr_is_owned(o);
46677         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46678         o_conv.is_owned = false;
46679         int64_t ret_conv = RouteHop_hash(&o_conv);
46680         return ret_conv;
46681 }
46682
46683 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46684         LDKRouteHop a_conv;
46685         a_conv.inner = untag_ptr(a);
46686         a_conv.is_owned = ptr_is_owned(a);
46687         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46688         a_conv.is_owned = false;
46689         LDKRouteHop b_conv;
46690         b_conv.inner = untag_ptr(b);
46691         b_conv.is_owned = ptr_is_owned(b);
46692         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46693         b_conv.is_owned = false;
46694         jboolean ret_conv = RouteHop_eq(&a_conv, &b_conv);
46695         return ret_conv;
46696 }
46697
46698 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
46699         LDKRouteHop obj_conv;
46700         obj_conv.inner = untag_ptr(obj);
46701         obj_conv.is_owned = ptr_is_owned(obj);
46702         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46703         obj_conv.is_owned = false;
46704         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
46705         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46706         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46707         CVec_u8Z_free(ret_var);
46708         return ret_arr;
46709 }
46710
46711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
46712         LDKu8slice ser_ref;
46713         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46714         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46715         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
46716         *ret_conv = RouteHop_read(ser_ref);
46717         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46718         return tag_ptr(ret_conv, true);
46719 }
46720
46721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46722         LDKRoute this_obj_conv;
46723         this_obj_conv.inner = untag_ptr(this_obj);
46724         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46726         Route_free(this_obj_conv);
46727 }
46728
46729 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) {
46730         LDKRoute this_ptr_conv;
46731         this_ptr_conv.inner = untag_ptr(this_ptr);
46732         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46734         this_ptr_conv.is_owned = false;
46735         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
46736         jobjectArray ret_arr = NULL;
46737         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_J_clz, NULL);
46738         ;
46739         for (size_t m = 0; m < ret_var.datalen; m++) {
46740                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
46741                 int64_tArray ret_conv_12_arr = NULL;
46742                 ret_conv_12_arr = (*env)->NewLongArray(env, ret_conv_12_var.datalen);
46743                 int64_t *ret_conv_12_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_conv_12_arr, NULL);
46744                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
46745                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
46746                         int64_t ret_conv_12_conv_10_ref = 0;
46747                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
46748                         ret_conv_12_conv_10_ref = tag_ptr(ret_conv_12_conv_10_var.inner, ret_conv_12_conv_10_var.is_owned);
46749                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
46750                 }
46751                 (*env)->ReleasePrimitiveArrayCritical(env, ret_conv_12_arr, ret_conv_12_arr_ptr, 0);
46752                 FREE(ret_conv_12_var.data);
46753                 (*env)->SetObjectArrayElement(env, ret_arr, m, ret_conv_12_arr);
46754         }
46755         
46756         FREE(ret_var.data);
46757         return ret_arr;
46758 }
46759
46760 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
46761         LDKRoute this_ptr_conv;
46762         this_ptr_conv.inner = untag_ptr(this_ptr);
46763         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46765         this_ptr_conv.is_owned = false;
46766         LDKCVec_CVec_RouteHopZZ val_constr;
46767         val_constr.datalen = (*env)->GetArrayLength(env, val);
46768         if (val_constr.datalen > 0)
46769                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
46770         else
46771                 val_constr.data = NULL;
46772         for (size_t m = 0; m < val_constr.datalen; m++) {
46773                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
46774                 LDKCVec_RouteHopZ val_conv_12_constr;
46775                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
46776                 if (val_conv_12_constr.datalen > 0)
46777                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
46778                 else
46779                         val_conv_12_constr.data = NULL;
46780                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
46781                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
46782                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
46783                         LDKRouteHop val_conv_12_conv_10_conv;
46784                         val_conv_12_conv_10_conv.inner = untag_ptr(val_conv_12_conv_10);
46785                         val_conv_12_conv_10_conv.is_owned = ptr_is_owned(val_conv_12_conv_10);
46786                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
46787                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
46788                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
46789                 }
46790                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
46791                 val_constr.data[m] = val_conv_12_constr;
46792         }
46793         Route_set_paths(&this_ptr_conv, val_constr);
46794 }
46795
46796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
46797         LDKRoute this_ptr_conv;
46798         this_ptr_conv.inner = untag_ptr(this_ptr);
46799         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46801         this_ptr_conv.is_owned = false;
46802         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
46803         int64_t ret_ref = 0;
46804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46805         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46806         return ret_ref;
46807 }
46808
46809 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46810         LDKRoute this_ptr_conv;
46811         this_ptr_conv.inner = untag_ptr(this_ptr);
46812         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46814         this_ptr_conv.is_owned = false;
46815         LDKPaymentParameters val_conv;
46816         val_conv.inner = untag_ptr(val);
46817         val_conv.is_owned = ptr_is_owned(val);
46818         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46819         val_conv = PaymentParameters_clone(&val_conv);
46820         Route_set_payment_params(&this_ptr_conv, val_conv);
46821 }
46822
46823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg, int64_t payment_params_arg) {
46824         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
46825         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
46826         if (paths_arg_constr.datalen > 0)
46827                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
46828         else
46829                 paths_arg_constr.data = NULL;
46830         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
46831                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
46832                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
46833                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
46834                 if (paths_arg_conv_12_constr.datalen > 0)
46835                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
46836                 else
46837                         paths_arg_conv_12_constr.data = NULL;
46838                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
46839                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
46840                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
46841                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
46842                         paths_arg_conv_12_conv_10_conv.inner = untag_ptr(paths_arg_conv_12_conv_10);
46843                         paths_arg_conv_12_conv_10_conv.is_owned = ptr_is_owned(paths_arg_conv_12_conv_10);
46844                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
46845                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
46846                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
46847                 }
46848                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
46849                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
46850         }
46851         LDKPaymentParameters payment_params_arg_conv;
46852         payment_params_arg_conv.inner = untag_ptr(payment_params_arg);
46853         payment_params_arg_conv.is_owned = ptr_is_owned(payment_params_arg);
46854         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
46855         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
46856         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
46857         int64_t ret_ref = 0;
46858         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46859         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46860         return ret_ref;
46861 }
46862
46863 static inline uint64_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
46864         LDKRoute ret_var = Route_clone(arg);
46865         int64_t ret_ref = 0;
46866         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46867         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46868         return ret_ref;
46869 }
46870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46871         LDKRoute arg_conv;
46872         arg_conv.inner = untag_ptr(arg);
46873         arg_conv.is_owned = ptr_is_owned(arg);
46874         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46875         arg_conv.is_owned = false;
46876         int64_t ret_conv = Route_clone_ptr(&arg_conv);
46877         return ret_conv;
46878 }
46879
46880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46881         LDKRoute orig_conv;
46882         orig_conv.inner = untag_ptr(orig);
46883         orig_conv.is_owned = ptr_is_owned(orig);
46884         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46885         orig_conv.is_owned = false;
46886         LDKRoute ret_var = Route_clone(&orig_conv);
46887         int64_t ret_ref = 0;
46888         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46889         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46890         return ret_ref;
46891 }
46892
46893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) {
46894         LDKRoute o_conv;
46895         o_conv.inner = untag_ptr(o);
46896         o_conv.is_owned = ptr_is_owned(o);
46897         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46898         o_conv.is_owned = false;
46899         int64_t ret_conv = Route_hash(&o_conv);
46900         return ret_conv;
46901 }
46902
46903 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46904         LDKRoute a_conv;
46905         a_conv.inner = untag_ptr(a);
46906         a_conv.is_owned = ptr_is_owned(a);
46907         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46908         a_conv.is_owned = false;
46909         LDKRoute b_conv;
46910         b_conv.inner = untag_ptr(b);
46911         b_conv.is_owned = ptr_is_owned(b);
46912         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46913         b_conv.is_owned = false;
46914         jboolean ret_conv = Route_eq(&a_conv, &b_conv);
46915         return ret_conv;
46916 }
46917
46918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) {
46919         LDKRoute this_arg_conv;
46920         this_arg_conv.inner = untag_ptr(this_arg);
46921         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46923         this_arg_conv.is_owned = false;
46924         int64_t ret_conv = Route_get_total_fees(&this_arg_conv);
46925         return ret_conv;
46926 }
46927
46928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
46929         LDKRoute this_arg_conv;
46930         this_arg_conv.inner = untag_ptr(this_arg);
46931         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46933         this_arg_conv.is_owned = false;
46934         int64_t ret_conv = Route_get_total_amount(&this_arg_conv);
46935         return ret_conv;
46936 }
46937
46938 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
46939         LDKRoute obj_conv;
46940         obj_conv.inner = untag_ptr(obj);
46941         obj_conv.is_owned = ptr_is_owned(obj);
46942         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46943         obj_conv.is_owned = false;
46944         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
46945         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46946         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46947         CVec_u8Z_free(ret_var);
46948         return ret_arr;
46949 }
46950
46951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
46952         LDKu8slice ser_ref;
46953         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46954         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46955         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
46956         *ret_conv = Route_read(ser_ref);
46957         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46958         return tag_ptr(ret_conv, true);
46959 }
46960
46961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46962         LDKRouteParameters this_obj_conv;
46963         this_obj_conv.inner = untag_ptr(this_obj);
46964         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46966         RouteParameters_free(this_obj_conv);
46967 }
46968
46969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
46970         LDKRouteParameters this_ptr_conv;
46971         this_ptr_conv.inner = untag_ptr(this_ptr);
46972         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46974         this_ptr_conv.is_owned = false;
46975         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
46976         int64_t ret_ref = 0;
46977         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46978         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46979         return ret_ref;
46980 }
46981
46982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46983         LDKRouteParameters this_ptr_conv;
46984         this_ptr_conv.inner = untag_ptr(this_ptr);
46985         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46987         this_ptr_conv.is_owned = false;
46988         LDKPaymentParameters val_conv;
46989         val_conv.inner = untag_ptr(val);
46990         val_conv.is_owned = ptr_is_owned(val);
46991         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46992         val_conv = PaymentParameters_clone(&val_conv);
46993         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
46994 }
46995
46996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46997         LDKRouteParameters this_ptr_conv;
46998         this_ptr_conv.inner = untag_ptr(this_ptr);
46999         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47001         this_ptr_conv.is_owned = false;
47002         int64_t ret_conv = RouteParameters_get_final_value_msat(&this_ptr_conv);
47003         return ret_conv;
47004 }
47005
47006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47007         LDKRouteParameters this_ptr_conv;
47008         this_ptr_conv.inner = untag_ptr(this_ptr);
47009         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47011         this_ptr_conv.is_owned = false;
47012         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
47013 }
47014
47015 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
47016         LDKRouteParameters this_ptr_conv;
47017         this_ptr_conv.inner = untag_ptr(this_ptr);
47018         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47020         this_ptr_conv.is_owned = false;
47021         int32_t ret_conv = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
47022         return ret_conv;
47023 }
47024
47025 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) {
47026         LDKRouteParameters this_ptr_conv;
47027         this_ptr_conv.inner = untag_ptr(this_ptr);
47028         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47030         this_ptr_conv.is_owned = false;
47031         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
47032 }
47033
47034 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) {
47035         LDKPaymentParameters payment_params_arg_conv;
47036         payment_params_arg_conv.inner = untag_ptr(payment_params_arg);
47037         payment_params_arg_conv.is_owned = ptr_is_owned(payment_params_arg);
47038         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
47039         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
47040         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
47041         int64_t ret_ref = 0;
47042         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47043         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47044         return ret_ref;
47045 }
47046
47047 static inline uint64_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
47048         LDKRouteParameters ret_var = RouteParameters_clone(arg);
47049         int64_t ret_ref = 0;
47050         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47051         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47052         return ret_ref;
47053 }
47054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47055         LDKRouteParameters arg_conv;
47056         arg_conv.inner = untag_ptr(arg);
47057         arg_conv.is_owned = ptr_is_owned(arg);
47058         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47059         arg_conv.is_owned = false;
47060         int64_t ret_conv = RouteParameters_clone_ptr(&arg_conv);
47061         return ret_conv;
47062 }
47063
47064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47065         LDKRouteParameters orig_conv;
47066         orig_conv.inner = untag_ptr(orig);
47067         orig_conv.is_owned = ptr_is_owned(orig);
47068         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47069         orig_conv.is_owned = false;
47070         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
47071         int64_t ret_ref = 0;
47072         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47073         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47074         return ret_ref;
47075 }
47076
47077 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
47078         LDKRouteParameters obj_conv;
47079         obj_conv.inner = untag_ptr(obj);
47080         obj_conv.is_owned = ptr_is_owned(obj);
47081         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47082         obj_conv.is_owned = false;
47083         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
47084         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47085         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47086         CVec_u8Z_free(ret_var);
47087         return ret_arr;
47088 }
47089
47090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
47091         LDKu8slice ser_ref;
47092         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47093         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47094         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
47095         *ret_conv = RouteParameters_read(ser_ref);
47096         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47097         return tag_ptr(ret_conv, true);
47098 }
47099
47100 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47101         LDKPaymentParameters this_obj_conv;
47102         this_obj_conv.inner = untag_ptr(this_obj);
47103         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47105         PaymentParameters_free(this_obj_conv);
47106 }
47107
47108 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
47109         LDKPaymentParameters this_ptr_conv;
47110         this_ptr_conv.inner = untag_ptr(this_ptr);
47111         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47113         this_ptr_conv.is_owned = false;
47114         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
47115         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form);
47116         return ret_arr;
47117 }
47118
47119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
47120         LDKPaymentParameters this_ptr_conv;
47121         this_ptr_conv.inner = untag_ptr(this_ptr);
47122         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47124         this_ptr_conv.is_owned = false;
47125         LDKPublicKey val_ref;
47126         CHECK((*env)->GetArrayLength(env, val) == 33);
47127         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
47128         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
47129 }
47130
47131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
47132         LDKPaymentParameters this_ptr_conv;
47133         this_ptr_conv.inner = untag_ptr(this_ptr);
47134         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47136         this_ptr_conv.is_owned = false;
47137         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
47138         int64_t ret_ref = 0;
47139         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47140         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47141         return ret_ref;
47142 }
47143
47144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47145         LDKPaymentParameters this_ptr_conv;
47146         this_ptr_conv.inner = untag_ptr(this_ptr);
47147         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47149         this_ptr_conv.is_owned = false;
47150         LDKInvoiceFeatures val_conv;
47151         val_conv.inner = untag_ptr(val);
47152         val_conv.is_owned = ptr_is_owned(val);
47153         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
47154         val_conv = InvoiceFeatures_clone(&val_conv);
47155         PaymentParameters_set_features(&this_ptr_conv, val_conv);
47156 }
47157
47158 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr) {
47159         LDKPaymentParameters this_ptr_conv;
47160         this_ptr_conv.inner = untag_ptr(this_ptr);
47161         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47163         this_ptr_conv.is_owned = false;
47164         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
47165         int64_tArray ret_arr = NULL;
47166         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
47167         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
47168         for (size_t l = 0; l < ret_var.datalen; l++) {
47169                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
47170                 int64_t ret_conv_11_ref = 0;
47171                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
47172                 ret_conv_11_ref = tag_ptr(ret_conv_11_var.inner, ret_conv_11_var.is_owned);
47173                 ret_arr_ptr[l] = ret_conv_11_ref;
47174         }
47175         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
47176         FREE(ret_var.data);
47177         return ret_arr;
47178 }
47179
47180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
47181         LDKPaymentParameters this_ptr_conv;
47182         this_ptr_conv.inner = untag_ptr(this_ptr);
47183         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47185         this_ptr_conv.is_owned = false;
47186         LDKCVec_RouteHintZ val_constr;
47187         val_constr.datalen = (*env)->GetArrayLength(env, val);
47188         if (val_constr.datalen > 0)
47189                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
47190         else
47191                 val_constr.data = NULL;
47192         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
47193         for (size_t l = 0; l < val_constr.datalen; l++) {
47194                 int64_t val_conv_11 = val_vals[l];
47195                 LDKRouteHint val_conv_11_conv;
47196                 val_conv_11_conv.inner = untag_ptr(val_conv_11);
47197                 val_conv_11_conv.is_owned = ptr_is_owned(val_conv_11);
47198                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
47199                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
47200                 val_constr.data[l] = val_conv_11_conv;
47201         }
47202         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
47203         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
47204 }
47205
47206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr) {
47207         LDKPaymentParameters this_ptr_conv;
47208         this_ptr_conv.inner = untag_ptr(this_ptr);
47209         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47211         this_ptr_conv.is_owned = false;
47212         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
47213         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
47214         int64_t ret_ref = tag_ptr(ret_copy, true);
47215         return ret_ref;
47216 }
47217
47218 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47219         LDKPaymentParameters this_ptr_conv;
47220         this_ptr_conv.inner = untag_ptr(this_ptr);
47221         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47223         this_ptr_conv.is_owned = false;
47224         void* val_ptr = untag_ptr(val);
47225         CHECK_ACCESS(val_ptr);
47226         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
47227         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
47228         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
47229 }
47230
47231 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1total_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
47232         LDKPaymentParameters this_ptr_conv;
47233         this_ptr_conv.inner = untag_ptr(this_ptr);
47234         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47236         this_ptr_conv.is_owned = false;
47237         int32_t ret_conv = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
47238         return ret_conv;
47239 }
47240
47241 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) {
47242         LDKPaymentParameters this_ptr_conv;
47243         this_ptr_conv.inner = untag_ptr(this_ptr);
47244         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47246         this_ptr_conv.is_owned = false;
47247         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
47248 }
47249
47250 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr) {
47251         LDKPaymentParameters this_ptr_conv;
47252         this_ptr_conv.inner = untag_ptr(this_ptr);
47253         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47255         this_ptr_conv.is_owned = false;
47256         int8_t ret_conv = PaymentParameters_get_max_path_count(&this_ptr_conv);
47257         return ret_conv;
47258 }
47259
47260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1max_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
47261         LDKPaymentParameters this_ptr_conv;
47262         this_ptr_conv.inner = untag_ptr(this_ptr);
47263         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47265         this_ptr_conv.is_owned = false;
47266         PaymentParameters_set_max_path_count(&this_ptr_conv, val);
47267 }
47268
47269 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) {
47270         LDKPaymentParameters this_ptr_conv;
47271         this_ptr_conv.inner = untag_ptr(this_ptr);
47272         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47274         this_ptr_conv.is_owned = false;
47275         int8_t ret_conv = PaymentParameters_get_max_channel_saturation_power_of_half(&this_ptr_conv);
47276         return ret_conv;
47277 }
47278
47279 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) {
47280         LDKPaymentParameters this_ptr_conv;
47281         this_ptr_conv.inner = untag_ptr(this_ptr);
47282         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47284         this_ptr_conv.is_owned = false;
47285         PaymentParameters_set_max_channel_saturation_power_of_half(&this_ptr_conv, val);
47286 }
47287
47288 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1previously_1failed_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
47289         LDKPaymentParameters this_ptr_conv;
47290         this_ptr_conv.inner = untag_ptr(this_ptr);
47291         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47293         this_ptr_conv.is_owned = false;
47294         LDKCVec_u64Z ret_var = PaymentParameters_get_previously_failed_channels(&this_ptr_conv);
47295         int64_tArray ret_arr = NULL;
47296         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
47297         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
47298         for (size_t g = 0; g < ret_var.datalen; g++) {
47299                 int64_t ret_conv_6_conv = ret_var.data[g];
47300                 ret_arr_ptr[g] = ret_conv_6_conv;
47301         }
47302         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
47303         FREE(ret_var.data);
47304         return ret_arr;
47305 }
47306
47307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1previously_1failed_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
47308         LDKPaymentParameters this_ptr_conv;
47309         this_ptr_conv.inner = untag_ptr(this_ptr);
47310         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47312         this_ptr_conv.is_owned = false;
47313         LDKCVec_u64Z val_constr;
47314         val_constr.datalen = (*env)->GetArrayLength(env, val);
47315         if (val_constr.datalen > 0)
47316                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
47317         else
47318                 val_constr.data = NULL;
47319         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
47320         for (size_t g = 0; g < val_constr.datalen; g++) {
47321                 int64_t val_conv_6 = val_vals[g];
47322                 val_constr.data[g] = val_conv_6;
47323         }
47324         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
47325         PaymentParameters_set_previously_failed_channels(&this_ptr_conv, val_constr);
47326 }
47327
47328 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) {
47329         LDKPublicKey payee_pubkey_arg_ref;
47330         CHECK((*env)->GetArrayLength(env, payee_pubkey_arg) == 33);
47331         (*env)->GetByteArrayRegion(env, payee_pubkey_arg, 0, 33, payee_pubkey_arg_ref.compressed_form);
47332         LDKInvoiceFeatures features_arg_conv;
47333         features_arg_conv.inner = untag_ptr(features_arg);
47334         features_arg_conv.is_owned = ptr_is_owned(features_arg);
47335         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
47336         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
47337         LDKCVec_RouteHintZ route_hints_arg_constr;
47338         route_hints_arg_constr.datalen = (*env)->GetArrayLength(env, route_hints_arg);
47339         if (route_hints_arg_constr.datalen > 0)
47340                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
47341         else
47342                 route_hints_arg_constr.data = NULL;
47343         int64_t* route_hints_arg_vals = (*env)->GetLongArrayElements (env, route_hints_arg, NULL);
47344         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
47345                 int64_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
47346                 LDKRouteHint route_hints_arg_conv_11_conv;
47347                 route_hints_arg_conv_11_conv.inner = untag_ptr(route_hints_arg_conv_11);
47348                 route_hints_arg_conv_11_conv.is_owned = ptr_is_owned(route_hints_arg_conv_11);
47349                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
47350                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
47351                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
47352         }
47353         (*env)->ReleaseLongArrayElements(env, route_hints_arg, route_hints_arg_vals, 0);
47354         void* expiry_time_arg_ptr = untag_ptr(expiry_time_arg);
47355         CHECK_ACCESS(expiry_time_arg_ptr);
47356         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
47357         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(expiry_time_arg));
47358         LDKCVec_u64Z previously_failed_channels_arg_constr;
47359         previously_failed_channels_arg_constr.datalen = (*env)->GetArrayLength(env, previously_failed_channels_arg);
47360         if (previously_failed_channels_arg_constr.datalen > 0)
47361                 previously_failed_channels_arg_constr.data = MALLOC(previously_failed_channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
47362         else
47363                 previously_failed_channels_arg_constr.data = NULL;
47364         int64_t* previously_failed_channels_arg_vals = (*env)->GetLongArrayElements (env, previously_failed_channels_arg, NULL);
47365         for (size_t g = 0; g < previously_failed_channels_arg_constr.datalen; g++) {
47366                 int64_t previously_failed_channels_arg_conv_6 = previously_failed_channels_arg_vals[g];
47367                 previously_failed_channels_arg_constr.data[g] = previously_failed_channels_arg_conv_6;
47368         }
47369         (*env)->ReleaseLongArrayElements(env, previously_failed_channels_arg, previously_failed_channels_arg_vals, 0);
47370         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);
47371         int64_t ret_ref = 0;
47372         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47373         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47374         return ret_ref;
47375 }
47376
47377 static inline uint64_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
47378         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
47379         int64_t ret_ref = 0;
47380         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47381         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47382         return ret_ref;
47383 }
47384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47385         LDKPaymentParameters arg_conv;
47386         arg_conv.inner = untag_ptr(arg);
47387         arg_conv.is_owned = ptr_is_owned(arg);
47388         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47389         arg_conv.is_owned = false;
47390         int64_t ret_conv = PaymentParameters_clone_ptr(&arg_conv);
47391         return ret_conv;
47392 }
47393
47394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47395         LDKPaymentParameters orig_conv;
47396         orig_conv.inner = untag_ptr(orig);
47397         orig_conv.is_owned = ptr_is_owned(orig);
47398         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47399         orig_conv.is_owned = false;
47400         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
47401         int64_t ret_ref = 0;
47402         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47403         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47404         return ret_ref;
47405 }
47406
47407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1hash(JNIEnv *env, jclass clz, int64_t o) {
47408         LDKPaymentParameters o_conv;
47409         o_conv.inner = untag_ptr(o);
47410         o_conv.is_owned = ptr_is_owned(o);
47411         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
47412         o_conv.is_owned = false;
47413         int64_t ret_conv = PaymentParameters_hash(&o_conv);
47414         return ret_conv;
47415 }
47416
47417 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47418         LDKPaymentParameters a_conv;
47419         a_conv.inner = untag_ptr(a);
47420         a_conv.is_owned = ptr_is_owned(a);
47421         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47422         a_conv.is_owned = false;
47423         LDKPaymentParameters b_conv;
47424         b_conv.inner = untag_ptr(b);
47425         b_conv.is_owned = ptr_is_owned(b);
47426         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47427         b_conv.is_owned = false;
47428         jboolean ret_conv = PaymentParameters_eq(&a_conv, &b_conv);
47429         return ret_conv;
47430 }
47431
47432 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
47433         LDKPaymentParameters obj_conv;
47434         obj_conv.inner = untag_ptr(obj);
47435         obj_conv.is_owned = ptr_is_owned(obj);
47436         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47437         obj_conv.is_owned = false;
47438         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
47439         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47440         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47441         CVec_u8Z_free(ret_var);
47442         return ret_arr;
47443 }
47444
47445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
47446         LDKu8slice ser_ref;
47447         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47448         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47449         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
47450         *ret_conv = PaymentParameters_read(ser_ref);
47451         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47452         return tag_ptr(ret_conv, true);
47453 }
47454
47455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1from_1node_1id(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
47456         LDKPublicKey payee_pubkey_ref;
47457         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
47458         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
47459         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
47460         int64_t ret_ref = 0;
47461         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47462         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47463         return ret_ref;
47464 }
47465
47466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1for_1keysend(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
47467         LDKPublicKey payee_pubkey_ref;
47468         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
47469         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
47470         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
47471         int64_t ret_ref = 0;
47472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47473         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47474         return ret_ref;
47475 }
47476
47477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47478         LDKRouteHint this_obj_conv;
47479         this_obj_conv.inner = untag_ptr(this_obj);
47480         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47482         RouteHint_free(this_obj_conv);
47483 }
47484
47485 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
47486         LDKRouteHint this_ptr_conv;
47487         this_ptr_conv.inner = untag_ptr(this_ptr);
47488         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47490         this_ptr_conv.is_owned = false;
47491         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
47492         int64_tArray ret_arr = NULL;
47493         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
47494         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
47495         for (size_t o = 0; o < ret_var.datalen; o++) {
47496                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
47497                 int64_t ret_conv_14_ref = 0;
47498                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
47499                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
47500                 ret_arr_ptr[o] = ret_conv_14_ref;
47501         }
47502         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
47503         FREE(ret_var.data);
47504         return ret_arr;
47505 }
47506
47507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
47508         LDKRouteHint this_ptr_conv;
47509         this_ptr_conv.inner = untag_ptr(this_ptr);
47510         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47512         this_ptr_conv.is_owned = false;
47513         LDKCVec_RouteHintHopZ val_constr;
47514         val_constr.datalen = (*env)->GetArrayLength(env, val);
47515         if (val_constr.datalen > 0)
47516                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
47517         else
47518                 val_constr.data = NULL;
47519         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
47520         for (size_t o = 0; o < val_constr.datalen; o++) {
47521                 int64_t val_conv_14 = val_vals[o];
47522                 LDKRouteHintHop val_conv_14_conv;
47523                 val_conv_14_conv.inner = untag_ptr(val_conv_14);
47524                 val_conv_14_conv.is_owned = ptr_is_owned(val_conv_14);
47525                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
47526                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
47527                 val_constr.data[o] = val_conv_14_conv;
47528         }
47529         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
47530         RouteHint_set_a(&this_ptr_conv, val_constr);
47531 }
47532
47533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv *env, jclass clz, int64_tArray a_arg) {
47534         LDKCVec_RouteHintHopZ a_arg_constr;
47535         a_arg_constr.datalen = (*env)->GetArrayLength(env, a_arg);
47536         if (a_arg_constr.datalen > 0)
47537                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
47538         else
47539                 a_arg_constr.data = NULL;
47540         int64_t* a_arg_vals = (*env)->GetLongArrayElements (env, a_arg, NULL);
47541         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
47542                 int64_t a_arg_conv_14 = a_arg_vals[o];
47543                 LDKRouteHintHop a_arg_conv_14_conv;
47544                 a_arg_conv_14_conv.inner = untag_ptr(a_arg_conv_14);
47545                 a_arg_conv_14_conv.is_owned = ptr_is_owned(a_arg_conv_14);
47546                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
47547                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
47548                 a_arg_constr.data[o] = a_arg_conv_14_conv;
47549         }
47550         (*env)->ReleaseLongArrayElements(env, a_arg, a_arg_vals, 0);
47551         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
47552         int64_t ret_ref = 0;
47553         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47554         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47555         return ret_ref;
47556 }
47557
47558 static inline uint64_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
47559         LDKRouteHint ret_var = RouteHint_clone(arg);
47560         int64_t ret_ref = 0;
47561         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47562         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47563         return ret_ref;
47564 }
47565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47566         LDKRouteHint arg_conv;
47567         arg_conv.inner = untag_ptr(arg);
47568         arg_conv.is_owned = ptr_is_owned(arg);
47569         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47570         arg_conv.is_owned = false;
47571         int64_t ret_conv = RouteHint_clone_ptr(&arg_conv);
47572         return ret_conv;
47573 }
47574
47575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47576         LDKRouteHint orig_conv;
47577         orig_conv.inner = untag_ptr(orig);
47578         orig_conv.is_owned = ptr_is_owned(orig);
47579         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47580         orig_conv.is_owned = false;
47581         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
47582         int64_t ret_ref = 0;
47583         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47584         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47585         return ret_ref;
47586 }
47587
47588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) {
47589         LDKRouteHint o_conv;
47590         o_conv.inner = untag_ptr(o);
47591         o_conv.is_owned = ptr_is_owned(o);
47592         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
47593         o_conv.is_owned = false;
47594         int64_t ret_conv = RouteHint_hash(&o_conv);
47595         return ret_conv;
47596 }
47597
47598 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47599         LDKRouteHint a_conv;
47600         a_conv.inner = untag_ptr(a);
47601         a_conv.is_owned = ptr_is_owned(a);
47602         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47603         a_conv.is_owned = false;
47604         LDKRouteHint b_conv;
47605         b_conv.inner = untag_ptr(b);
47606         b_conv.is_owned = ptr_is_owned(b);
47607         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47608         b_conv.is_owned = false;
47609         jboolean ret_conv = RouteHint_eq(&a_conv, &b_conv);
47610         return ret_conv;
47611 }
47612
47613 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1write(JNIEnv *env, jclass clz, int64_t obj) {
47614         LDKRouteHint obj_conv;
47615         obj_conv.inner = untag_ptr(obj);
47616         obj_conv.is_owned = ptr_is_owned(obj);
47617         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47618         obj_conv.is_owned = false;
47619         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
47620         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47621         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47622         CVec_u8Z_free(ret_var);
47623         return ret_arr;
47624 }
47625
47626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
47627         LDKu8slice ser_ref;
47628         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47629         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47630         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
47631         *ret_conv = RouteHint_read(ser_ref);
47632         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47633         return tag_ptr(ret_conv, true);
47634 }
47635
47636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47637         LDKRouteHintHop this_obj_conv;
47638         this_obj_conv.inner = untag_ptr(this_obj);
47639         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47641         RouteHintHop_free(this_obj_conv);
47642 }
47643
47644 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
47645         LDKRouteHintHop this_ptr_conv;
47646         this_ptr_conv.inner = untag_ptr(this_ptr);
47647         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47649         this_ptr_conv.is_owned = false;
47650         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
47651         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
47652         return ret_arr;
47653 }
47654
47655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
47656         LDKRouteHintHop this_ptr_conv;
47657         this_ptr_conv.inner = untag_ptr(this_ptr);
47658         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47660         this_ptr_conv.is_owned = false;
47661         LDKPublicKey val_ref;
47662         CHECK((*env)->GetArrayLength(env, val) == 33);
47663         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
47664         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
47665 }
47666
47667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
47668         LDKRouteHintHop this_ptr_conv;
47669         this_ptr_conv.inner = untag_ptr(this_ptr);
47670         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47672         this_ptr_conv.is_owned = false;
47673         int64_t ret_conv = RouteHintHop_get_short_channel_id(&this_ptr_conv);
47674         return ret_conv;
47675 }
47676
47677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47678         LDKRouteHintHop this_ptr_conv;
47679         this_ptr_conv.inner = untag_ptr(this_ptr);
47680         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47682         this_ptr_conv.is_owned = false;
47683         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
47684 }
47685
47686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
47687         LDKRouteHintHop this_ptr_conv;
47688         this_ptr_conv.inner = untag_ptr(this_ptr);
47689         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47691         this_ptr_conv.is_owned = false;
47692         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
47693         int64_t ret_ref = 0;
47694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47695         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47696         return ret_ref;
47697 }
47698
47699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47700         LDKRouteHintHop this_ptr_conv;
47701         this_ptr_conv.inner = untag_ptr(this_ptr);
47702         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47704         this_ptr_conv.is_owned = false;
47705         LDKRoutingFees val_conv;
47706         val_conv.inner = untag_ptr(val);
47707         val_conv.is_owned = ptr_is_owned(val);
47708         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
47709         val_conv = RoutingFees_clone(&val_conv);
47710         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
47711 }
47712
47713 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
47714         LDKRouteHintHop this_ptr_conv;
47715         this_ptr_conv.inner = untag_ptr(this_ptr);
47716         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47718         this_ptr_conv.is_owned = false;
47719         int16_t ret_conv = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
47720         return ret_conv;
47721 }
47722
47723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
47724         LDKRouteHintHop this_ptr_conv;
47725         this_ptr_conv.inner = untag_ptr(this_ptr);
47726         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47728         this_ptr_conv.is_owned = false;
47729         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
47730 }
47731
47732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
47733         LDKRouteHintHop this_ptr_conv;
47734         this_ptr_conv.inner = untag_ptr(this_ptr);
47735         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47737         this_ptr_conv.is_owned = false;
47738         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
47739         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
47740         int64_t ret_ref = tag_ptr(ret_copy, true);
47741         return ret_ref;
47742 }
47743
47744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47745         LDKRouteHintHop this_ptr_conv;
47746         this_ptr_conv.inner = untag_ptr(this_ptr);
47747         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47749         this_ptr_conv.is_owned = false;
47750         void* val_ptr = untag_ptr(val);
47751         CHECK_ACCESS(val_ptr);
47752         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
47753         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
47754         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
47755 }
47756
47757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
47758         LDKRouteHintHop this_ptr_conv;
47759         this_ptr_conv.inner = untag_ptr(this_ptr);
47760         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47762         this_ptr_conv.is_owned = false;
47763         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
47764         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
47765         int64_t ret_ref = tag_ptr(ret_copy, true);
47766         return ret_ref;
47767 }
47768
47769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47770         LDKRouteHintHop this_ptr_conv;
47771         this_ptr_conv.inner = untag_ptr(this_ptr);
47772         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47774         this_ptr_conv.is_owned = false;
47775         void* val_ptr = untag_ptr(val);
47776         CHECK_ACCESS(val_ptr);
47777         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
47778         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
47779         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
47780 }
47781
47782 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) {
47783         LDKPublicKey src_node_id_arg_ref;
47784         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
47785         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
47786         LDKRoutingFees fees_arg_conv;
47787         fees_arg_conv.inner = untag_ptr(fees_arg);
47788         fees_arg_conv.is_owned = ptr_is_owned(fees_arg);
47789         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
47790         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
47791         void* htlc_minimum_msat_arg_ptr = untag_ptr(htlc_minimum_msat_arg);
47792         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
47793         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
47794         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_minimum_msat_arg));
47795         void* htlc_maximum_msat_arg_ptr = untag_ptr(htlc_maximum_msat_arg);
47796         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
47797         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
47798         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_maximum_msat_arg));
47799         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);
47800         int64_t ret_ref = 0;
47801         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47802         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47803         return ret_ref;
47804 }
47805
47806 static inline uint64_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
47807         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
47808         int64_t ret_ref = 0;
47809         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47810         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47811         return ret_ref;
47812 }
47813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47814         LDKRouteHintHop arg_conv;
47815         arg_conv.inner = untag_ptr(arg);
47816         arg_conv.is_owned = ptr_is_owned(arg);
47817         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47818         arg_conv.is_owned = false;
47819         int64_t ret_conv = RouteHintHop_clone_ptr(&arg_conv);
47820         return ret_conv;
47821 }
47822
47823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47824         LDKRouteHintHop orig_conv;
47825         orig_conv.inner = untag_ptr(orig);
47826         orig_conv.is_owned = ptr_is_owned(orig);
47827         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47828         orig_conv.is_owned = false;
47829         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
47830         int64_t ret_ref = 0;
47831         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47832         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47833         return ret_ref;
47834 }
47835
47836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
47837         LDKRouteHintHop o_conv;
47838         o_conv.inner = untag_ptr(o);
47839         o_conv.is_owned = ptr_is_owned(o);
47840         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
47841         o_conv.is_owned = false;
47842         int64_t ret_conv = RouteHintHop_hash(&o_conv);
47843         return ret_conv;
47844 }
47845
47846 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47847         LDKRouteHintHop a_conv;
47848         a_conv.inner = untag_ptr(a);
47849         a_conv.is_owned = ptr_is_owned(a);
47850         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47851         a_conv.is_owned = false;
47852         LDKRouteHintHop b_conv;
47853         b_conv.inner = untag_ptr(b);
47854         b_conv.is_owned = ptr_is_owned(b);
47855         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47856         b_conv.is_owned = false;
47857         jboolean ret_conv = RouteHintHop_eq(&a_conv, &b_conv);
47858         return ret_conv;
47859 }
47860
47861 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
47862         LDKRouteHintHop obj_conv;
47863         obj_conv.inner = untag_ptr(obj);
47864         obj_conv.is_owned = ptr_is_owned(obj);
47865         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47866         obj_conv.is_owned = false;
47867         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
47868         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47869         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47870         CVec_u8Z_free(ret_var);
47871         return ret_arr;
47872 }
47873
47874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
47875         LDKu8slice ser_ref;
47876         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47877         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47878         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
47879         *ret_conv = RouteHintHop_read(ser_ref);
47880         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47881         return tag_ptr(ret_conv, true);
47882 }
47883
47884 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) {
47885         LDKPublicKey our_node_pubkey_ref;
47886         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
47887         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
47888         LDKRouteParameters route_params_conv;
47889         route_params_conv.inner = untag_ptr(route_params);
47890         route_params_conv.is_owned = ptr_is_owned(route_params);
47891         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
47892         route_params_conv.is_owned = false;
47893         LDKNetworkGraph network_graph_conv;
47894         network_graph_conv.inner = untag_ptr(network_graph);
47895         network_graph_conv.is_owned = ptr_is_owned(network_graph);
47896         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
47897         network_graph_conv.is_owned = false;
47898         LDKCVec_ChannelDetailsZ first_hops_constr;
47899         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
47900         if (first_hops != NULL) {
47901                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
47902                 if (first_hops_constr.datalen > 0)
47903                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
47904                 else
47905                         first_hops_constr.data = NULL;
47906                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
47907                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
47908                         int64_t first_hops_conv_16 = first_hops_vals[q];
47909                         LDKChannelDetails first_hops_conv_16_conv;
47910                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
47911                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
47912                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
47913                         first_hops_conv_16_conv.is_owned = false;
47914                         first_hops_constr.data[q] = first_hops_conv_16_conv;
47915                 }
47916                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
47917                 first_hops_ptr = &first_hops_constr;
47918         }
47919         void* logger_ptr = untag_ptr(logger);
47920         CHECK_ACCESS(logger_ptr);
47921         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
47922         if (logger_conv.free == LDKLogger_JCalls_free) {
47923                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47924                 LDKLogger_JCalls_cloned(&logger_conv);
47925         }
47926         void* scorer_ptr = untag_ptr(scorer);
47927         if (ptr_is_owned(scorer)) { CHECK_ACCESS(scorer_ptr); }
47928         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
47929         unsigned char random_seed_bytes_arr[32];
47930         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
47931         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
47932         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
47933         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
47934         *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);
47935         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
47936         return tag_ptr(ret_conv, true);
47937 }
47938
47939 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) {
47940         LDKPublicKey our_node_pubkey_ref;
47941         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
47942         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
47943         LDKCVec_PublicKeyZ hops_constr;
47944         hops_constr.datalen = (*env)->GetArrayLength(env, hops);
47945         if (hops_constr.datalen > 0)
47946                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
47947         else
47948                 hops_constr.data = NULL;
47949         for (size_t i = 0; i < hops_constr.datalen; i++) {
47950                 int8_tArray hops_conv_8 = (*env)->GetObjectArrayElement(env, hops, i);
47951                 LDKPublicKey hops_conv_8_ref;
47952                 CHECK((*env)->GetArrayLength(env, hops_conv_8) == 33);
47953                 (*env)->GetByteArrayRegion(env, hops_conv_8, 0, 33, hops_conv_8_ref.compressed_form);
47954                 hops_constr.data[i] = hops_conv_8_ref;
47955         }
47956         LDKRouteParameters route_params_conv;
47957         route_params_conv.inner = untag_ptr(route_params);
47958         route_params_conv.is_owned = ptr_is_owned(route_params);
47959         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
47960         route_params_conv.is_owned = false;
47961         LDKNetworkGraph network_graph_conv;
47962         network_graph_conv.inner = untag_ptr(network_graph);
47963         network_graph_conv.is_owned = ptr_is_owned(network_graph);
47964         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
47965         network_graph_conv.is_owned = false;
47966         void* logger_ptr = untag_ptr(logger);
47967         CHECK_ACCESS(logger_ptr);
47968         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
47969         if (logger_conv.free == LDKLogger_JCalls_free) {
47970                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47971                 LDKLogger_JCalls_cloned(&logger_conv);
47972         }
47973         unsigned char random_seed_bytes_arr[32];
47974         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
47975         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
47976         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
47977         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
47978         *ret_conv = build_route_from_hops(our_node_pubkey_ref, hops_constr, &route_params_conv, &network_graph_conv, logger_conv, random_seed_bytes_ref);
47979         return tag_ptr(ret_conv, true);
47980 }
47981
47982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47983         if (!ptr_is_owned(this_ptr)) return;
47984         void* this_ptr_ptr = untag_ptr(this_ptr);
47985         CHECK_ACCESS(this_ptr_ptr);
47986         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
47987         FREE(untag_ptr(this_ptr));
47988         Score_free(this_ptr_conv);
47989 }
47990
47991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47992         if (!ptr_is_owned(this_ptr)) return;
47993         void* this_ptr_ptr = untag_ptr(this_ptr);
47994         CHECK_ACCESS(this_ptr_ptr);
47995         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
47996         FREE(untag_ptr(this_ptr));
47997         LockableScore_free(this_ptr_conv);
47998 }
47999
48000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WriteableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48001         if (!ptr_is_owned(this_ptr)) return;
48002         void* this_ptr_ptr = untag_ptr(this_ptr);
48003         CHECK_ACCESS(this_ptr_ptr);
48004         LDKWriteableScore this_ptr_conv = *(LDKWriteableScore*)(this_ptr_ptr);
48005         FREE(untag_ptr(this_ptr));
48006         WriteableScore_free(this_ptr_conv);
48007 }
48008
48009 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48010         LDKMultiThreadedLockableScore this_obj_conv;
48011         this_obj_conv.inner = untag_ptr(this_obj);
48012         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48014         MultiThreadedLockableScore_free(this_obj_conv);
48015 }
48016
48017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedScoreLock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48018         LDKMultiThreadedScoreLock this_obj_conv;
48019         this_obj_conv.inner = untag_ptr(this_obj);
48020         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48022         MultiThreadedScoreLock_free(this_obj_conv);
48023 }
48024
48025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedScoreLock_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
48026         LDKMultiThreadedScoreLock this_arg_conv;
48027         this_arg_conv.inner = untag_ptr(this_arg);
48028         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48030         this_arg_conv.is_owned = false;
48031         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
48032         *ret_ret = MultiThreadedScoreLock_as_Score(&this_arg_conv);
48033         return tag_ptr(ret_ret, true);
48034 }
48035
48036 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MultiThreadedScoreLock_1write(JNIEnv *env, jclass clz, int64_t obj) {
48037         LDKMultiThreadedScoreLock obj_conv;
48038         obj_conv.inner = untag_ptr(obj);
48039         obj_conv.is_owned = ptr_is_owned(obj);
48040         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48041         obj_conv.is_owned = false;
48042         LDKCVec_u8Z ret_var = MultiThreadedScoreLock_write(&obj_conv);
48043         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48044         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48045         CVec_u8Z_free(ret_var);
48046         return ret_arr;
48047 }
48048
48049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1as_1LockableScore(JNIEnv *env, jclass clz, int64_t this_arg) {
48050         LDKMultiThreadedLockableScore this_arg_conv;
48051         this_arg_conv.inner = untag_ptr(this_arg);
48052         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48054         this_arg_conv.is_owned = false;
48055         LDKLockableScore* ret_ret = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
48056         *ret_ret = MultiThreadedLockableScore_as_LockableScore(&this_arg_conv);
48057         return tag_ptr(ret_ret, true);
48058 }
48059
48060 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1write(JNIEnv *env, jclass clz, int64_t obj) {
48061         LDKMultiThreadedLockableScore obj_conv;
48062         obj_conv.inner = untag_ptr(obj);
48063         obj_conv.is_owned = ptr_is_owned(obj);
48064         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48065         obj_conv.is_owned = false;
48066         LDKCVec_u8Z ret_var = MultiThreadedLockableScore_write(&obj_conv);
48067         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48068         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48069         CVec_u8Z_free(ret_var);
48070         return ret_arr;
48071 }
48072
48073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1as_1WriteableScore(JNIEnv *env, jclass clz, int64_t this_arg) {
48074         LDKMultiThreadedLockableScore this_arg_conv;
48075         this_arg_conv.inner = untag_ptr(this_arg);
48076         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48078         this_arg_conv.is_owned = false;
48079         LDKWriteableScore* ret_ret = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
48080         *ret_ret = MultiThreadedLockableScore_as_WriteableScore(&this_arg_conv);
48081         return tag_ptr(ret_ret, true);
48082 }
48083
48084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1new(JNIEnv *env, jclass clz, int64_t score) {
48085         void* score_ptr = untag_ptr(score);
48086         CHECK_ACCESS(score_ptr);
48087         LDKScore score_conv = *(LDKScore*)(score_ptr);
48088         if (score_conv.free == LDKScore_JCalls_free) {
48089                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48090                 LDKScore_JCalls_cloned(&score_conv);
48091         }
48092         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
48093         int64_t ret_ref = 0;
48094         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48095         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48096         return ret_ref;
48097 }
48098
48099 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48100         LDKChannelUsage this_obj_conv;
48101         this_obj_conv.inner = untag_ptr(this_obj);
48102         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48104         ChannelUsage_free(this_obj_conv);
48105 }
48106
48107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48108         LDKChannelUsage this_ptr_conv;
48109         this_ptr_conv.inner = untag_ptr(this_ptr);
48110         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48112         this_ptr_conv.is_owned = false;
48113         int64_t ret_conv = ChannelUsage_get_amount_msat(&this_ptr_conv);
48114         return ret_conv;
48115 }
48116
48117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48118         LDKChannelUsage this_ptr_conv;
48119         this_ptr_conv.inner = untag_ptr(this_ptr);
48120         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48122         this_ptr_conv.is_owned = false;
48123         ChannelUsage_set_amount_msat(&this_ptr_conv, val);
48124 }
48125
48126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48127         LDKChannelUsage this_ptr_conv;
48128         this_ptr_conv.inner = untag_ptr(this_ptr);
48129         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48131         this_ptr_conv.is_owned = false;
48132         int64_t ret_conv = ChannelUsage_get_inflight_htlc_msat(&this_ptr_conv);
48133         return ret_conv;
48134 }
48135
48136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48137         LDKChannelUsage this_ptr_conv;
48138         this_ptr_conv.inner = untag_ptr(this_ptr);
48139         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48141         this_ptr_conv.is_owned = false;
48142         ChannelUsage_set_inflight_htlc_msat(&this_ptr_conv, val);
48143 }
48144
48145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr) {
48146         LDKChannelUsage this_ptr_conv;
48147         this_ptr_conv.inner = untag_ptr(this_ptr);
48148         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48150         this_ptr_conv.is_owned = false;
48151         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
48152         *ret_copy = ChannelUsage_get_effective_capacity(&this_ptr_conv);
48153         int64_t ret_ref = tag_ptr(ret_copy, true);
48154         return ret_ref;
48155 }
48156
48157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48158         LDKChannelUsage this_ptr_conv;
48159         this_ptr_conv.inner = untag_ptr(this_ptr);
48160         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48162         this_ptr_conv.is_owned = false;
48163         void* val_ptr = untag_ptr(val);
48164         CHECK_ACCESS(val_ptr);
48165         LDKEffectiveCapacity val_conv = *(LDKEffectiveCapacity*)(val_ptr);
48166         val_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)untag_ptr(val));
48167         ChannelUsage_set_effective_capacity(&this_ptr_conv, val_conv);
48168 }
48169
48170 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) {
48171         void* effective_capacity_arg_ptr = untag_ptr(effective_capacity_arg);
48172         CHECK_ACCESS(effective_capacity_arg_ptr);
48173         LDKEffectiveCapacity effective_capacity_arg_conv = *(LDKEffectiveCapacity*)(effective_capacity_arg_ptr);
48174         effective_capacity_arg_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)untag_ptr(effective_capacity_arg));
48175         LDKChannelUsage ret_var = ChannelUsage_new(amount_msat_arg, inflight_htlc_msat_arg, effective_capacity_arg_conv);
48176         int64_t ret_ref = 0;
48177         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48178         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48179         return ret_ref;
48180 }
48181
48182 static inline uint64_t ChannelUsage_clone_ptr(LDKChannelUsage *NONNULL_PTR arg) {
48183         LDKChannelUsage ret_var = ChannelUsage_clone(arg);
48184         int64_t ret_ref = 0;
48185         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48186         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48187         return ret_ref;
48188 }
48189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48190         LDKChannelUsage arg_conv;
48191         arg_conv.inner = untag_ptr(arg);
48192         arg_conv.is_owned = ptr_is_owned(arg);
48193         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48194         arg_conv.is_owned = false;
48195         int64_t ret_conv = ChannelUsage_clone_ptr(&arg_conv);
48196         return ret_conv;
48197 }
48198
48199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48200         LDKChannelUsage orig_conv;
48201         orig_conv.inner = untag_ptr(orig);
48202         orig_conv.is_owned = ptr_is_owned(orig);
48203         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48204         orig_conv.is_owned = false;
48205         LDKChannelUsage ret_var = ChannelUsage_clone(&orig_conv);
48206         int64_t ret_ref = 0;
48207         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48208         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48209         return ret_ref;
48210 }
48211
48212 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48213         LDKFixedPenaltyScorer this_obj_conv;
48214         this_obj_conv.inner = untag_ptr(this_obj);
48215         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48217         FixedPenaltyScorer_free(this_obj_conv);
48218 }
48219
48220 static inline uint64_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
48221         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
48222         int64_t ret_ref = 0;
48223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48224         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48225         return ret_ref;
48226 }
48227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48228         LDKFixedPenaltyScorer arg_conv;
48229         arg_conv.inner = untag_ptr(arg);
48230         arg_conv.is_owned = ptr_is_owned(arg);
48231         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48232         arg_conv.is_owned = false;
48233         int64_t ret_conv = FixedPenaltyScorer_clone_ptr(&arg_conv);
48234         return ret_conv;
48235 }
48236
48237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48238         LDKFixedPenaltyScorer orig_conv;
48239         orig_conv.inner = untag_ptr(orig);
48240         orig_conv.is_owned = ptr_is_owned(orig);
48241         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48242         orig_conv.is_owned = false;
48243         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
48244         int64_t ret_ref = 0;
48245         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48246         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48247         return ret_ref;
48248 }
48249
48250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1with_1penalty(JNIEnv *env, jclass clz, int64_t penalty_msat) {
48251         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
48252         int64_t ret_ref = 0;
48253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48254         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48255         return ret_ref;
48256 }
48257
48258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
48259         LDKFixedPenaltyScorer this_arg_conv;
48260         this_arg_conv.inner = untag_ptr(this_arg);
48261         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48263         this_arg_conv.is_owned = false;
48264         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
48265         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
48266         return tag_ptr(ret_ret, true);
48267 }
48268
48269 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
48270         LDKFixedPenaltyScorer obj_conv;
48271         obj_conv.inner = untag_ptr(obj);
48272         obj_conv.is_owned = ptr_is_owned(obj);
48273         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48274         obj_conv.is_owned = false;
48275         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
48276         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48277         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48278         CVec_u8Z_free(ret_var);
48279         return ret_arr;
48280 }
48281
48282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
48283         LDKu8slice ser_ref;
48284         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48285         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48286         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
48287         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
48288         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48289         return tag_ptr(ret_conv, true);
48290 }
48291
48292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48293         LDKProbabilisticScorer this_obj_conv;
48294         this_obj_conv.inner = untag_ptr(this_obj);
48295         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48297         ProbabilisticScorer_free(this_obj_conv);
48298 }
48299
48300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48301         LDKProbabilisticScoringParameters this_obj_conv;
48302         this_obj_conv.inner = untag_ptr(this_obj);
48303         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48305         ProbabilisticScoringParameters_free(this_obj_conv);
48306 }
48307
48308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48309         LDKProbabilisticScoringParameters this_ptr_conv;
48310         this_ptr_conv.inner = untag_ptr(this_ptr);
48311         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48313         this_ptr_conv.is_owned = false;
48314         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
48315         return ret_conv;
48316 }
48317
48318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48319         LDKProbabilisticScoringParameters this_ptr_conv;
48320         this_ptr_conv.inner = untag_ptr(this_ptr);
48321         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48323         this_ptr_conv.is_owned = false;
48324         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
48325 }
48326
48327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48328         LDKProbabilisticScoringParameters this_ptr_conv;
48329         this_ptr_conv.inner = untag_ptr(this_ptr);
48330         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48332         this_ptr_conv.is_owned = false;
48333         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_amount_multiplier_msat(&this_ptr_conv);
48334         return ret_conv;
48335 }
48336
48337 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) {
48338         LDKProbabilisticScoringParameters this_ptr_conv;
48339         this_ptr_conv.inner = untag_ptr(this_ptr);
48340         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48342         this_ptr_conv.is_owned = false;
48343         ProbabilisticScoringParameters_set_base_penalty_amount_multiplier_msat(&this_ptr_conv, val);
48344 }
48345
48346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48347         LDKProbabilisticScoringParameters this_ptr_conv;
48348         this_ptr_conv.inner = untag_ptr(this_ptr);
48349         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48351         this_ptr_conv.is_owned = false;
48352         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
48353         return ret_conv;
48354 }
48355
48356 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) {
48357         LDKProbabilisticScoringParameters this_ptr_conv;
48358         this_ptr_conv.inner = untag_ptr(this_ptr);
48359         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48361         this_ptr_conv.is_owned = false;
48362         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
48363 }
48364
48365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1offset_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
48366         LDKProbabilisticScoringParameters this_ptr_conv;
48367         this_ptr_conv.inner = untag_ptr(this_ptr);
48368         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48370         this_ptr_conv.is_owned = false;
48371         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
48372         return ret_conv;
48373 }
48374
48375 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) {
48376         LDKProbabilisticScoringParameters this_ptr_conv;
48377         this_ptr_conv.inner = untag_ptr(this_ptr);
48378         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48380         this_ptr_conv.is_owned = false;
48381         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
48382 }
48383
48384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48385         LDKProbabilisticScoringParameters this_ptr_conv;
48386         this_ptr_conv.inner = untag_ptr(this_ptr);
48387         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48389         this_ptr_conv.is_owned = false;
48390         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
48391         return ret_conv;
48392 }
48393
48394 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) {
48395         LDKProbabilisticScoringParameters this_ptr_conv;
48396         this_ptr_conv.inner = untag_ptr(this_ptr);
48397         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48399         this_ptr_conv.is_owned = false;
48400         ProbabilisticScoringParameters_set_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
48401 }
48402
48403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1historical_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48404         LDKProbabilisticScoringParameters this_ptr_conv;
48405         this_ptr_conv.inner = untag_ptr(this_ptr);
48406         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48408         this_ptr_conv.is_owned = false;
48409         int64_t ret_conv = ProbabilisticScoringParameters_get_historical_liquidity_penalty_multiplier_msat(&this_ptr_conv);
48410         return ret_conv;
48411 }
48412
48413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1historical_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48414         LDKProbabilisticScoringParameters this_ptr_conv;
48415         this_ptr_conv.inner = untag_ptr(this_ptr);
48416         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48418         this_ptr_conv.is_owned = false;
48419         ProbabilisticScoringParameters_set_historical_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
48420 }
48421
48422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1historical_1liquidity_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48423         LDKProbabilisticScoringParameters this_ptr_conv;
48424         this_ptr_conv.inner = untag_ptr(this_ptr);
48425         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48427         this_ptr_conv.is_owned = false;
48428         int64_t ret_conv = ProbabilisticScoringParameters_get_historical_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
48429         return ret_conv;
48430 }
48431
48432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1historical_1liquidity_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48433         LDKProbabilisticScoringParameters this_ptr_conv;
48434         this_ptr_conv.inner = untag_ptr(this_ptr);
48435         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48437         this_ptr_conv.is_owned = false;
48438         ProbabilisticScoringParameters_set_historical_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
48439 }
48440
48441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1historical_1no_1updates_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
48442         LDKProbabilisticScoringParameters this_ptr_conv;
48443         this_ptr_conv.inner = untag_ptr(this_ptr);
48444         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48446         this_ptr_conv.is_owned = false;
48447         int64_t ret_conv = ProbabilisticScoringParameters_get_historical_no_updates_half_life(&this_ptr_conv);
48448         return ret_conv;
48449 }
48450
48451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1historical_1no_1updates_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48452         LDKProbabilisticScoringParameters this_ptr_conv;
48453         this_ptr_conv.inner = untag_ptr(this_ptr);
48454         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48456         this_ptr_conv.is_owned = false;
48457         ProbabilisticScoringParameters_set_historical_no_updates_half_life(&this_ptr_conv, val);
48458 }
48459
48460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1anti_1probing_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48461         LDKProbabilisticScoringParameters this_ptr_conv;
48462         this_ptr_conv.inner = untag_ptr(this_ptr);
48463         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48465         this_ptr_conv.is_owned = false;
48466         int64_t ret_conv = ProbabilisticScoringParameters_get_anti_probing_penalty_msat(&this_ptr_conv);
48467         return ret_conv;
48468 }
48469
48470 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) {
48471         LDKProbabilisticScoringParameters this_ptr_conv;
48472         this_ptr_conv.inner = untag_ptr(this_ptr);
48473         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48475         this_ptr_conv.is_owned = false;
48476         ProbabilisticScoringParameters_set_anti_probing_penalty_msat(&this_ptr_conv, val);
48477 }
48478
48479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1considered_1impossible_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48480         LDKProbabilisticScoringParameters this_ptr_conv;
48481         this_ptr_conv.inner = untag_ptr(this_ptr);
48482         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48484         this_ptr_conv.is_owned = false;
48485         int64_t ret_conv = ProbabilisticScoringParameters_get_considered_impossible_penalty_msat(&this_ptr_conv);
48486         return ret_conv;
48487 }
48488
48489 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) {
48490         LDKProbabilisticScoringParameters this_ptr_conv;
48491         this_ptr_conv.inner = untag_ptr(this_ptr);
48492         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48494         this_ptr_conv.is_owned = false;
48495         ProbabilisticScoringParameters_set_considered_impossible_penalty_msat(&this_ptr_conv, val);
48496 }
48497
48498 static inline uint64_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
48499         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
48500         int64_t ret_ref = 0;
48501         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48502         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48503         return ret_ref;
48504 }
48505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48506         LDKProbabilisticScoringParameters arg_conv;
48507         arg_conv.inner = untag_ptr(arg);
48508         arg_conv.is_owned = ptr_is_owned(arg);
48509         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48510         arg_conv.is_owned = false;
48511         int64_t ret_conv = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
48512         return ret_conv;
48513 }
48514
48515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48516         LDKProbabilisticScoringParameters orig_conv;
48517         orig_conv.inner = untag_ptr(orig);
48518         orig_conv.is_owned = ptr_is_owned(orig);
48519         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48520         orig_conv.is_owned = false;
48521         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
48522         int64_t ret_ref = 0;
48523         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48524         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48525         return ret_ref;
48526 }
48527
48528 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) {
48529         LDKProbabilisticScoringParameters params_conv;
48530         params_conv.inner = untag_ptr(params);
48531         params_conv.is_owned = ptr_is_owned(params);
48532         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
48533         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
48534         LDKNetworkGraph network_graph_conv;
48535         network_graph_conv.inner = untag_ptr(network_graph);
48536         network_graph_conv.is_owned = ptr_is_owned(network_graph);
48537         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
48538         network_graph_conv.is_owned = false;
48539         void* logger_ptr = untag_ptr(logger);
48540         CHECK_ACCESS(logger_ptr);
48541         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
48542         if (logger_conv.free == LDKLogger_JCalls_free) {
48543                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48544                 LDKLogger_JCalls_cloned(&logger_conv);
48545         }
48546         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv, logger_conv);
48547         int64_t ret_ref = 0;
48548         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48549         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48550         return ret_ref;
48551 }
48552
48553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1debug_1log_1liquidity_1stats(JNIEnv *env, jclass clz, int64_t this_arg) {
48554         LDKProbabilisticScorer this_arg_conv;
48555         this_arg_conv.inner = untag_ptr(this_arg);
48556         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48558         this_arg_conv.is_owned = false;
48559         ProbabilisticScorer_debug_log_liquidity_stats(&this_arg_conv);
48560 }
48561
48562 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) {
48563         LDKProbabilisticScorer this_arg_conv;
48564         this_arg_conv.inner = untag_ptr(this_arg);
48565         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48567         this_arg_conv.is_owned = false;
48568         LDKNodeId target_conv;
48569         target_conv.inner = untag_ptr(target);
48570         target_conv.is_owned = ptr_is_owned(target);
48571         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
48572         target_conv.is_owned = false;
48573         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
48574         *ret_copy = ProbabilisticScorer_estimated_channel_liquidity_range(&this_arg_conv, scid, &target_conv);
48575         int64_t ret_ref = tag_ptr(ret_copy, true);
48576         return ret_ref;
48577 }
48578
48579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1add_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
48580         LDKProbabilisticScorer this_arg_conv;
48581         this_arg_conv.inner = untag_ptr(this_arg);
48582         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48584         this_arg_conv.is_owned = false;
48585         LDKNodeId node_id_conv;
48586         node_id_conv.inner = untag_ptr(node_id);
48587         node_id_conv.is_owned = ptr_is_owned(node_id);
48588         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
48589         node_id_conv.is_owned = false;
48590         ProbabilisticScorer_add_banned(&this_arg_conv, &node_id_conv);
48591 }
48592
48593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
48594         LDKProbabilisticScorer this_arg_conv;
48595         this_arg_conv.inner = untag_ptr(this_arg);
48596         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48598         this_arg_conv.is_owned = false;
48599         LDKNodeId node_id_conv;
48600         node_id_conv.inner = untag_ptr(node_id);
48601         node_id_conv.is_owned = ptr_is_owned(node_id);
48602         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
48603         node_id_conv.is_owned = false;
48604         ProbabilisticScorer_remove_banned(&this_arg_conv, &node_id_conv);
48605 }
48606
48607 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) {
48608         LDKProbabilisticScorer this_arg_conv;
48609         this_arg_conv.inner = untag_ptr(this_arg);
48610         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48612         this_arg_conv.is_owned = false;
48613         LDKNodeId node_id_conv;
48614         node_id_conv.inner = untag_ptr(node_id);
48615         node_id_conv.is_owned = ptr_is_owned(node_id);
48616         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
48617         node_id_conv.is_owned = false;
48618         ProbabilisticScorer_set_manual_penalty(&this_arg_conv, &node_id_conv, penalty);
48619 }
48620
48621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1manual_1penalty(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
48622         LDKProbabilisticScorer this_arg_conv;
48623         this_arg_conv.inner = untag_ptr(this_arg);
48624         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48626         this_arg_conv.is_owned = false;
48627         LDKNodeId node_id_conv;
48628         node_id_conv.inner = untag_ptr(node_id);
48629         node_id_conv.is_owned = ptr_is_owned(node_id);
48630         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
48631         node_id_conv.is_owned = false;
48632         ProbabilisticScorer_remove_manual_penalty(&this_arg_conv, &node_id_conv);
48633 }
48634
48635 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1clear_1manual_1penalties(JNIEnv *env, jclass clz, int64_t this_arg) {
48636         LDKProbabilisticScorer this_arg_conv;
48637         this_arg_conv.inner = untag_ptr(this_arg);
48638         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48640         this_arg_conv.is_owned = false;
48641         ProbabilisticScorer_clear_manual_penalties(&this_arg_conv);
48642 }
48643
48644 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) {
48645         LDKProbabilisticScoringParameters this_arg_conv;
48646         this_arg_conv.inner = untag_ptr(this_arg);
48647         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48649         this_arg_conv.is_owned = false;
48650         LDKCVec_NodeIdZ node_ids_constr;
48651         node_ids_constr.datalen = (*env)->GetArrayLength(env, node_ids);
48652         if (node_ids_constr.datalen > 0)
48653                 node_ids_constr.data = MALLOC(node_ids_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
48654         else
48655                 node_ids_constr.data = NULL;
48656         int64_t* node_ids_vals = (*env)->GetLongArrayElements (env, node_ids, NULL);
48657         for (size_t i = 0; i < node_ids_constr.datalen; i++) {
48658                 int64_t node_ids_conv_8 = node_ids_vals[i];
48659                 LDKNodeId node_ids_conv_8_conv;
48660                 node_ids_conv_8_conv.inner = untag_ptr(node_ids_conv_8);
48661                 node_ids_conv_8_conv.is_owned = ptr_is_owned(node_ids_conv_8);
48662                 CHECK_INNER_FIELD_ACCESS_OR_NULL(node_ids_conv_8_conv);
48663                 node_ids_conv_8_conv = NodeId_clone(&node_ids_conv_8_conv);
48664                 node_ids_constr.data[i] = node_ids_conv_8_conv;
48665         }
48666         (*env)->ReleaseLongArrayElements(env, node_ids, node_ids_vals, 0);
48667         ProbabilisticScoringParameters_add_banned_from_list(&this_arg_conv, node_ids_constr);
48668 }
48669
48670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1default(JNIEnv *env, jclass clz) {
48671         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
48672         int64_t ret_ref = 0;
48673         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48674         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48675         return ret_ref;
48676 }
48677
48678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
48679         LDKProbabilisticScorer this_arg_conv;
48680         this_arg_conv.inner = untag_ptr(this_arg);
48681         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48683         this_arg_conv.is_owned = false;
48684         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
48685         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
48686         return tag_ptr(ret_ret, true);
48687 }
48688
48689 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
48690         LDKProbabilisticScorer obj_conv;
48691         obj_conv.inner = untag_ptr(obj);
48692         obj_conv.is_owned = ptr_is_owned(obj);
48693         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48694         obj_conv.is_owned = false;
48695         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
48696         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48697         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48698         CVec_u8Z_free(ret_var);
48699         return ret_arr;
48700 }
48701
48702 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) {
48703         LDKu8slice ser_ref;
48704         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48705         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48706         LDKProbabilisticScoringParameters arg_a_conv;
48707         arg_a_conv.inner = untag_ptr(arg_a);
48708         arg_a_conv.is_owned = ptr_is_owned(arg_a);
48709         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
48710         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
48711         LDKNetworkGraph arg_b_conv;
48712         arg_b_conv.inner = untag_ptr(arg_b);
48713         arg_b_conv.is_owned = ptr_is_owned(arg_b);
48714         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
48715         arg_b_conv.is_owned = false;
48716         void* arg_c_ptr = untag_ptr(arg_c);
48717         CHECK_ACCESS(arg_c_ptr);
48718         LDKLogger arg_c_conv = *(LDKLogger*)(arg_c_ptr);
48719         if (arg_c_conv.free == LDKLogger_JCalls_free) {
48720                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48721                 LDKLogger_JCalls_cloned(&arg_c_conv);
48722         }
48723         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
48724         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv, arg_c_conv);
48725         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48726         return tag_ptr(ret_conv, true);
48727 }
48728
48729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48730         LDKBlindedRoute this_obj_conv;
48731         this_obj_conv.inner = untag_ptr(this_obj);
48732         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48734         BlindedRoute_free(this_obj_conv);
48735 }
48736
48737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48738         LDKBlindedHop this_obj_conv;
48739         this_obj_conv.inner = untag_ptr(this_obj);
48740         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48742         BlindedHop_free(this_obj_conv);
48743 }
48744
48745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedRoute_1new(JNIEnv *env, jclass clz, jobjectArray node_pks, int64_t keys_manager) {
48746         LDKCVec_PublicKeyZ node_pks_constr;
48747         node_pks_constr.datalen = (*env)->GetArrayLength(env, node_pks);
48748         if (node_pks_constr.datalen > 0)
48749                 node_pks_constr.data = MALLOC(node_pks_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
48750         else
48751                 node_pks_constr.data = NULL;
48752         for (size_t i = 0; i < node_pks_constr.datalen; i++) {
48753                 int8_tArray node_pks_conv_8 = (*env)->GetObjectArrayElement(env, node_pks, i);
48754                 LDKPublicKey node_pks_conv_8_ref;
48755                 CHECK((*env)->GetArrayLength(env, node_pks_conv_8) == 33);
48756                 (*env)->GetByteArrayRegion(env, node_pks_conv_8, 0, 33, node_pks_conv_8_ref.compressed_form);
48757                 node_pks_constr.data[i] = node_pks_conv_8_ref;
48758         }
48759         void* keys_manager_ptr = untag_ptr(keys_manager);
48760         if (ptr_is_owned(keys_manager)) { CHECK_ACCESS(keys_manager_ptr); }
48761         LDKKeysInterface* keys_manager_conv = (LDKKeysInterface*)keys_manager_ptr;
48762         LDKCResult_BlindedRouteNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedRouteNoneZ), "LDKCResult_BlindedRouteNoneZ");
48763         *ret_conv = BlindedRoute_new(node_pks_constr, keys_manager_conv);
48764         return tag_ptr(ret_conv, true);
48765 }
48766
48767 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedRoute_1write(JNIEnv *env, jclass clz, int64_t obj) {
48768         LDKBlindedRoute obj_conv;
48769         obj_conv.inner = untag_ptr(obj);
48770         obj_conv.is_owned = ptr_is_owned(obj);
48771         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48772         obj_conv.is_owned = false;
48773         LDKCVec_u8Z ret_var = BlindedRoute_write(&obj_conv);
48774         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48775         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48776         CVec_u8Z_free(ret_var);
48777         return ret_arr;
48778 }
48779
48780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedRoute_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
48781         LDKu8slice ser_ref;
48782         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48783         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48784         LDKCResult_BlindedRouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedRouteDecodeErrorZ), "LDKCResult_BlindedRouteDecodeErrorZ");
48785         *ret_conv = BlindedRoute_read(ser_ref);
48786         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48787         return tag_ptr(ret_conv, true);
48788 }
48789
48790 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
48791         LDKBlindedHop obj_conv;
48792         obj_conv.inner = untag_ptr(obj);
48793         obj_conv.is_owned = ptr_is_owned(obj);
48794         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48795         obj_conv.is_owned = false;
48796         LDKCVec_u8Z ret_var = BlindedHop_write(&obj_conv);
48797         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48798         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48799         CVec_u8Z_free(ret_var);
48800         return ret_arr;
48801 }
48802
48803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
48804         LDKu8slice ser_ref;
48805         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48806         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48807         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
48808         *ret_conv = BlindedHop_read(ser_ref);
48809         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48810         return tag_ptr(ret_conv, true);
48811 }
48812
48813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48814         LDKOnionMessenger this_obj_conv;
48815         this_obj_conv.inner = untag_ptr(this_obj);
48816         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48818         OnionMessenger_free(this_obj_conv);
48819 }
48820
48821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Destination_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48822         if (!ptr_is_owned(this_ptr)) return;
48823         void* this_ptr_ptr = untag_ptr(this_ptr);
48824         CHECK_ACCESS(this_ptr_ptr);
48825         LDKDestination this_ptr_conv = *(LDKDestination*)(this_ptr_ptr);
48826         FREE(untag_ptr(this_ptr));
48827         Destination_free(this_ptr_conv);
48828 }
48829
48830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1node(JNIEnv *env, jclass clz, int8_tArray a) {
48831         LDKPublicKey a_ref;
48832         CHECK((*env)->GetArrayLength(env, a) == 33);
48833         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
48834         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
48835         *ret_copy = Destination_node(a_ref);
48836         int64_t ret_ref = tag_ptr(ret_copy, true);
48837         return ret_ref;
48838 }
48839
48840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1blinded_1route(JNIEnv *env, jclass clz, int64_t a) {
48841         LDKBlindedRoute a_conv;
48842         a_conv.inner = untag_ptr(a);
48843         a_conv.is_owned = ptr_is_owned(a);
48844         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48845         // WARNING: we need a move here but no clone is available for LDKBlindedRoute
48846         
48847         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
48848         *ret_copy = Destination_blinded_route(a_conv);
48849         int64_t ret_ref = tag_ptr(ret_copy, true);
48850         return ret_ref;
48851 }
48852
48853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SendError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48854         if (!ptr_is_owned(this_ptr)) return;
48855         void* this_ptr_ptr = untag_ptr(this_ptr);
48856         CHECK_ACCESS(this_ptr_ptr);
48857         LDKSendError this_ptr_conv = *(LDKSendError*)(this_ptr_ptr);
48858         FREE(untag_ptr(this_ptr));
48859         SendError_free(this_ptr_conv);
48860 }
48861
48862 static inline uint64_t SendError_clone_ptr(LDKSendError *NONNULL_PTR arg) {
48863         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
48864         *ret_copy = SendError_clone(arg);
48865         int64_t ret_ref = tag_ptr(ret_copy, true);
48866         return ret_ref;
48867 }
48868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48869         LDKSendError* arg_conv = (LDKSendError*)untag_ptr(arg);
48870         int64_t ret_conv = SendError_clone_ptr(arg_conv);
48871         return ret_conv;
48872 }
48873
48874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48875         LDKSendError* orig_conv = (LDKSendError*)untag_ptr(orig);
48876         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
48877         *ret_copy = SendError_clone(orig_conv);
48878         int64_t ret_ref = tag_ptr(ret_copy, true);
48879         return ret_ref;
48880 }
48881
48882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1secp256k1(JNIEnv *env, jclass clz, jclass a) {
48883         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_java(env, a);
48884         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
48885         *ret_copy = SendError_secp256k1(a_conv);
48886         int64_t ret_ref = tag_ptr(ret_copy, true);
48887         return ret_ref;
48888 }
48889
48890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1too_1big_1packet(JNIEnv *env, jclass clz) {
48891         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
48892         *ret_copy = SendError_too_big_packet();
48893         int64_t ret_ref = tag_ptr(ret_copy, true);
48894         return ret_ref;
48895 }
48896
48897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1too_1few_1blinded_1hops(JNIEnv *env, jclass clz) {
48898         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
48899         *ret_copy = SendError_too_few_blinded_hops();
48900         int64_t ret_ref = tag_ptr(ret_copy, true);
48901         return ret_ref;
48902 }
48903
48904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1invalid_1first_1hop(JNIEnv *env, jclass clz) {
48905         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
48906         *ret_copy = SendError_invalid_first_hop();
48907         int64_t ret_ref = tag_ptr(ret_copy, true);
48908         return ret_ref;
48909 }
48910
48911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1invalid_1message(JNIEnv *env, jclass clz) {
48912         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
48913         *ret_copy = SendError_invalid_message();
48914         int64_t ret_ref = tag_ptr(ret_copy, true);
48915         return ret_ref;
48916 }
48917
48918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1buffer_1full(JNIEnv *env, jclass clz) {
48919         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
48920         *ret_copy = SendError_buffer_full();
48921         int64_t ret_ref = tag_ptr(ret_copy, true);
48922         return ret_ref;
48923 }
48924
48925 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SendError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48926         LDKSendError* a_conv = (LDKSendError*)untag_ptr(a);
48927         LDKSendError* b_conv = (LDKSendError*)untag_ptr(b);
48928         jboolean ret_conv = SendError_eq(a_conv, b_conv);
48929         return ret_conv;
48930 }
48931
48932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48933         if (!ptr_is_owned(this_ptr)) return;
48934         void* this_ptr_ptr = untag_ptr(this_ptr);
48935         CHECK_ACCESS(this_ptr_ptr);
48936         LDKCustomOnionMessageHandler this_ptr_conv = *(LDKCustomOnionMessageHandler*)(this_ptr_ptr);
48937         FREE(untag_ptr(this_ptr));
48938         CustomOnionMessageHandler_free(this_ptr_conv);
48939 }
48940
48941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1new(JNIEnv *env, jclass clz, int64_t keys_manager, int64_t logger, int64_t custom_handler) {
48942         void* keys_manager_ptr = untag_ptr(keys_manager);
48943         CHECK_ACCESS(keys_manager_ptr);
48944         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
48945         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
48946                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48947                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
48948         }
48949         void* logger_ptr = untag_ptr(logger);
48950         CHECK_ACCESS(logger_ptr);
48951         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
48952         if (logger_conv.free == LDKLogger_JCalls_free) {
48953                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48954                 LDKLogger_JCalls_cloned(&logger_conv);
48955         }
48956         void* custom_handler_ptr = untag_ptr(custom_handler);
48957         CHECK_ACCESS(custom_handler_ptr);
48958         LDKCustomOnionMessageHandler custom_handler_conv = *(LDKCustomOnionMessageHandler*)(custom_handler_ptr);
48959         if (custom_handler_conv.free == LDKCustomOnionMessageHandler_JCalls_free) {
48960                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48961                 LDKCustomOnionMessageHandler_JCalls_cloned(&custom_handler_conv);
48962         }
48963         LDKOnionMessenger ret_var = OnionMessenger_new(keys_manager_conv, logger_conv, custom_handler_conv);
48964         int64_t ret_ref = 0;
48965         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48966         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48967         return ret_ref;
48968 }
48969
48970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1send_1custom_1onion_1message(JNIEnv *env, jclass clz, int64_t this_arg, jobjectArray intermediate_nodes, int64_t destination, int64_t msg, int64_t reply_path) {
48971         LDKOnionMessenger this_arg_conv;
48972         this_arg_conv.inner = untag_ptr(this_arg);
48973         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48975         this_arg_conv.is_owned = false;
48976         LDKCVec_PublicKeyZ intermediate_nodes_constr;
48977         intermediate_nodes_constr.datalen = (*env)->GetArrayLength(env, intermediate_nodes);
48978         if (intermediate_nodes_constr.datalen > 0)
48979                 intermediate_nodes_constr.data = MALLOC(intermediate_nodes_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
48980         else
48981                 intermediate_nodes_constr.data = NULL;
48982         for (size_t i = 0; i < intermediate_nodes_constr.datalen; i++) {
48983                 int8_tArray intermediate_nodes_conv_8 = (*env)->GetObjectArrayElement(env, intermediate_nodes, i);
48984                 LDKPublicKey intermediate_nodes_conv_8_ref;
48985                 CHECK((*env)->GetArrayLength(env, intermediate_nodes_conv_8) == 33);
48986                 (*env)->GetByteArrayRegion(env, intermediate_nodes_conv_8, 0, 33, intermediate_nodes_conv_8_ref.compressed_form);
48987                 intermediate_nodes_constr.data[i] = intermediate_nodes_conv_8_ref;
48988         }
48989         void* destination_ptr = untag_ptr(destination);
48990         CHECK_ACCESS(destination_ptr);
48991         LDKDestination destination_conv = *(LDKDestination*)(destination_ptr);
48992         // WARNING: we may need a move here but no clone is available for LDKDestination
48993         void* msg_ptr = untag_ptr(msg);
48994         CHECK_ACCESS(msg_ptr);
48995         LDKCustomOnionMessageContents msg_conv = *(LDKCustomOnionMessageContents*)(msg_ptr);
48996         if (msg_conv.free == LDKCustomOnionMessageContents_JCalls_free) {
48997                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48998                 LDKCustomOnionMessageContents_JCalls_cloned(&msg_conv);
48999         }
49000         LDKBlindedRoute reply_path_conv;
49001         reply_path_conv.inner = untag_ptr(reply_path);
49002         reply_path_conv.is_owned = ptr_is_owned(reply_path);
49003         CHECK_INNER_FIELD_ACCESS_OR_NULL(reply_path_conv);
49004         reply_path_conv.is_owned = false;
49005         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
49006         *ret_conv = OnionMessenger_send_custom_onion_message(&this_arg_conv, intermediate_nodes_constr, destination_conv, msg_conv, reply_path_conv);
49007         return tag_ptr(ret_conv, true);
49008 }
49009
49010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1as_1OnionMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
49011         LDKOnionMessenger this_arg_conv;
49012         this_arg_conv.inner = untag_ptr(this_arg);
49013         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49015         this_arg_conv.is_owned = false;
49016         LDKOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
49017         *ret_ret = OnionMessenger_as_OnionMessageHandler(&this_arg_conv);
49018         return tag_ptr(ret_ret, true);
49019 }
49020
49021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1as_1OnionMessageProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
49022         LDKOnionMessenger this_arg_conv;
49023         this_arg_conv.inner = untag_ptr(this_arg);
49024         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49026         this_arg_conv.is_owned = false;
49027         LDKOnionMessageProvider* ret_ret = MALLOC(sizeof(LDKOnionMessageProvider), "LDKOnionMessageProvider");
49028         *ret_ret = OnionMessenger_as_OnionMessageProvider(&this_arg_conv);
49029         return tag_ptr(ret_ret, true);
49030 }
49031
49032 static inline uint64_t CustomOnionMessageContents_clone_ptr(LDKCustomOnionMessageContents *NONNULL_PTR arg) {
49033         LDKCustomOnionMessageContents* ret_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
49034         *ret_ret = CustomOnionMessageContents_clone(arg);
49035         return tag_ptr(ret_ret, true);
49036 }
49037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49038         void* arg_ptr = untag_ptr(arg);
49039         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
49040         LDKCustomOnionMessageContents* arg_conv = (LDKCustomOnionMessageContents*)arg_ptr;
49041         int64_t ret_conv = CustomOnionMessageContents_clone_ptr(arg_conv);
49042         return ret_conv;
49043 }
49044
49045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49046         void* orig_ptr = untag_ptr(orig);
49047         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
49048         LDKCustomOnionMessageContents* orig_conv = (LDKCustomOnionMessageContents*)orig_ptr;
49049         LDKCustomOnionMessageContents* ret_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
49050         *ret_ret = CustomOnionMessageContents_clone(orig_conv);
49051         return tag_ptr(ret_ret, true);
49052 }
49053
49054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49055         if (!ptr_is_owned(this_ptr)) return;
49056         void* this_ptr_ptr = untag_ptr(this_ptr);
49057         CHECK_ACCESS(this_ptr_ptr);
49058         LDKCustomOnionMessageContents this_ptr_conv = *(LDKCustomOnionMessageContents*)(this_ptr_ptr);
49059         FREE(untag_ptr(this_ptr));
49060         CustomOnionMessageContents_free(this_ptr_conv);
49061 }
49062
49063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49064         LDKFilesystemPersister this_obj_conv;
49065         this_obj_conv.inner = untag_ptr(this_obj);
49066         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49068         FilesystemPersister_free(this_obj_conv);
49069 }
49070
49071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
49072         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
49073         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
49074         int64_t ret_ref = 0;
49075         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49076         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49077         return ret_ref;
49078 }
49079
49080 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
49081         LDKFilesystemPersister this_arg_conv;
49082         this_arg_conv.inner = untag_ptr(this_arg);
49083         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49085         this_arg_conv.is_owned = false;
49086         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
49087         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49088         Str_free(ret_str);
49089         return ret_conv;
49090 }
49091
49092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
49093         LDKFilesystemPersister this_arg_conv;
49094         this_arg_conv.inner = untag_ptr(this_arg);
49095         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49097         this_arg_conv.is_owned = false;
49098         void* keys_manager_ptr = untag_ptr(keys_manager);
49099         CHECK_ACCESS(keys_manager_ptr);
49100         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
49101         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
49102                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49103                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
49104         }
49105         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
49106         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
49107         return tag_ptr(ret_conv, true);
49108 }
49109
49110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49111         LDKBackgroundProcessor this_obj_conv;
49112         this_obj_conv.inner = untag_ptr(this_obj);
49113         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49115         BackgroundProcessor_free(this_obj_conv);
49116 }
49117
49118 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipSync_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49119         if (!ptr_is_owned(this_ptr)) return;
49120         void* this_ptr_ptr = untag_ptr(this_ptr);
49121         CHECK_ACCESS(this_ptr_ptr);
49122         LDKGossipSync this_ptr_conv = *(LDKGossipSync*)(this_ptr_ptr);
49123         FREE(untag_ptr(this_ptr));
49124         GossipSync_free(this_ptr_conv);
49125 }
49126
49127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1p2_1p(JNIEnv *env, jclass clz, int64_t a) {
49128         LDKP2PGossipSync a_conv;
49129         a_conv.inner = untag_ptr(a);
49130         a_conv.is_owned = ptr_is_owned(a);
49131         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49132         a_conv.is_owned = false;
49133         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
49134         *ret_copy = GossipSync_p2_p(&a_conv);
49135         int64_t ret_ref = tag_ptr(ret_copy, true);
49136         return ret_ref;
49137 }
49138
49139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1rapid(JNIEnv *env, jclass clz, int64_t a) {
49140         LDKRapidGossipSync a_conv;
49141         a_conv.inner = untag_ptr(a);
49142         a_conv.is_owned = ptr_is_owned(a);
49143         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49144         a_conv.is_owned = false;
49145         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
49146         *ret_copy = GossipSync_rapid(&a_conv);
49147         int64_t ret_ref = tag_ptr(ret_copy, true);
49148         return ret_ref;
49149 }
49150
49151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1none(JNIEnv *env, jclass clz) {
49152         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
49153         *ret_copy = GossipSync_none();
49154         int64_t ret_ref = tag_ptr(ret_copy, true);
49155         return ret_ref;
49156 }
49157
49158 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) {
49159         void* persister_ptr = untag_ptr(persister);
49160         CHECK_ACCESS(persister_ptr);
49161         LDKPersister persister_conv = *(LDKPersister*)(persister_ptr);
49162         if (persister_conv.free == LDKPersister_JCalls_free) {
49163                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49164                 LDKPersister_JCalls_cloned(&persister_conv);
49165         }
49166         void* event_handler_ptr = untag_ptr(event_handler);
49167         CHECK_ACCESS(event_handler_ptr);
49168         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
49169         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
49170                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49171                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
49172         }
49173         LDKChainMonitor chain_monitor_conv;
49174         chain_monitor_conv.inner = untag_ptr(chain_monitor);
49175         chain_monitor_conv.is_owned = ptr_is_owned(chain_monitor);
49176         CHECK_INNER_FIELD_ACCESS_OR_NULL(chain_monitor_conv);
49177         chain_monitor_conv.is_owned = false;
49178         LDKChannelManager channel_manager_conv;
49179         channel_manager_conv.inner = untag_ptr(channel_manager);
49180         channel_manager_conv.is_owned = ptr_is_owned(channel_manager);
49181         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
49182         channel_manager_conv.is_owned = false;
49183         void* gossip_sync_ptr = untag_ptr(gossip_sync);
49184         CHECK_ACCESS(gossip_sync_ptr);
49185         LDKGossipSync gossip_sync_conv = *(LDKGossipSync*)(gossip_sync_ptr);
49186         // WARNING: we may need a move here but no clone is available for LDKGossipSync
49187         LDKPeerManager peer_manager_conv;
49188         peer_manager_conv.inner = untag_ptr(peer_manager);
49189         peer_manager_conv.is_owned = ptr_is_owned(peer_manager);
49190         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_manager_conv);
49191         peer_manager_conv.is_owned = false;
49192         void* logger_ptr = untag_ptr(logger);
49193         CHECK_ACCESS(logger_ptr);
49194         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
49195         if (logger_conv.free == LDKLogger_JCalls_free) {
49196                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49197                 LDKLogger_JCalls_cloned(&logger_conv);
49198         }
49199         void* scorer_ptr = untag_ptr(scorer);
49200         CHECK_ACCESS(scorer_ptr);
49201         LDKCOption_WriteableScoreZ scorer_conv = *(LDKCOption_WriteableScoreZ*)(scorer_ptr);
49202         // WARNING: we may need a move here but no clone is available for LDKCOption_WriteableScoreZ
49203         if (scorer_conv.tag == LDKCOption_WriteableScoreZ_Some) {
49204                 // Manually implement clone for Java trait instances
49205                 if (scorer_conv.some.free == LDKWriteableScore_JCalls_free) {
49206                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49207                         LDKWriteableScore_JCalls_cloned(&scorer_conv.some);
49208                 }
49209         }
49210         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);
49211         int64_t ret_ref = 0;
49212         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49213         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49214         return ret_ref;
49215 }
49216
49217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
49218         LDKBackgroundProcessor this_arg_conv;
49219         this_arg_conv.inner = untag_ptr(this_arg);
49220         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49222         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
49223         
49224         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
49225         *ret_conv = BackgroundProcessor_join(this_arg_conv);
49226         return tag_ptr(ret_conv, true);
49227 }
49228
49229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
49230         LDKBackgroundProcessor this_arg_conv;
49231         this_arg_conv.inner = untag_ptr(this_arg);
49232         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49234         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
49235         
49236         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
49237         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
49238         return tag_ptr(ret_conv, true);
49239 }
49240
49241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49242         if (!ptr_is_owned(this_ptr)) return;
49243         void* this_ptr_ptr = untag_ptr(this_ptr);
49244         CHECK_ACCESS(this_ptr_ptr);
49245         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
49246         FREE(untag_ptr(this_ptr));
49247         ParseError_free(this_ptr_conv);
49248 }
49249
49250 static inline uint64_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
49251         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49252         *ret_copy = ParseError_clone(arg);
49253         int64_t ret_ref = tag_ptr(ret_copy, true);
49254         return ret_ref;
49255 }
49256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49257         LDKParseError* arg_conv = (LDKParseError*)untag_ptr(arg);
49258         int64_t ret_conv = ParseError_clone_ptr(arg_conv);
49259         return ret_conv;
49260 }
49261
49262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49263         LDKParseError* orig_conv = (LDKParseError*)untag_ptr(orig);
49264         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49265         *ret_copy = ParseError_clone(orig_conv);
49266         int64_t ret_ref = tag_ptr(ret_copy, true);
49267         return ret_ref;
49268 }
49269
49270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bech32_1error(JNIEnv *env, jclass clz, int64_t a) {
49271         void* a_ptr = untag_ptr(a);
49272         CHECK_ACCESS(a_ptr);
49273         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
49274         a_conv = Bech32Error_clone((LDKBech32Error*)untag_ptr(a));
49275         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49276         *ret_copy = ParseError_bech32_error(a_conv);
49277         int64_t ret_ref = tag_ptr(ret_copy, true);
49278         return ret_ref;
49279 }
49280
49281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1parse_1amount_1error(JNIEnv *env, jclass clz, int32_t a) {
49282         
49283         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49284         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
49285         int64_t ret_ref = tag_ptr(ret_copy, true);
49286         return ret_ref;
49287 }
49288
49289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1signature(JNIEnv *env, jclass clz, jclass a) {
49290         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_java(env, a);
49291         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49292         *ret_copy = ParseError_malformed_signature(a_conv);
49293         int64_t ret_ref = tag_ptr(ret_copy, true);
49294         return ret_ref;
49295 }
49296
49297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bad_1prefix(JNIEnv *env, jclass clz) {
49298         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49299         *ret_copy = ParseError_bad_prefix();
49300         int64_t ret_ref = tag_ptr(ret_copy, true);
49301         return ret_ref;
49302 }
49303
49304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1currency(JNIEnv *env, jclass clz) {
49305         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49306         *ret_copy = ParseError_unknown_currency();
49307         int64_t ret_ref = tag_ptr(ret_copy, true);
49308         return ret_ref;
49309 }
49310
49311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1si_1prefix(JNIEnv *env, jclass clz) {
49312         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49313         *ret_copy = ParseError_unknown_si_prefix();
49314         int64_t ret_ref = tag_ptr(ret_copy, true);
49315         return ret_ref;
49316 }
49317
49318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1hrp(JNIEnv *env, jclass clz) {
49319         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49320         *ret_copy = ParseError_malformed_hrp();
49321         int64_t ret_ref = tag_ptr(ret_copy, true);
49322         return ret_ref;
49323 }
49324
49325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1too_1short_1data_1part(JNIEnv *env, jclass clz) {
49326         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49327         *ret_copy = ParseError_too_short_data_part();
49328         int64_t ret_ref = tag_ptr(ret_copy, true);
49329         return ret_ref;
49330 }
49331
49332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unexpected_1end_1of_1tagged_1fields(JNIEnv *env, jclass clz) {
49333         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49334         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
49335         int64_t ret_ref = tag_ptr(ret_copy, true);
49336         return ret_ref;
49337 }
49338
49339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1description_1decode_1error(JNIEnv *env, jclass clz, int32_t a) {
49340         
49341         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49342         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
49343         int64_t ret_ref = tag_ptr(ret_copy, true);
49344         return ret_ref;
49345 }
49346
49347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1padding_1error(JNIEnv *env, jclass clz) {
49348         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49349         *ret_copy = ParseError_padding_error();
49350         int64_t ret_ref = tag_ptr(ret_copy, true);
49351         return ret_ref;
49352 }
49353
49354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1integer_1overflow_1error(JNIEnv *env, jclass clz) {
49355         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49356         *ret_copy = ParseError_integer_overflow_error();
49357         int64_t ret_ref = tag_ptr(ret_copy, true);
49358         return ret_ref;
49359 }
49360
49361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1seg_1wit_1program_1length(JNIEnv *env, jclass clz) {
49362         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49363         *ret_copy = ParseError_invalid_seg_wit_program_length();
49364         int64_t ret_ref = tag_ptr(ret_copy, true);
49365         return ret_ref;
49366 }
49367
49368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1pub_1key_1hash_1length(JNIEnv *env, jclass clz) {
49369         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49370         *ret_copy = ParseError_invalid_pub_key_hash_length();
49371         int64_t ret_ref = tag_ptr(ret_copy, true);
49372         return ret_ref;
49373 }
49374
49375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1script_1hash_1length(JNIEnv *env, jclass clz) {
49376         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49377         *ret_copy = ParseError_invalid_script_hash_length();
49378         int64_t ret_ref = tag_ptr(ret_copy, true);
49379         return ret_ref;
49380 }
49381
49382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
49383         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49384         *ret_copy = ParseError_invalid_recovery_id();
49385         int64_t ret_ref = tag_ptr(ret_copy, true);
49386         return ret_ref;
49387 }
49388
49389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1slice_1length(JNIEnv *env, jclass clz, jstring a) {
49390         LDKStr a_conv = java_to_owned_str(env, a);
49391         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49392         *ret_copy = ParseError_invalid_slice_length(a_conv);
49393         int64_t ret_ref = tag_ptr(ret_copy, true);
49394         return ret_ref;
49395 }
49396
49397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1skip(JNIEnv *env, jclass clz) {
49398         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
49399         *ret_copy = ParseError_skip();
49400         int64_t ret_ref = tag_ptr(ret_copy, true);
49401         return ret_ref;
49402 }
49403
49404 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ParseError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49405         LDKParseError* a_conv = (LDKParseError*)untag_ptr(a);
49406         LDKParseError* b_conv = (LDKParseError*)untag_ptr(b);
49407         jboolean ret_conv = ParseError_eq(a_conv, b_conv);
49408         return ret_conv;
49409 }
49410
49411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49412         if (!ptr_is_owned(this_ptr)) return;
49413         void* this_ptr_ptr = untag_ptr(this_ptr);
49414         CHECK_ACCESS(this_ptr_ptr);
49415         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
49416         FREE(untag_ptr(this_ptr));
49417         ParseOrSemanticError_free(this_ptr_conv);
49418 }
49419
49420 static inline uint64_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
49421         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
49422         *ret_copy = ParseOrSemanticError_clone(arg);
49423         int64_t ret_ref = tag_ptr(ret_copy, true);
49424         return ret_ref;
49425 }
49426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49427         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)untag_ptr(arg);
49428         int64_t ret_conv = ParseOrSemanticError_clone_ptr(arg_conv);
49429         return ret_conv;
49430 }
49431
49432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49433         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)untag_ptr(orig);
49434         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
49435         *ret_copy = ParseOrSemanticError_clone(orig_conv);
49436         int64_t ret_ref = tag_ptr(ret_copy, true);
49437         return ret_ref;
49438 }
49439
49440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1parse_1error(JNIEnv *env, jclass clz, int64_t a) {
49441         void* a_ptr = untag_ptr(a);
49442         CHECK_ACCESS(a_ptr);
49443         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
49444         a_conv = ParseError_clone((LDKParseError*)untag_ptr(a));
49445         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
49446         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
49447         int64_t ret_ref = tag_ptr(ret_copy, true);
49448         return ret_ref;
49449 }
49450
49451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1semantic_1error(JNIEnv *env, jclass clz, jclass a) {
49452         LDKSemanticError a_conv = LDKSemanticError_from_java(env, a);
49453         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
49454         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
49455         int64_t ret_ref = tag_ptr(ret_copy, true);
49456         return ret_ref;
49457 }
49458
49459 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49460         LDKParseOrSemanticError* a_conv = (LDKParseOrSemanticError*)untag_ptr(a);
49461         LDKParseOrSemanticError* b_conv = (LDKParseOrSemanticError*)untag_ptr(b);
49462         jboolean ret_conv = ParseOrSemanticError_eq(a_conv, b_conv);
49463         return ret_conv;
49464 }
49465
49466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49467         LDKInvoice this_obj_conv;
49468         this_obj_conv.inner = untag_ptr(this_obj);
49469         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49471         Invoice_free(this_obj_conv);
49472 }
49473
49474 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49475         LDKInvoice a_conv;
49476         a_conv.inner = untag_ptr(a);
49477         a_conv.is_owned = ptr_is_owned(a);
49478         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49479         a_conv.is_owned = false;
49480         LDKInvoice b_conv;
49481         b_conv.inner = untag_ptr(b);
49482         b_conv.is_owned = ptr_is_owned(b);
49483         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49484         b_conv.is_owned = false;
49485         jboolean ret_conv = Invoice_eq(&a_conv, &b_conv);
49486         return ret_conv;
49487 }
49488
49489 static inline uint64_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
49490         LDKInvoice ret_var = Invoice_clone(arg);
49491         int64_t ret_ref = 0;
49492         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49493         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49494         return ret_ref;
49495 }
49496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49497         LDKInvoice arg_conv;
49498         arg_conv.inner = untag_ptr(arg);
49499         arg_conv.is_owned = ptr_is_owned(arg);
49500         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49501         arg_conv.is_owned = false;
49502         int64_t ret_conv = Invoice_clone_ptr(&arg_conv);
49503         return ret_conv;
49504 }
49505
49506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49507         LDKInvoice orig_conv;
49508         orig_conv.inner = untag_ptr(orig);
49509         orig_conv.is_owned = ptr_is_owned(orig);
49510         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49511         orig_conv.is_owned = false;
49512         LDKInvoice ret_var = Invoice_clone(&orig_conv);
49513         int64_t ret_ref = 0;
49514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49515         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49516         return ret_ref;
49517 }
49518
49519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1hash(JNIEnv *env, jclass clz, int64_t o) {
49520         LDKInvoice o_conv;
49521         o_conv.inner = untag_ptr(o);
49522         o_conv.is_owned = ptr_is_owned(o);
49523         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49524         o_conv.is_owned = false;
49525         int64_t ret_conv = Invoice_hash(&o_conv);
49526         return ret_conv;
49527 }
49528
49529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49530         LDKSignedRawInvoice this_obj_conv;
49531         this_obj_conv.inner = untag_ptr(this_obj);
49532         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49534         SignedRawInvoice_free(this_obj_conv);
49535 }
49536
49537 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49538         LDKSignedRawInvoice a_conv;
49539         a_conv.inner = untag_ptr(a);
49540         a_conv.is_owned = ptr_is_owned(a);
49541         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49542         a_conv.is_owned = false;
49543         LDKSignedRawInvoice b_conv;
49544         b_conv.inner = untag_ptr(b);
49545         b_conv.is_owned = ptr_is_owned(b);
49546         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49547         b_conv.is_owned = false;
49548         jboolean ret_conv = SignedRawInvoice_eq(&a_conv, &b_conv);
49549         return ret_conv;
49550 }
49551
49552 static inline uint64_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
49553         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
49554         int64_t ret_ref = 0;
49555         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49556         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49557         return ret_ref;
49558 }
49559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49560         LDKSignedRawInvoice arg_conv;
49561         arg_conv.inner = untag_ptr(arg);
49562         arg_conv.is_owned = ptr_is_owned(arg);
49563         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49564         arg_conv.is_owned = false;
49565         int64_t ret_conv = SignedRawInvoice_clone_ptr(&arg_conv);
49566         return ret_conv;
49567 }
49568
49569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49570         LDKSignedRawInvoice orig_conv;
49571         orig_conv.inner = untag_ptr(orig);
49572         orig_conv.is_owned = ptr_is_owned(orig);
49573         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49574         orig_conv.is_owned = false;
49575         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
49576         int64_t ret_ref = 0;
49577         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49578         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49579         return ret_ref;
49580 }
49581
49582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t o) {
49583         LDKSignedRawInvoice o_conv;
49584         o_conv.inner = untag_ptr(o);
49585         o_conv.is_owned = ptr_is_owned(o);
49586         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49587         o_conv.is_owned = false;
49588         int64_t ret_conv = SignedRawInvoice_hash(&o_conv);
49589         return ret_conv;
49590 }
49591
49592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49593         LDKRawInvoice this_obj_conv;
49594         this_obj_conv.inner = untag_ptr(this_obj);
49595         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49597         RawInvoice_free(this_obj_conv);
49598 }
49599
49600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
49601         LDKRawInvoice this_ptr_conv;
49602         this_ptr_conv.inner = untag_ptr(this_ptr);
49603         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49605         this_ptr_conv.is_owned = false;
49606         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
49607         int64_t ret_ref = 0;
49608         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49609         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49610         return ret_ref;
49611 }
49612
49613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49614         LDKRawInvoice this_ptr_conv;
49615         this_ptr_conv.inner = untag_ptr(this_ptr);
49616         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49618         this_ptr_conv.is_owned = false;
49619         LDKRawDataPart val_conv;
49620         val_conv.inner = untag_ptr(val);
49621         val_conv.is_owned = ptr_is_owned(val);
49622         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49623         val_conv = RawDataPart_clone(&val_conv);
49624         RawInvoice_set_data(&this_ptr_conv, val_conv);
49625 }
49626
49627 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49628         LDKRawInvoice a_conv;
49629         a_conv.inner = untag_ptr(a);
49630         a_conv.is_owned = ptr_is_owned(a);
49631         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49632         a_conv.is_owned = false;
49633         LDKRawInvoice b_conv;
49634         b_conv.inner = untag_ptr(b);
49635         b_conv.is_owned = ptr_is_owned(b);
49636         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49637         b_conv.is_owned = false;
49638         jboolean ret_conv = RawInvoice_eq(&a_conv, &b_conv);
49639         return ret_conv;
49640 }
49641
49642 static inline uint64_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
49643         LDKRawInvoice ret_var = RawInvoice_clone(arg);
49644         int64_t ret_ref = 0;
49645         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49646         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49647         return ret_ref;
49648 }
49649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49650         LDKRawInvoice arg_conv;
49651         arg_conv.inner = untag_ptr(arg);
49652         arg_conv.is_owned = ptr_is_owned(arg);
49653         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49654         arg_conv.is_owned = false;
49655         int64_t ret_conv = RawInvoice_clone_ptr(&arg_conv);
49656         return ret_conv;
49657 }
49658
49659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49660         LDKRawInvoice orig_conv;
49661         orig_conv.inner = untag_ptr(orig);
49662         orig_conv.is_owned = ptr_is_owned(orig);
49663         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49664         orig_conv.is_owned = false;
49665         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
49666         int64_t ret_ref = 0;
49667         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49668         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49669         return ret_ref;
49670 }
49671
49672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t o) {
49673         LDKRawInvoice o_conv;
49674         o_conv.inner = untag_ptr(o);
49675         o_conv.is_owned = ptr_is_owned(o);
49676         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49677         o_conv.is_owned = false;
49678         int64_t ret_conv = RawInvoice_hash(&o_conv);
49679         return ret_conv;
49680 }
49681
49682 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49683         LDKRawDataPart this_obj_conv;
49684         this_obj_conv.inner = untag_ptr(this_obj);
49685         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49687         RawDataPart_free(this_obj_conv);
49688 }
49689
49690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
49691         LDKRawDataPart this_ptr_conv;
49692         this_ptr_conv.inner = untag_ptr(this_ptr);
49693         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49695         this_ptr_conv.is_owned = false;
49696         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
49697         int64_t ret_ref = 0;
49698         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49699         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49700         return ret_ref;
49701 }
49702
49703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49704         LDKRawDataPart this_ptr_conv;
49705         this_ptr_conv.inner = untag_ptr(this_ptr);
49706         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49708         this_ptr_conv.is_owned = false;
49709         LDKPositiveTimestamp val_conv;
49710         val_conv.inner = untag_ptr(val);
49711         val_conv.is_owned = ptr_is_owned(val);
49712         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49713         val_conv = PositiveTimestamp_clone(&val_conv);
49714         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
49715 }
49716
49717 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49718         LDKRawDataPart a_conv;
49719         a_conv.inner = untag_ptr(a);
49720         a_conv.is_owned = ptr_is_owned(a);
49721         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49722         a_conv.is_owned = false;
49723         LDKRawDataPart b_conv;
49724         b_conv.inner = untag_ptr(b);
49725         b_conv.is_owned = ptr_is_owned(b);
49726         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49727         b_conv.is_owned = false;
49728         jboolean ret_conv = RawDataPart_eq(&a_conv, &b_conv);
49729         return ret_conv;
49730 }
49731
49732 static inline uint64_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
49733         LDKRawDataPart ret_var = RawDataPart_clone(arg);
49734         int64_t ret_ref = 0;
49735         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49736         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49737         return ret_ref;
49738 }
49739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49740         LDKRawDataPart arg_conv;
49741         arg_conv.inner = untag_ptr(arg);
49742         arg_conv.is_owned = ptr_is_owned(arg);
49743         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49744         arg_conv.is_owned = false;
49745         int64_t ret_conv = RawDataPart_clone_ptr(&arg_conv);
49746         return ret_conv;
49747 }
49748
49749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49750         LDKRawDataPart orig_conv;
49751         orig_conv.inner = untag_ptr(orig);
49752         orig_conv.is_owned = ptr_is_owned(orig);
49753         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49754         orig_conv.is_owned = false;
49755         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
49756         int64_t ret_ref = 0;
49757         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49758         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49759         return ret_ref;
49760 }
49761
49762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1hash(JNIEnv *env, jclass clz, int64_t o) {
49763         LDKRawDataPart o_conv;
49764         o_conv.inner = untag_ptr(o);
49765         o_conv.is_owned = ptr_is_owned(o);
49766         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49767         o_conv.is_owned = false;
49768         int64_t ret_conv = RawDataPart_hash(&o_conv);
49769         return ret_conv;
49770 }
49771
49772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49773         LDKPositiveTimestamp this_obj_conv;
49774         this_obj_conv.inner = untag_ptr(this_obj);
49775         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49777         PositiveTimestamp_free(this_obj_conv);
49778 }
49779
49780 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49781         LDKPositiveTimestamp a_conv;
49782         a_conv.inner = untag_ptr(a);
49783         a_conv.is_owned = ptr_is_owned(a);
49784         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49785         a_conv.is_owned = false;
49786         LDKPositiveTimestamp b_conv;
49787         b_conv.inner = untag_ptr(b);
49788         b_conv.is_owned = ptr_is_owned(b);
49789         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49790         b_conv.is_owned = false;
49791         jboolean ret_conv = PositiveTimestamp_eq(&a_conv, &b_conv);
49792         return ret_conv;
49793 }
49794
49795 static inline uint64_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
49796         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
49797         int64_t ret_ref = 0;
49798         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49799         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49800         return ret_ref;
49801 }
49802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49803         LDKPositiveTimestamp arg_conv;
49804         arg_conv.inner = untag_ptr(arg);
49805         arg_conv.is_owned = ptr_is_owned(arg);
49806         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49807         arg_conv.is_owned = false;
49808         int64_t ret_conv = PositiveTimestamp_clone_ptr(&arg_conv);
49809         return ret_conv;
49810 }
49811
49812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49813         LDKPositiveTimestamp orig_conv;
49814         orig_conv.inner = untag_ptr(orig);
49815         orig_conv.is_owned = ptr_is_owned(orig);
49816         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49817         orig_conv.is_owned = false;
49818         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
49819         int64_t ret_ref = 0;
49820         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49821         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49822         return ret_ref;
49823 }
49824
49825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1hash(JNIEnv *env, jclass clz, int64_t o) {
49826         LDKPositiveTimestamp o_conv;
49827         o_conv.inner = untag_ptr(o);
49828         o_conv.is_owned = ptr_is_owned(o);
49829         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49830         o_conv.is_owned = false;
49831         int64_t ret_conv = PositiveTimestamp_hash(&o_conv);
49832         return ret_conv;
49833 }
49834
49835 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49836         LDKSiPrefix* orig_conv = (LDKSiPrefix*)untag_ptr(orig);
49837         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
49838         return ret_conv;
49839 }
49840
49841 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
49842         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
49843         return ret_conv;
49844 }
49845
49846 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
49847         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
49848         return ret_conv;
49849 }
49850
49851 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
49852         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
49853         return ret_conv;
49854 }
49855
49856 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
49857         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
49858         return ret_conv;
49859 }
49860
49861 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49862         LDKSiPrefix* a_conv = (LDKSiPrefix*)untag_ptr(a);
49863         LDKSiPrefix* b_conv = (LDKSiPrefix*)untag_ptr(b);
49864         jboolean ret_conv = SiPrefix_eq(a_conv, b_conv);
49865         return ret_conv;
49866 }
49867
49868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1hash(JNIEnv *env, jclass clz, int64_t o) {
49869         LDKSiPrefix* o_conv = (LDKSiPrefix*)untag_ptr(o);
49870         int64_t ret_conv = SiPrefix_hash(o_conv);
49871         return ret_conv;
49872 }
49873
49874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
49875         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)untag_ptr(this_arg);
49876         int64_t ret_conv = SiPrefix_multiplier(this_arg_conv);
49877         return ret_conv;
49878 }
49879
49880 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49881         LDKCurrency* orig_conv = (LDKCurrency*)untag_ptr(orig);
49882         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
49883         return ret_conv;
49884 }
49885
49886 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
49887         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
49888         return ret_conv;
49889 }
49890
49891 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
49892         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
49893         return ret_conv;
49894 }
49895
49896 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
49897         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
49898         return ret_conv;
49899 }
49900
49901 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
49902         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
49903         return ret_conv;
49904 }
49905
49906 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
49907         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
49908         return ret_conv;
49909 }
49910
49911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) {
49912         LDKCurrency* o_conv = (LDKCurrency*)untag_ptr(o);
49913         int64_t ret_conv = Currency_hash(o_conv);
49914         return ret_conv;
49915 }
49916
49917 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49918         LDKCurrency* a_conv = (LDKCurrency*)untag_ptr(a);
49919         LDKCurrency* b_conv = (LDKCurrency*)untag_ptr(b);
49920         jboolean ret_conv = Currency_eq(a_conv, b_conv);
49921         return ret_conv;
49922 }
49923
49924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49925         LDKSha256 this_obj_conv;
49926         this_obj_conv.inner = untag_ptr(this_obj);
49927         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49929         Sha256_free(this_obj_conv);
49930 }
49931
49932 static inline uint64_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
49933         LDKSha256 ret_var = Sha256_clone(arg);
49934         int64_t ret_ref = 0;
49935         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49936         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49937         return ret_ref;
49938 }
49939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49940         LDKSha256 arg_conv;
49941         arg_conv.inner = untag_ptr(arg);
49942         arg_conv.is_owned = ptr_is_owned(arg);
49943         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49944         arg_conv.is_owned = false;
49945         int64_t ret_conv = Sha256_clone_ptr(&arg_conv);
49946         return ret_conv;
49947 }
49948
49949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49950         LDKSha256 orig_conv;
49951         orig_conv.inner = untag_ptr(orig);
49952         orig_conv.is_owned = ptr_is_owned(orig);
49953         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49954         orig_conv.is_owned = false;
49955         LDKSha256 ret_var = Sha256_clone(&orig_conv);
49956         int64_t ret_ref = 0;
49957         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49958         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49959         return ret_ref;
49960 }
49961
49962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) {
49963         LDKSha256 o_conv;
49964         o_conv.inner = untag_ptr(o);
49965         o_conv.is_owned = ptr_is_owned(o);
49966         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49967         o_conv.is_owned = false;
49968         int64_t ret_conv = Sha256_hash(&o_conv);
49969         return ret_conv;
49970 }
49971
49972 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49973         LDKSha256 a_conv;
49974         a_conv.inner = untag_ptr(a);
49975         a_conv.is_owned = ptr_is_owned(a);
49976         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49977         a_conv.is_owned = false;
49978         LDKSha256 b_conv;
49979         b_conv.inner = untag_ptr(b);
49980         b_conv.is_owned = ptr_is_owned(b);
49981         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49982         b_conv.is_owned = false;
49983         jboolean ret_conv = Sha256_eq(&a_conv, &b_conv);
49984         return ret_conv;
49985 }
49986
49987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49988         LDKDescription this_obj_conv;
49989         this_obj_conv.inner = untag_ptr(this_obj);
49990         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49992         Description_free(this_obj_conv);
49993 }
49994
49995 static inline uint64_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
49996         LDKDescription ret_var = Description_clone(arg);
49997         int64_t ret_ref = 0;
49998         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49999         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50000         return ret_ref;
50001 }
50002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50003         LDKDescription arg_conv;
50004         arg_conv.inner = untag_ptr(arg);
50005         arg_conv.is_owned = ptr_is_owned(arg);
50006         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50007         arg_conv.is_owned = false;
50008         int64_t ret_conv = Description_clone_ptr(&arg_conv);
50009         return ret_conv;
50010 }
50011
50012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50013         LDKDescription orig_conv;
50014         orig_conv.inner = untag_ptr(orig);
50015         orig_conv.is_owned = ptr_is_owned(orig);
50016         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50017         orig_conv.is_owned = false;
50018         LDKDescription ret_var = Description_clone(&orig_conv);
50019         int64_t ret_ref = 0;
50020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50021         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50022         return ret_ref;
50023 }
50024
50025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) {
50026         LDKDescription o_conv;
50027         o_conv.inner = untag_ptr(o);
50028         o_conv.is_owned = ptr_is_owned(o);
50029         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
50030         o_conv.is_owned = false;
50031         int64_t ret_conv = Description_hash(&o_conv);
50032         return ret_conv;
50033 }
50034
50035 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
50036         LDKDescription a_conv;
50037         a_conv.inner = untag_ptr(a);
50038         a_conv.is_owned = ptr_is_owned(a);
50039         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50040         a_conv.is_owned = false;
50041         LDKDescription b_conv;
50042         b_conv.inner = untag_ptr(b);
50043         b_conv.is_owned = ptr_is_owned(b);
50044         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50045         b_conv.is_owned = false;
50046         jboolean ret_conv = Description_eq(&a_conv, &b_conv);
50047         return ret_conv;
50048 }
50049
50050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50051         LDKPayeePubKey this_obj_conv;
50052         this_obj_conv.inner = untag_ptr(this_obj);
50053         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50055         PayeePubKey_free(this_obj_conv);
50056 }
50057
50058 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
50059         LDKPayeePubKey this_ptr_conv;
50060         this_ptr_conv.inner = untag_ptr(this_ptr);
50061         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50063         this_ptr_conv.is_owned = false;
50064         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
50065         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PayeePubKey_get_a(&this_ptr_conv).compressed_form);
50066         return ret_arr;
50067 }
50068
50069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
50070         LDKPayeePubKey this_ptr_conv;
50071         this_ptr_conv.inner = untag_ptr(this_ptr);
50072         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50074         this_ptr_conv.is_owned = false;
50075         LDKPublicKey val_ref;
50076         CHECK((*env)->GetArrayLength(env, val) == 33);
50077         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
50078         PayeePubKey_set_a(&this_ptr_conv, val_ref);
50079 }
50080
50081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
50082         LDKPublicKey a_arg_ref;
50083         CHECK((*env)->GetArrayLength(env, a_arg) == 33);
50084         (*env)->GetByteArrayRegion(env, a_arg, 0, 33, a_arg_ref.compressed_form);
50085         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
50086         int64_t ret_ref = 0;
50087         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50088         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50089         return ret_ref;
50090 }
50091
50092 static inline uint64_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
50093         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
50094         int64_t ret_ref = 0;
50095         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50096         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50097         return ret_ref;
50098 }
50099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50100         LDKPayeePubKey arg_conv;
50101         arg_conv.inner = untag_ptr(arg);
50102         arg_conv.is_owned = ptr_is_owned(arg);
50103         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50104         arg_conv.is_owned = false;
50105         int64_t ret_conv = PayeePubKey_clone_ptr(&arg_conv);
50106         return ret_conv;
50107 }
50108
50109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50110         LDKPayeePubKey orig_conv;
50111         orig_conv.inner = untag_ptr(orig);
50112         orig_conv.is_owned = ptr_is_owned(orig);
50113         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50114         orig_conv.is_owned = false;
50115         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
50116         int64_t ret_ref = 0;
50117         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50118         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50119         return ret_ref;
50120 }
50121
50122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) {
50123         LDKPayeePubKey o_conv;
50124         o_conv.inner = untag_ptr(o);
50125         o_conv.is_owned = ptr_is_owned(o);
50126         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
50127         o_conv.is_owned = false;
50128         int64_t ret_conv = PayeePubKey_hash(&o_conv);
50129         return ret_conv;
50130 }
50131
50132 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
50133         LDKPayeePubKey a_conv;
50134         a_conv.inner = untag_ptr(a);
50135         a_conv.is_owned = ptr_is_owned(a);
50136         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50137         a_conv.is_owned = false;
50138         LDKPayeePubKey b_conv;
50139         b_conv.inner = untag_ptr(b);
50140         b_conv.is_owned = ptr_is_owned(b);
50141         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50142         b_conv.is_owned = false;
50143         jboolean ret_conv = PayeePubKey_eq(&a_conv, &b_conv);
50144         return ret_conv;
50145 }
50146
50147 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50148         LDKExpiryTime this_obj_conv;
50149         this_obj_conv.inner = untag_ptr(this_obj);
50150         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50152         ExpiryTime_free(this_obj_conv);
50153 }
50154
50155 static inline uint64_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
50156         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
50157         int64_t ret_ref = 0;
50158         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50159         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50160         return ret_ref;
50161 }
50162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50163         LDKExpiryTime arg_conv;
50164         arg_conv.inner = untag_ptr(arg);
50165         arg_conv.is_owned = ptr_is_owned(arg);
50166         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50167         arg_conv.is_owned = false;
50168         int64_t ret_conv = ExpiryTime_clone_ptr(&arg_conv);
50169         return ret_conv;
50170 }
50171
50172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50173         LDKExpiryTime orig_conv;
50174         orig_conv.inner = untag_ptr(orig);
50175         orig_conv.is_owned = ptr_is_owned(orig);
50176         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50177         orig_conv.is_owned = false;
50178         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
50179         int64_t ret_ref = 0;
50180         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50181         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50182         return ret_ref;
50183 }
50184
50185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) {
50186         LDKExpiryTime o_conv;
50187         o_conv.inner = untag_ptr(o);
50188         o_conv.is_owned = ptr_is_owned(o);
50189         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
50190         o_conv.is_owned = false;
50191         int64_t ret_conv = ExpiryTime_hash(&o_conv);
50192         return ret_conv;
50193 }
50194
50195 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
50196         LDKExpiryTime a_conv;
50197         a_conv.inner = untag_ptr(a);
50198         a_conv.is_owned = ptr_is_owned(a);
50199         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50200         a_conv.is_owned = false;
50201         LDKExpiryTime b_conv;
50202         b_conv.inner = untag_ptr(b);
50203         b_conv.is_owned = ptr_is_owned(b);
50204         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50205         b_conv.is_owned = false;
50206         jboolean ret_conv = ExpiryTime_eq(&a_conv, &b_conv);
50207         return ret_conv;
50208 }
50209
50210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50211         LDKMinFinalCltvExpiry this_obj_conv;
50212         this_obj_conv.inner = untag_ptr(this_obj);
50213         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50215         MinFinalCltvExpiry_free(this_obj_conv);
50216 }
50217
50218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
50219         LDKMinFinalCltvExpiry this_ptr_conv;
50220         this_ptr_conv.inner = untag_ptr(this_ptr);
50221         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50223         this_ptr_conv.is_owned = false;
50224         int64_t ret_conv = MinFinalCltvExpiry_get_a(&this_ptr_conv);
50225         return ret_conv;
50226 }
50227
50228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
50229         LDKMinFinalCltvExpiry this_ptr_conv;
50230         this_ptr_conv.inner = untag_ptr(this_ptr);
50231         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50233         this_ptr_conv.is_owned = false;
50234         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
50235 }
50236
50237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
50238         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
50239         int64_t ret_ref = 0;
50240         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50241         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50242         return ret_ref;
50243 }
50244
50245 static inline uint64_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
50246         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
50247         int64_t ret_ref = 0;
50248         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50249         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50250         return ret_ref;
50251 }
50252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50253         LDKMinFinalCltvExpiry arg_conv;
50254         arg_conv.inner = untag_ptr(arg);
50255         arg_conv.is_owned = ptr_is_owned(arg);
50256         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50257         arg_conv.is_owned = false;
50258         int64_t ret_conv = MinFinalCltvExpiry_clone_ptr(&arg_conv);
50259         return ret_conv;
50260 }
50261
50262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50263         LDKMinFinalCltvExpiry orig_conv;
50264         orig_conv.inner = untag_ptr(orig);
50265         orig_conv.is_owned = ptr_is_owned(orig);
50266         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50267         orig_conv.is_owned = false;
50268         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
50269         int64_t ret_ref = 0;
50270         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50271         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50272         return ret_ref;
50273 }
50274
50275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1hash(JNIEnv *env, jclass clz, int64_t o) {
50276         LDKMinFinalCltvExpiry o_conv;
50277         o_conv.inner = untag_ptr(o);
50278         o_conv.is_owned = ptr_is_owned(o);
50279         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
50280         o_conv.is_owned = false;
50281         int64_t ret_conv = MinFinalCltvExpiry_hash(&o_conv);
50282         return ret_conv;
50283 }
50284
50285 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
50286         LDKMinFinalCltvExpiry a_conv;
50287         a_conv.inner = untag_ptr(a);
50288         a_conv.is_owned = ptr_is_owned(a);
50289         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50290         a_conv.is_owned = false;
50291         LDKMinFinalCltvExpiry b_conv;
50292         b_conv.inner = untag_ptr(b);
50293         b_conv.is_owned = ptr_is_owned(b);
50294         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50295         b_conv.is_owned = false;
50296         jboolean ret_conv = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
50297         return ret_conv;
50298 }
50299
50300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
50301         if (!ptr_is_owned(this_ptr)) return;
50302         void* this_ptr_ptr = untag_ptr(this_ptr);
50303         CHECK_ACCESS(this_ptr_ptr);
50304         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
50305         FREE(untag_ptr(this_ptr));
50306         Fallback_free(this_ptr_conv);
50307 }
50308
50309 static inline uint64_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
50310         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
50311         *ret_copy = Fallback_clone(arg);
50312         int64_t ret_ref = tag_ptr(ret_copy, true);
50313         return ret_ref;
50314 }
50315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50316         LDKFallback* arg_conv = (LDKFallback*)untag_ptr(arg);
50317         int64_t ret_conv = Fallback_clone_ptr(arg_conv);
50318         return ret_conv;
50319 }
50320
50321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50322         LDKFallback* orig_conv = (LDKFallback*)untag_ptr(orig);
50323         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
50324         *ret_copy = Fallback_clone(orig_conv);
50325         int64_t ret_ref = tag_ptr(ret_copy, true);
50326         return ret_ref;
50327 }
50328
50329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
50330         
50331         LDKCVec_u8Z program_ref;
50332         program_ref.datalen = (*env)->GetArrayLength(env, program);
50333         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
50334         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
50335         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
50336         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
50337         int64_t ret_ref = tag_ptr(ret_copy, true);
50338         return ret_ref;
50339 }
50340
50341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
50342         LDKTwentyBytes a_ref;
50343         CHECK((*env)->GetArrayLength(env, a) == 20);
50344         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
50345         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
50346         *ret_copy = Fallback_pub_key_hash(a_ref);
50347         int64_t ret_ref = tag_ptr(ret_copy, true);
50348         return ret_ref;
50349 }
50350
50351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
50352         LDKTwentyBytes a_ref;
50353         CHECK((*env)->GetArrayLength(env, a) == 20);
50354         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
50355         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
50356         *ret_copy = Fallback_script_hash(a_ref);
50357         int64_t ret_ref = tag_ptr(ret_copy, true);
50358         return ret_ref;
50359 }
50360
50361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1hash(JNIEnv *env, jclass clz, int64_t o) {
50362         LDKFallback* o_conv = (LDKFallback*)untag_ptr(o);
50363         int64_t ret_conv = Fallback_hash(o_conv);
50364         return ret_conv;
50365 }
50366
50367 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
50368         LDKFallback* a_conv = (LDKFallback*)untag_ptr(a);
50369         LDKFallback* b_conv = (LDKFallback*)untag_ptr(b);
50370         jboolean ret_conv = Fallback_eq(a_conv, b_conv);
50371         return ret_conv;
50372 }
50373
50374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50375         LDKInvoiceSignature this_obj_conv;
50376         this_obj_conv.inner = untag_ptr(this_obj);
50377         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50379         InvoiceSignature_free(this_obj_conv);
50380 }
50381
50382 static inline uint64_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
50383         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
50384         int64_t ret_ref = 0;
50385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50386         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50387         return ret_ref;
50388 }
50389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50390         LDKInvoiceSignature arg_conv;
50391         arg_conv.inner = untag_ptr(arg);
50392         arg_conv.is_owned = ptr_is_owned(arg);
50393         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50394         arg_conv.is_owned = false;
50395         int64_t ret_conv = InvoiceSignature_clone_ptr(&arg_conv);
50396         return ret_conv;
50397 }
50398
50399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50400         LDKInvoiceSignature orig_conv;
50401         orig_conv.inner = untag_ptr(orig);
50402         orig_conv.is_owned = ptr_is_owned(orig);
50403         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50404         orig_conv.is_owned = false;
50405         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
50406         int64_t ret_ref = 0;
50407         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50408         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50409         return ret_ref;
50410 }
50411
50412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1hash(JNIEnv *env, jclass clz, int64_t o) {
50413         LDKInvoiceSignature o_conv;
50414         o_conv.inner = untag_ptr(o);
50415         o_conv.is_owned = ptr_is_owned(o);
50416         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
50417         o_conv.is_owned = false;
50418         int64_t ret_conv = InvoiceSignature_hash(&o_conv);
50419         return ret_conv;
50420 }
50421
50422 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
50423         LDKInvoiceSignature a_conv;
50424         a_conv.inner = untag_ptr(a);
50425         a_conv.is_owned = ptr_is_owned(a);
50426         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50427         a_conv.is_owned = false;
50428         LDKInvoiceSignature b_conv;
50429         b_conv.inner = untag_ptr(b);
50430         b_conv.is_owned = ptr_is_owned(b);
50431         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50432         b_conv.is_owned = false;
50433         jboolean ret_conv = InvoiceSignature_eq(&a_conv, &b_conv);
50434         return ret_conv;
50435 }
50436
50437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50438         LDKPrivateRoute this_obj_conv;
50439         this_obj_conv.inner = untag_ptr(this_obj);
50440         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50442         PrivateRoute_free(this_obj_conv);
50443 }
50444
50445 static inline uint64_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
50446         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
50447         int64_t ret_ref = 0;
50448         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50449         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50450         return ret_ref;
50451 }
50452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50453         LDKPrivateRoute arg_conv;
50454         arg_conv.inner = untag_ptr(arg);
50455         arg_conv.is_owned = ptr_is_owned(arg);
50456         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50457         arg_conv.is_owned = false;
50458         int64_t ret_conv = PrivateRoute_clone_ptr(&arg_conv);
50459         return ret_conv;
50460 }
50461
50462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50463         LDKPrivateRoute orig_conv;
50464         orig_conv.inner = untag_ptr(orig);
50465         orig_conv.is_owned = ptr_is_owned(orig);
50466         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50467         orig_conv.is_owned = false;
50468         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
50469         int64_t ret_ref = 0;
50470         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50471         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50472         return ret_ref;
50473 }
50474
50475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) {
50476         LDKPrivateRoute o_conv;
50477         o_conv.inner = untag_ptr(o);
50478         o_conv.is_owned = ptr_is_owned(o);
50479         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
50480         o_conv.is_owned = false;
50481         int64_t ret_conv = PrivateRoute_hash(&o_conv);
50482         return ret_conv;
50483 }
50484
50485 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
50486         LDKPrivateRoute a_conv;
50487         a_conv.inner = untag_ptr(a);
50488         a_conv.is_owned = ptr_is_owned(a);
50489         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50490         a_conv.is_owned = false;
50491         LDKPrivateRoute b_conv;
50492         b_conv.inner = untag_ptr(b);
50493         b_conv.is_owned = ptr_is_owned(b);
50494         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50495         b_conv.is_owned = false;
50496         jboolean ret_conv = PrivateRoute_eq(&a_conv, &b_conv);
50497         return ret_conv;
50498 }
50499
50500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
50501         LDKSignedRawInvoice this_arg_conv;
50502         this_arg_conv.inner = untag_ptr(this_arg);
50503         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50505         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
50506         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
50507         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
50508         return tag_ptr(ret_conv, true);
50509 }
50510
50511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
50512         LDKSignedRawInvoice this_arg_conv;
50513         this_arg_conv.inner = untag_ptr(this_arg);
50514         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50516         this_arg_conv.is_owned = false;
50517         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
50518         int64_t ret_ref = 0;
50519         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50520         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50521         return ret_ref;
50522 }
50523
50524 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signable_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
50525         LDKSignedRawInvoice this_arg_conv;
50526         this_arg_conv.inner = untag_ptr(this_arg);
50527         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50529         this_arg_conv.is_owned = false;
50530         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
50531         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_signable_hash(&this_arg_conv));
50532         return ret_arr;
50533 }
50534
50535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
50536         LDKSignedRawInvoice this_arg_conv;
50537         this_arg_conv.inner = untag_ptr(this_arg);
50538         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50540         this_arg_conv.is_owned = false;
50541         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
50542         int64_t ret_ref = 0;
50543         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50544         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50545         return ret_ref;
50546 }
50547
50548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
50549         LDKSignedRawInvoice this_arg_conv;
50550         this_arg_conv.inner = untag_ptr(this_arg);
50551         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50553         this_arg_conv.is_owned = false;
50554         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
50555         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
50556         return tag_ptr(ret_conv, true);
50557 }
50558
50559 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
50560         LDKSignedRawInvoice this_arg_conv;
50561         this_arg_conv.inner = untag_ptr(this_arg);
50562         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50564         this_arg_conv.is_owned = false;
50565         jboolean ret_conv = SignedRawInvoice_check_signature(&this_arg_conv);
50566         return ret_conv;
50567 }
50568
50569 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1signable_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
50570         LDKRawInvoice this_arg_conv;
50571         this_arg_conv.inner = untag_ptr(this_arg);
50572         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50574         this_arg_conv.is_owned = false;
50575         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
50576         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_signable_hash(&this_arg_conv).data);
50577         return ret_arr;
50578 }
50579
50580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
50581         LDKRawInvoice this_arg_conv;
50582         this_arg_conv.inner = untag_ptr(this_arg);
50583         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50585         this_arg_conv.is_owned = false;
50586         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
50587         int64_t ret_ref = 0;
50588         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50589         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50590         return ret_ref;
50591 }
50592
50593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
50594         LDKRawInvoice this_arg_conv;
50595         this_arg_conv.inner = untag_ptr(this_arg);
50596         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50598         this_arg_conv.is_owned = false;
50599         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
50600         int64_t ret_ref = 0;
50601         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50602         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50603         return ret_ref;
50604 }
50605
50606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
50607         LDKRawInvoice this_arg_conv;
50608         this_arg_conv.inner = untag_ptr(this_arg);
50609         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50611         this_arg_conv.is_owned = false;
50612         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
50613         int64_t ret_ref = 0;
50614         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50615         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50616         return ret_ref;
50617 }
50618
50619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
50620         LDKRawInvoice this_arg_conv;
50621         this_arg_conv.inner = untag_ptr(this_arg);
50622         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50624         this_arg_conv.is_owned = false;
50625         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
50626         int64_t ret_ref = 0;
50627         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50628         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50629         return ret_ref;
50630 }
50631
50632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
50633         LDKRawInvoice this_arg_conv;
50634         this_arg_conv.inner = untag_ptr(this_arg);
50635         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50637         this_arg_conv.is_owned = false;
50638         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
50639         int64_t ret_ref = 0;
50640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50641         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50642         return ret_ref;
50643 }
50644
50645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
50646         LDKRawInvoice this_arg_conv;
50647         this_arg_conv.inner = untag_ptr(this_arg);
50648         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50650         this_arg_conv.is_owned = false;
50651         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
50652         int64_t ret_ref = 0;
50653         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50654         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50655         return ret_ref;
50656 }
50657
50658 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
50659         LDKRawInvoice this_arg_conv;
50660         this_arg_conv.inner = untag_ptr(this_arg);
50661         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50663         this_arg_conv.is_owned = false;
50664         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
50665         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
50666         return ret_arr;
50667 }
50668
50669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
50670         LDKRawInvoice this_arg_conv;
50671         this_arg_conv.inner = untag_ptr(this_arg);
50672         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50674         this_arg_conv.is_owned = false;
50675         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
50676         int64_t ret_ref = 0;
50677         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50678         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50679         return ret_ref;
50680 }
50681
50682 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
50683         LDKRawInvoice this_arg_conv;
50684         this_arg_conv.inner = untag_ptr(this_arg);
50685         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50687         this_arg_conv.is_owned = false;
50688         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
50689         int64_tArray ret_arr = NULL;
50690         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
50691         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
50692         for (size_t o = 0; o < ret_var.datalen; o++) {
50693                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
50694                 int64_t ret_conv_14_ref = 0;
50695                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
50696                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
50697                 ret_arr_ptr[o] = ret_conv_14_ref;
50698         }
50699         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
50700         FREE(ret_var.data);
50701         return ret_arr;
50702 }
50703
50704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
50705         LDKRawInvoice this_arg_conv;
50706         this_arg_conv.inner = untag_ptr(this_arg);
50707         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50709         this_arg_conv.is_owned = false;
50710         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
50711         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
50712         int64_t ret_ref = tag_ptr(ret_copy, true);
50713         return ret_ref;
50714 }
50715
50716 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
50717         LDKRawInvoice this_arg_conv;
50718         this_arg_conv.inner = untag_ptr(this_arg);
50719         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50721         this_arg_conv.is_owned = false;
50722         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
50723         return ret_conv;
50724 }
50725
50726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
50727         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
50728         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
50729         return tag_ptr(ret_conv, true);
50730 }
50731
50732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
50733         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
50734         *ret_conv = PositiveTimestamp_from_system_time(time);
50735         return tag_ptr(ret_conv, true);
50736 }
50737
50738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t duration) {
50739         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
50740         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
50741         return tag_ptr(ret_conv, true);
50742 }
50743
50744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
50745         LDKPositiveTimestamp this_arg_conv;
50746         this_arg_conv.inner = untag_ptr(this_arg);
50747         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50749         this_arg_conv.is_owned = false;
50750         int64_t ret_conv = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
50751         return ret_conv;
50752 }
50753
50754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
50755         LDKPositiveTimestamp this_arg_conv;
50756         this_arg_conv.inner = untag_ptr(this_arg);
50757         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50759         this_arg_conv.is_owned = false;
50760         int64_t ret_conv = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
50761         return ret_conv;
50762 }
50763
50764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
50765         LDKPositiveTimestamp this_arg_conv;
50766         this_arg_conv.inner = untag_ptr(this_arg);
50767         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50769         this_arg_conv.is_owned = false;
50770         int64_t ret_conv = PositiveTimestamp_as_time(&this_arg_conv);
50771         return ret_conv;
50772 }
50773
50774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
50775         LDKInvoice this_arg_conv;
50776         this_arg_conv.inner = untag_ptr(this_arg);
50777         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50779         this_arg_conv = Invoice_clone(&this_arg_conv);
50780         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
50781         int64_t ret_ref = 0;
50782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50783         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50784         return ret_ref;
50785 }
50786
50787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
50788         LDKInvoice this_arg_conv;
50789         this_arg_conv.inner = untag_ptr(this_arg);
50790         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50792         this_arg_conv.is_owned = false;
50793         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
50794         *ret_conv = Invoice_check_signature(&this_arg_conv);
50795         return tag_ptr(ret_conv, true);
50796 }
50797
50798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
50799         LDKSignedRawInvoice signed_invoice_conv;
50800         signed_invoice_conv.inner = untag_ptr(signed_invoice);
50801         signed_invoice_conv.is_owned = ptr_is_owned(signed_invoice);
50802         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
50803         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
50804         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
50805         *ret_conv = Invoice_from_signed(signed_invoice_conv);
50806         return tag_ptr(ret_conv, true);
50807 }
50808
50809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
50810         LDKInvoice this_arg_conv;
50811         this_arg_conv.inner = untag_ptr(this_arg);
50812         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50814         this_arg_conv.is_owned = false;
50815         int64_t ret_conv = Invoice_timestamp(&this_arg_conv);
50816         return ret_conv;
50817 }
50818
50819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
50820         LDKInvoice this_arg_conv;
50821         this_arg_conv.inner = untag_ptr(this_arg);
50822         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50824         this_arg_conv.is_owned = false;
50825         int64_t ret_conv = Invoice_duration_since_epoch(&this_arg_conv);
50826         return ret_conv;
50827 }
50828
50829 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
50830         LDKInvoice this_arg_conv;
50831         this_arg_conv.inner = untag_ptr(this_arg);
50832         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50834         this_arg_conv.is_owned = false;
50835         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
50836         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
50837         return ret_arr;
50838 }
50839
50840 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
50841         LDKInvoice this_arg_conv;
50842         this_arg_conv.inner = untag_ptr(this_arg);
50843         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50845         this_arg_conv.is_owned = false;
50846         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
50847         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
50848         return ret_arr;
50849 }
50850
50851 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
50852         LDKInvoice this_arg_conv;
50853         this_arg_conv.inner = untag_ptr(this_arg);
50854         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50856         this_arg_conv.is_owned = false;
50857         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
50858         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_secret(&this_arg_conv));
50859         return ret_arr;
50860 }
50861
50862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
50863         LDKInvoice this_arg_conv;
50864         this_arg_conv.inner = untag_ptr(this_arg);
50865         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50867         this_arg_conv.is_owned = false;
50868         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
50869         int64_t ret_ref = 0;
50870         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50871         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50872         return ret_ref;
50873 }
50874
50875 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
50876         LDKInvoice this_arg_conv;
50877         this_arg_conv.inner = untag_ptr(this_arg);
50878         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50880         this_arg_conv.is_owned = false;
50881         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
50882         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
50883         return ret_arr;
50884 }
50885
50886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
50887         LDKInvoice this_arg_conv;
50888         this_arg_conv.inner = untag_ptr(this_arg);
50889         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50891         this_arg_conv.is_owned = false;
50892         int64_t ret_conv = Invoice_expiry_time(&this_arg_conv);
50893         return ret_conv;
50894 }
50895
50896 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
50897         LDKInvoice this_arg_conv;
50898         this_arg_conv.inner = untag_ptr(this_arg);
50899         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50901         this_arg_conv.is_owned = false;
50902         jboolean ret_conv = Invoice_is_expired(&this_arg_conv);
50903         return ret_conv;
50904 }
50905
50906 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1would_1expire(JNIEnv *env, jclass clz, int64_t this_arg, int64_t at_time) {
50907         LDKInvoice this_arg_conv;
50908         this_arg_conv.inner = untag_ptr(this_arg);
50909         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50911         this_arg_conv.is_owned = false;
50912         jboolean ret_conv = Invoice_would_expire(&this_arg_conv, at_time);
50913         return ret_conv;
50914 }
50915
50916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
50917         LDKInvoice this_arg_conv;
50918         this_arg_conv.inner = untag_ptr(this_arg);
50919         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50921         this_arg_conv.is_owned = false;
50922         int64_t ret_conv = Invoice_min_final_cltv_expiry(&this_arg_conv);
50923         return ret_conv;
50924 }
50925
50926 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
50927         LDKInvoice this_arg_conv;
50928         this_arg_conv.inner = untag_ptr(this_arg);
50929         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50931         this_arg_conv.is_owned = false;
50932         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
50933         int64_tArray ret_arr = NULL;
50934         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
50935         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
50936         for (size_t o = 0; o < ret_var.datalen; o++) {
50937                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
50938                 int64_t ret_conv_14_ref = 0;
50939                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
50940                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
50941                 ret_arr_ptr[o] = ret_conv_14_ref;
50942         }
50943         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
50944         FREE(ret_var.data);
50945         return ret_arr;
50946 }
50947
50948 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
50949         LDKInvoice this_arg_conv;
50950         this_arg_conv.inner = untag_ptr(this_arg);
50951         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50953         this_arg_conv.is_owned = false;
50954         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
50955         int64_tArray ret_arr = NULL;
50956         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
50957         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
50958         for (size_t l = 0; l < ret_var.datalen; l++) {
50959                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
50960                 int64_t ret_conv_11_ref = 0;
50961                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
50962                 ret_conv_11_ref = tag_ptr(ret_conv_11_var.inner, ret_conv_11_var.is_owned);
50963                 ret_arr_ptr[l] = ret_conv_11_ref;
50964         }
50965         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
50966         FREE(ret_var.data);
50967         return ret_arr;
50968 }
50969
50970 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
50971         LDKInvoice this_arg_conv;
50972         this_arg_conv.inner = untag_ptr(this_arg);
50973         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50975         this_arg_conv.is_owned = false;
50976         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
50977         return ret_conv;
50978 }
50979
50980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1milli_1satoshis(JNIEnv *env, jclass clz, int64_t this_arg) {
50981         LDKInvoice this_arg_conv;
50982         this_arg_conv.inner = untag_ptr(this_arg);
50983         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50985         this_arg_conv.is_owned = false;
50986         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
50987         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
50988         int64_t ret_ref = tag_ptr(ret_copy, true);
50989         return ret_ref;
50990 }
50991
50992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
50993         LDKStr description_conv = java_to_owned_str(env, description);
50994         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
50995         *ret_conv = Description_new(description_conv);
50996         return tag_ptr(ret_conv, true);
50997 }
50998
50999 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
51000         LDKDescription this_arg_conv;
51001         this_arg_conv.inner = untag_ptr(this_arg);
51002         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51004         this_arg_conv = Description_clone(&this_arg_conv);
51005         LDKStr ret_str = Description_into_inner(this_arg_conv);
51006         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
51007         Str_free(ret_str);
51008         return ret_conv;
51009 }
51010
51011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
51012         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
51013         int64_t ret_ref = 0;
51014         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51015         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51016         return ret_ref;
51017 }
51018
51019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
51020         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
51021         int64_t ret_ref = 0;
51022         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51023         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51024         return ret_ref;
51025 }
51026
51027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
51028         LDKExpiryTime this_arg_conv;
51029         this_arg_conv.inner = untag_ptr(this_arg);
51030         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51032         this_arg_conv.is_owned = false;
51033         int64_t ret_conv = ExpiryTime_as_seconds(&this_arg_conv);
51034         return ret_conv;
51035 }
51036
51037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
51038         LDKExpiryTime this_arg_conv;
51039         this_arg_conv.inner = untag_ptr(this_arg);
51040         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51042         this_arg_conv.is_owned = false;
51043         int64_t ret_conv = ExpiryTime_as_duration(&this_arg_conv);
51044         return ret_conv;
51045 }
51046
51047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
51048         LDKRouteHint hops_conv;
51049         hops_conv.inner = untag_ptr(hops);
51050         hops_conv.is_owned = ptr_is_owned(hops);
51051         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
51052         hops_conv = RouteHint_clone(&hops_conv);
51053         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
51054         *ret_conv = PrivateRoute_new(hops_conv);
51055         return tag_ptr(ret_conv, true);
51056 }
51057
51058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
51059         LDKPrivateRoute this_arg_conv;
51060         this_arg_conv.inner = untag_ptr(this_arg);
51061         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51063         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
51064         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
51065         int64_t ret_ref = 0;
51066         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51067         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51068         return ret_ref;
51069 }
51070
51071 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51072         LDKCreationError* orig_conv = (LDKCreationError*)untag_ptr(orig);
51073         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
51074         return ret_conv;
51075 }
51076
51077 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
51078         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
51079         return ret_conv;
51080 }
51081
51082 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
51083         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
51084         return ret_conv;
51085 }
51086
51087 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
51088         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
51089         return ret_conv;
51090 }
51091
51092 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1invalid_1amount(JNIEnv *env, jclass clz) {
51093         jclass ret_conv = LDKCreationError_to_java(env, CreationError_invalid_amount());
51094         return ret_conv;
51095 }
51096
51097 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1missing_1route_1hints(JNIEnv *env, jclass clz) {
51098         jclass ret_conv = LDKCreationError_to_java(env, CreationError_missing_route_hints());
51099         return ret_conv;
51100 }
51101
51102 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51103         LDKCreationError* a_conv = (LDKCreationError*)untag_ptr(a);
51104         LDKCreationError* b_conv = (LDKCreationError*)untag_ptr(b);
51105         jboolean ret_conv = CreationError_eq(a_conv, b_conv);
51106         return ret_conv;
51107 }
51108
51109 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
51110         LDKCreationError* o_conv = (LDKCreationError*)untag_ptr(o);
51111         LDKStr ret_str = CreationError_to_str(o_conv);
51112         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
51113         Str_free(ret_str);
51114         return ret_conv;
51115 }
51116
51117 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51118         LDKSemanticError* orig_conv = (LDKSemanticError*)untag_ptr(orig);
51119         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
51120         return ret_conv;
51121 }
51122
51123 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
51124         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
51125         return ret_conv;
51126 }
51127
51128 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
51129         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
51130         return ret_conv;
51131 }
51132
51133 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
51134         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
51135         return ret_conv;
51136 }
51137
51138 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
51139         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
51140         return ret_conv;
51141 }
51142
51143 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) {
51144         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret());
51145         return ret_conv;
51146 }
51147
51148 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
51149         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
51150         return ret_conv;
51151 }
51152
51153 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
51154         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
51155         return ret_conv;
51156 }
51157
51158 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
51159         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
51160         return ret_conv;
51161 }
51162
51163 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
51164         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
51165         return ret_conv;
51166 }
51167
51168 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) {
51169         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount());
51170         return ret_conv;
51171 }
51172
51173 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51174         LDKSemanticError* a_conv = (LDKSemanticError*)untag_ptr(a);
51175         LDKSemanticError* b_conv = (LDKSemanticError*)untag_ptr(b);
51176         jboolean ret_conv = SemanticError_eq(a_conv, b_conv);
51177         return ret_conv;
51178 }
51179
51180 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
51181         LDKSemanticError* o_conv = (LDKSemanticError*)untag_ptr(o);
51182         LDKStr ret_str = SemanticError_to_str(o_conv);
51183         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
51184         Str_free(ret_str);
51185         return ret_conv;
51186 }
51187
51188 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
51189         if (!ptr_is_owned(this_ptr)) return;
51190         void* this_ptr_ptr = untag_ptr(this_ptr);
51191         CHECK_ACCESS(this_ptr_ptr);
51192         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
51193         FREE(untag_ptr(this_ptr));
51194         SignOrCreationError_free(this_ptr_conv);
51195 }
51196
51197 static inline uint64_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
51198         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
51199         *ret_copy = SignOrCreationError_clone(arg);
51200         int64_t ret_ref = tag_ptr(ret_copy, true);
51201         return ret_ref;
51202 }
51203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51204         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)untag_ptr(arg);
51205         int64_t ret_conv = SignOrCreationError_clone_ptr(arg_conv);
51206         return ret_conv;
51207 }
51208
51209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51210         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)untag_ptr(orig);
51211         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
51212         *ret_copy = SignOrCreationError_clone(orig_conv);
51213         int64_t ret_ref = tag_ptr(ret_copy, true);
51214         return ret_ref;
51215 }
51216
51217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
51218         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
51219         *ret_copy = SignOrCreationError_sign_error();
51220         int64_t ret_ref = tag_ptr(ret_copy, true);
51221         return ret_ref;
51222 }
51223
51224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
51225         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
51226         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
51227         *ret_copy = SignOrCreationError_creation_error(a_conv);
51228         int64_t ret_ref = tag_ptr(ret_copy, true);
51229         return ret_ref;
51230 }
51231
51232 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51233         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)untag_ptr(a);
51234         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)untag_ptr(b);
51235         jboolean ret_conv = SignOrCreationError_eq(a_conv, b_conv);
51236         return ret_conv;
51237 }
51238
51239 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
51240         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)untag_ptr(o);
51241         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
51242         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
51243         Str_free(ret_str);
51244         return ret_conv;
51245 }
51246
51247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51248         LDKInvoicePayer this_obj_conv;
51249         this_obj_conv.inner = untag_ptr(this_obj);
51250         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51252         InvoicePayer_free(this_obj_conv);
51253 }
51254
51255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
51256         if (!ptr_is_owned(this_ptr)) return;
51257         void* this_ptr_ptr = untag_ptr(this_ptr);
51258         CHECK_ACCESS(this_ptr_ptr);
51259         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
51260         FREE(untag_ptr(this_ptr));
51261         Payer_free(this_ptr_conv);
51262 }
51263
51264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
51265         if (!ptr_is_owned(this_ptr)) return;
51266         void* this_ptr_ptr = untag_ptr(this_ptr);
51267         CHECK_ACCESS(this_ptr_ptr);
51268         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
51269         FREE(untag_ptr(this_ptr));
51270         Router_free(this_ptr_conv);
51271 }
51272
51273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Retry_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
51274         if (!ptr_is_owned(this_ptr)) return;
51275         void* this_ptr_ptr = untag_ptr(this_ptr);
51276         CHECK_ACCESS(this_ptr_ptr);
51277         LDKRetry this_ptr_conv = *(LDKRetry*)(this_ptr_ptr);
51278         FREE(untag_ptr(this_ptr));
51279         Retry_free(this_ptr_conv);
51280 }
51281
51282 static inline uint64_t Retry_clone_ptr(LDKRetry *NONNULL_PTR arg) {
51283         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
51284         *ret_copy = Retry_clone(arg);
51285         int64_t ret_ref = tag_ptr(ret_copy, true);
51286         return ret_ref;
51287 }
51288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51289         LDKRetry* arg_conv = (LDKRetry*)untag_ptr(arg);
51290         int64_t ret_conv = Retry_clone_ptr(arg_conv);
51291         return ret_conv;
51292 }
51293
51294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51295         LDKRetry* orig_conv = (LDKRetry*)untag_ptr(orig);
51296         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
51297         *ret_copy = Retry_clone(orig_conv);
51298         int64_t ret_ref = tag_ptr(ret_copy, true);
51299         return ret_ref;
51300 }
51301
51302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1attempts(JNIEnv *env, jclass clz, int64_t a) {
51303         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
51304         *ret_copy = Retry_attempts(a);
51305         int64_t ret_ref = tag_ptr(ret_copy, true);
51306         return ret_ref;
51307 }
51308
51309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1timeout(JNIEnv *env, jclass clz, int64_t a) {
51310         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
51311         *ret_copy = Retry_timeout(a);
51312         int64_t ret_ref = tag_ptr(ret_copy, true);
51313         return ret_ref;
51314 }
51315
51316 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Retry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51317         LDKRetry* a_conv = (LDKRetry*)untag_ptr(a);
51318         LDKRetry* b_conv = (LDKRetry*)untag_ptr(b);
51319         jboolean ret_conv = Retry_eq(a_conv, b_conv);
51320         return ret_conv;
51321 }
51322
51323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1hash(JNIEnv *env, jclass clz, int64_t o) {
51324         LDKRetry* o_conv = (LDKRetry*)untag_ptr(o);
51325         int64_t ret_conv = Retry_hash(o_conv);
51326         return ret_conv;
51327 }
51328
51329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
51330         if (!ptr_is_owned(this_ptr)) return;
51331         void* this_ptr_ptr = untag_ptr(this_ptr);
51332         CHECK_ACCESS(this_ptr_ptr);
51333         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
51334         FREE(untag_ptr(this_ptr));
51335         PaymentError_free(this_ptr_conv);
51336 }
51337
51338 static inline uint64_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
51339         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
51340         *ret_copy = PaymentError_clone(arg);
51341         int64_t ret_ref = tag_ptr(ret_copy, true);
51342         return ret_ref;
51343 }
51344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51345         LDKPaymentError* arg_conv = (LDKPaymentError*)untag_ptr(arg);
51346         int64_t ret_conv = PaymentError_clone_ptr(arg_conv);
51347         return ret_conv;
51348 }
51349
51350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51351         LDKPaymentError* orig_conv = (LDKPaymentError*)untag_ptr(orig);
51352         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
51353         *ret_copy = PaymentError_clone(orig_conv);
51354         int64_t ret_ref = tag_ptr(ret_copy, true);
51355         return ret_ref;
51356 }
51357
51358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1invoice(JNIEnv *env, jclass clz, jstring a) {
51359         LDKStr a_conv = java_to_owned_str(env, a);
51360         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
51361         *ret_copy = PaymentError_invoice(a_conv);
51362         int64_t ret_ref = tag_ptr(ret_copy, true);
51363         return ret_ref;
51364 }
51365
51366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1routing(JNIEnv *env, jclass clz, int64_t a) {
51367         LDKLightningError a_conv;
51368         a_conv.inner = untag_ptr(a);
51369         a_conv.is_owned = ptr_is_owned(a);
51370         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51371         a_conv = LightningError_clone(&a_conv);
51372         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
51373         *ret_copy = PaymentError_routing(a_conv);
51374         int64_t ret_ref = tag_ptr(ret_copy, true);
51375         return ret_ref;
51376 }
51377
51378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1sending(JNIEnv *env, jclass clz, int64_t a) {
51379         void* a_ptr = untag_ptr(a);
51380         CHECK_ACCESS(a_ptr);
51381         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
51382         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(a));
51383         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
51384         *ret_copy = PaymentError_sending(a_conv);
51385         int64_t ret_ref = tag_ptr(ret_copy, true);
51386         return ret_ref;
51387 }
51388
51389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1new(JNIEnv *env, jclass clz, int64_t payer, int64_t router, int64_t logger, int64_t event_handler, int64_t retry) {
51390         void* payer_ptr = untag_ptr(payer);
51391         CHECK_ACCESS(payer_ptr);
51392         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
51393         if (payer_conv.free == LDKPayer_JCalls_free) {
51394                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51395                 LDKPayer_JCalls_cloned(&payer_conv);
51396         }
51397         void* router_ptr = untag_ptr(router);
51398         CHECK_ACCESS(router_ptr);
51399         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
51400         if (router_conv.free == LDKRouter_JCalls_free) {
51401                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51402                 LDKRouter_JCalls_cloned(&router_conv);
51403         }
51404         void* logger_ptr = untag_ptr(logger);
51405         CHECK_ACCESS(logger_ptr);
51406         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
51407         if (logger_conv.free == LDKLogger_JCalls_free) {
51408                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51409                 LDKLogger_JCalls_cloned(&logger_conv);
51410         }
51411         void* event_handler_ptr = untag_ptr(event_handler);
51412         CHECK_ACCESS(event_handler_ptr);
51413         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
51414         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
51415                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51416                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
51417         }
51418         void* retry_ptr = untag_ptr(retry);
51419         CHECK_ACCESS(retry_ptr);
51420         LDKRetry retry_conv = *(LDKRetry*)(retry_ptr);
51421         retry_conv = Retry_clone((LDKRetry*)untag_ptr(retry));
51422         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, logger_conv, event_handler_conv, retry_conv);
51423         int64_t ret_ref = 0;
51424         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51425         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51426         return ret_ref;
51427 }
51428
51429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice) {
51430         LDKInvoicePayer this_arg_conv;
51431         this_arg_conv.inner = untag_ptr(this_arg);
51432         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51434         this_arg_conv.is_owned = false;
51435         LDKInvoice invoice_conv;
51436         invoice_conv.inner = untag_ptr(invoice);
51437         invoice_conv.is_owned = ptr_is_owned(invoice);
51438         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
51439         invoice_conv.is_owned = false;
51440         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
51441         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
51442         return tag_ptr(ret_conv, true);
51443 }
51444
51445 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) {
51446         LDKInvoicePayer this_arg_conv;
51447         this_arg_conv.inner = untag_ptr(this_arg);
51448         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51450         this_arg_conv.is_owned = false;
51451         LDKInvoice invoice_conv;
51452         invoice_conv.inner = untag_ptr(invoice);
51453         invoice_conv.is_owned = ptr_is_owned(invoice);
51454         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
51455         invoice_conv.is_owned = false;
51456         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
51457         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
51458         return tag_ptr(ret_conv, true);
51459 }
51460
51461 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) {
51462         LDKInvoicePayer this_arg_conv;
51463         this_arg_conv.inner = untag_ptr(this_arg);
51464         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51466         this_arg_conv.is_owned = false;
51467         LDKPublicKey pubkey_ref;
51468         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
51469         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
51470         LDKThirtyTwoBytes payment_preimage_ref;
51471         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
51472         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
51473         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
51474         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
51475         return tag_ptr(ret_conv, true);
51476 }
51477
51478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1remove_1cached_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
51479         LDKInvoicePayer this_arg_conv;
51480         this_arg_conv.inner = untag_ptr(this_arg);
51481         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51483         this_arg_conv.is_owned = false;
51484         unsigned char payment_hash_arr[32];
51485         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
51486         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
51487         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
51488         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
51489 }
51490
51491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
51492         LDKInvoicePayer this_arg_conv;
51493         this_arg_conv.inner = untag_ptr(this_arg);
51494         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51496         this_arg_conv.is_owned = false;
51497         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
51498         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
51499         return tag_ptr(ret_ret, true);
51500 }
51501
51502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51503         LDKInFlightHtlcs this_obj_conv;
51504         this_obj_conv.inner = untag_ptr(this_obj);
51505         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51507         InFlightHtlcs_free(this_obj_conv);
51508 }
51509
51510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1used_1liquidity_1msat(JNIEnv *env, jclass clz, int64_t this_arg, int64_t source, int64_t target, int64_t channel_scid) {
51511         LDKInFlightHtlcs this_arg_conv;
51512         this_arg_conv.inner = untag_ptr(this_arg);
51513         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51515         this_arg_conv.is_owned = false;
51516         LDKNodeId source_conv;
51517         source_conv.inner = untag_ptr(source);
51518         source_conv.is_owned = ptr_is_owned(source);
51519         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
51520         source_conv.is_owned = false;
51521         LDKNodeId target_conv;
51522         target_conv.inner = untag_ptr(target);
51523         target_conv.is_owned = ptr_is_owned(target);
51524         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
51525         target_conv.is_owned = false;
51526         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
51527         *ret_copy = InFlightHtlcs_used_liquidity_msat(&this_arg_conv, &source_conv, &target_conv, channel_scid);
51528         int64_t ret_ref = tag_ptr(ret_copy, true);
51529         return ret_ref;
51530 }
51531
51532 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1write(JNIEnv *env, jclass clz, int64_t obj) {
51533         LDKInFlightHtlcs obj_conv;
51534         obj_conv.inner = untag_ptr(obj);
51535         obj_conv.is_owned = ptr_is_owned(obj);
51536         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51537         obj_conv.is_owned = false;
51538         LDKCVec_u8Z ret_var = InFlightHtlcs_write(&obj_conv);
51539         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
51540         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
51541         CVec_u8Z_free(ret_var);
51542         return ret_arr;
51543 }
51544
51545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
51546         LDKu8slice ser_ref;
51547         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
51548         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
51549         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
51550         *ret_conv = InFlightHtlcs_read(ser_ref);
51551         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
51552         return tag_ptr(ret_conv, true);
51553 }
51554
51555 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, int64_t logger, jclass network) {
51556         void* amt_msat_ptr = untag_ptr(amt_msat);
51557         CHECK_ACCESS(amt_msat_ptr);
51558         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
51559         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
51560         LDKThirtyTwoBytes payment_hash_ref;
51561         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
51562         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
51563         LDKStr description_conv = java_to_owned_str(env, description);
51564         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
51565         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
51566         if (phantom_route_hints_constr.datalen > 0)
51567                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
51568         else
51569                 phantom_route_hints_constr.data = NULL;
51570         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
51571         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
51572                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
51573                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
51574                 phantom_route_hints_conv_19_conv.inner = untag_ptr(phantom_route_hints_conv_19);
51575                 phantom_route_hints_conv_19_conv.is_owned = ptr_is_owned(phantom_route_hints_conv_19);
51576                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
51577                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
51578                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
51579         }
51580         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
51581         void* keys_manager_ptr = untag_ptr(keys_manager);
51582         CHECK_ACCESS(keys_manager_ptr);
51583         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
51584         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
51585                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51586                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
51587         }
51588         void* logger_ptr = untag_ptr(logger);
51589         CHECK_ACCESS(logger_ptr);
51590         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
51591         if (logger_conv.free == LDKLogger_JCalls_free) {
51592                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51593                 LDKLogger_JCalls_cloned(&logger_conv);
51594         }
51595         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
51596         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
51597         *ret_conv = create_phantom_invoice(amt_msat_conv, payment_hash_ref, description_conv, invoice_expiry_delta_secs, phantom_route_hints_constr, keys_manager_conv, logger_conv, network_conv);
51598         return tag_ptr(ret_conv, true);
51599 }
51600
51601 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, int64_t logger, jclass network) {
51602         void* amt_msat_ptr = untag_ptr(amt_msat);
51603         CHECK_ACCESS(amt_msat_ptr);
51604         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
51605         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
51606         LDKThirtyTwoBytes payment_hash_ref;
51607         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
51608         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
51609         LDKSha256 description_hash_conv;
51610         description_hash_conv.inner = untag_ptr(description_hash);
51611         description_hash_conv.is_owned = ptr_is_owned(description_hash);
51612         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
51613         description_hash_conv = Sha256_clone(&description_hash_conv);
51614         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
51615         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
51616         if (phantom_route_hints_constr.datalen > 0)
51617                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
51618         else
51619                 phantom_route_hints_constr.data = NULL;
51620         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
51621         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
51622                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
51623                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
51624                 phantom_route_hints_conv_19_conv.inner = untag_ptr(phantom_route_hints_conv_19);
51625                 phantom_route_hints_conv_19_conv.is_owned = ptr_is_owned(phantom_route_hints_conv_19);
51626                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
51627                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
51628                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
51629         }
51630         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
51631         void* keys_manager_ptr = untag_ptr(keys_manager);
51632         CHECK_ACCESS(keys_manager_ptr);
51633         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
51634         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
51635                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51636                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
51637         }
51638         void* logger_ptr = untag_ptr(logger);
51639         CHECK_ACCESS(logger_ptr);
51640         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
51641         if (logger_conv.free == LDKLogger_JCalls_free) {
51642                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51643                 LDKLogger_JCalls_cloned(&logger_conv);
51644         }
51645         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
51646         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
51647         *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, logger_conv, network_conv);
51648         return tag_ptr(ret_conv, true);
51649 }
51650
51651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, int64_t logger, jclass network, int64_t amt_msat, jstring description, int32_t invoice_expiry_delta_secs) {
51652         LDKChannelManager channelmanager_conv;
51653         channelmanager_conv.inner = untag_ptr(channelmanager);
51654         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
51655         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
51656         channelmanager_conv.is_owned = false;
51657         void* keys_manager_ptr = untag_ptr(keys_manager);
51658         CHECK_ACCESS(keys_manager_ptr);
51659         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
51660         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
51661                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51662                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
51663         }
51664         void* logger_ptr = untag_ptr(logger);
51665         CHECK_ACCESS(logger_ptr);
51666         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
51667         if (logger_conv.free == LDKLogger_JCalls_free) {
51668                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51669                 LDKLogger_JCalls_cloned(&logger_conv);
51670         }
51671         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
51672         void* amt_msat_ptr = untag_ptr(amt_msat);
51673         CHECK_ACCESS(amt_msat_ptr);
51674         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
51675         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
51676         LDKStr description_conv = java_to_owned_str(env, description);
51677         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
51678         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, logger_conv, network_conv, amt_msat_conv, description_conv, invoice_expiry_delta_secs);
51679         return tag_ptr(ret_conv, true);
51680 }
51681
51682 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, int64_t logger, jclass network, int64_t amt_msat, int64_t description_hash, int32_t invoice_expiry_delta_secs) {
51683         LDKChannelManager channelmanager_conv;
51684         channelmanager_conv.inner = untag_ptr(channelmanager);
51685         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
51686         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
51687         channelmanager_conv.is_owned = false;
51688         void* keys_manager_ptr = untag_ptr(keys_manager);
51689         CHECK_ACCESS(keys_manager_ptr);
51690         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
51691         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
51692                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51693                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
51694         }
51695         void* logger_ptr = untag_ptr(logger);
51696         CHECK_ACCESS(logger_ptr);
51697         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
51698         if (logger_conv.free == LDKLogger_JCalls_free) {
51699                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51700                 LDKLogger_JCalls_cloned(&logger_conv);
51701         }
51702         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
51703         void* amt_msat_ptr = untag_ptr(amt_msat);
51704         CHECK_ACCESS(amt_msat_ptr);
51705         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
51706         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
51707         LDKSha256 description_hash_conv;
51708         description_hash_conv.inner = untag_ptr(description_hash);
51709         description_hash_conv.is_owned = ptr_is_owned(description_hash);
51710         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
51711         description_hash_conv = Sha256_clone(&description_hash_conv);
51712         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
51713         *ret_conv = create_invoice_from_channelmanager_with_description_hash(&channelmanager_conv, keys_manager_conv, logger_conv, network_conv, amt_msat_conv, description_hash_conv, invoice_expiry_delta_secs);
51714         return tag_ptr(ret_conv, true);
51715 }
51716
51717 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, int64_t logger, jclass network, int64_t amt_msat, int64_t description_hash, int64_t duration_since_epoch, int32_t invoice_expiry_delta_secs) {
51718         LDKChannelManager channelmanager_conv;
51719         channelmanager_conv.inner = untag_ptr(channelmanager);
51720         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
51721         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
51722         channelmanager_conv.is_owned = false;
51723         void* keys_manager_ptr = untag_ptr(keys_manager);
51724         CHECK_ACCESS(keys_manager_ptr);
51725         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
51726         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
51727                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51728                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
51729         }
51730         void* logger_ptr = untag_ptr(logger);
51731         CHECK_ACCESS(logger_ptr);
51732         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
51733         if (logger_conv.free == LDKLogger_JCalls_free) {
51734                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51735                 LDKLogger_JCalls_cloned(&logger_conv);
51736         }
51737         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
51738         void* amt_msat_ptr = untag_ptr(amt_msat);
51739         CHECK_ACCESS(amt_msat_ptr);
51740         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
51741         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
51742         LDKSha256 description_hash_conv;
51743         description_hash_conv.inner = untag_ptr(description_hash);
51744         description_hash_conv.is_owned = ptr_is_owned(description_hash);
51745         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
51746         description_hash_conv = Sha256_clone(&description_hash_conv);
51747         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
51748         *ret_conv = create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(&channelmanager_conv, keys_manager_conv, logger_conv, network_conv, amt_msat_conv, description_hash_conv, duration_since_epoch, invoice_expiry_delta_secs);
51749         return tag_ptr(ret_conv, true);
51750 }
51751
51752 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, int64_t logger, jclass network, int64_t amt_msat, jstring description, int64_t duration_since_epoch, int32_t invoice_expiry_delta_secs) {
51753         LDKChannelManager channelmanager_conv;
51754         channelmanager_conv.inner = untag_ptr(channelmanager);
51755         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
51756         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
51757         channelmanager_conv.is_owned = false;
51758         void* keys_manager_ptr = untag_ptr(keys_manager);
51759         CHECK_ACCESS(keys_manager_ptr);
51760         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
51761         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
51762                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51763                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
51764         }
51765         void* logger_ptr = untag_ptr(logger);
51766         CHECK_ACCESS(logger_ptr);
51767         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
51768         if (logger_conv.free == LDKLogger_JCalls_free) {
51769                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51770                 LDKLogger_JCalls_cloned(&logger_conv);
51771         }
51772         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
51773         void* amt_msat_ptr = untag_ptr(amt_msat);
51774         CHECK_ACCESS(amt_msat_ptr);
51775         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
51776         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
51777         LDKStr description_conv = java_to_owned_str(env, description);
51778         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
51779         *ret_conv = create_invoice_from_channelmanager_and_duration_since_epoch(&channelmanager_conv, keys_manager_conv, logger_conv, network_conv, amt_msat_conv, description_conv, duration_since_epoch, invoice_expiry_delta_secs);
51780         return tag_ptr(ret_conv, true);
51781 }
51782
51783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51784         LDKDefaultRouter this_obj_conv;
51785         this_obj_conv.inner = untag_ptr(this_obj);
51786         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51788         DefaultRouter_free(this_obj_conv);
51789 }
51790
51791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t logger, int8_tArray random_seed_bytes, int64_t scorer) {
51792         LDKNetworkGraph network_graph_conv;
51793         network_graph_conv.inner = untag_ptr(network_graph);
51794         network_graph_conv.is_owned = ptr_is_owned(network_graph);
51795         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
51796         network_graph_conv.is_owned = false;
51797         void* logger_ptr = untag_ptr(logger);
51798         CHECK_ACCESS(logger_ptr);
51799         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
51800         if (logger_conv.free == LDKLogger_JCalls_free) {
51801                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51802                 LDKLogger_JCalls_cloned(&logger_conv);
51803         }
51804         LDKThirtyTwoBytes random_seed_bytes_ref;
51805         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
51806         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_ref.data);
51807         void* scorer_ptr = untag_ptr(scorer);
51808         CHECK_ACCESS(scorer_ptr);
51809         LDKLockableScore scorer_conv = *(LDKLockableScore*)(scorer_ptr);
51810         if (scorer_conv.free == LDKLockableScore_JCalls_free) {
51811                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
51812                 LDKLockableScore_JCalls_cloned(&scorer_conv);
51813         }
51814         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref, scorer_conv);
51815         int64_t ret_ref = 0;
51816         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51817         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51818         return ret_ref;
51819 }
51820
51821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1as_1Router(JNIEnv *env, jclass clz, int64_t this_arg) {
51822         LDKDefaultRouter this_arg_conv;
51823         this_arg_conv.inner = untag_ptr(this_arg);
51824         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51826         this_arg_conv.is_owned = false;
51827         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
51828         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
51829         return tag_ptr(ret_ret, true);
51830 }
51831
51832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Payer(JNIEnv *env, jclass clz, int64_t this_arg) {
51833         LDKChannelManager this_arg_conv;
51834         this_arg_conv.inner = untag_ptr(this_arg);
51835         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51837         this_arg_conv.is_owned = false;
51838         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
51839         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
51840         return tag_ptr(ret_ret, true);
51841 }
51842
51843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
51844         LDKStr s_conv = java_to_owned_str(env, s);
51845         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
51846         *ret_conv = SiPrefix_from_str(s_conv);
51847         return tag_ptr(ret_conv, true);
51848 }
51849
51850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
51851         LDKStr s_conv = java_to_owned_str(env, s);
51852         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
51853         *ret_conv = Invoice_from_str(s_conv);
51854         return tag_ptr(ret_conv, true);
51855 }
51856
51857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
51858         LDKStr s_conv = java_to_owned_str(env, s);
51859         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
51860         *ret_conv = SignedRawInvoice_from_str(s_conv);
51861         return tag_ptr(ret_conv, true);
51862 }
51863
51864 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
51865         LDKParseError* o_conv = (LDKParseError*)untag_ptr(o);
51866         LDKStr ret_str = ParseError_to_str(o_conv);
51867         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
51868         Str_free(ret_str);
51869         return ret_conv;
51870 }
51871
51872 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
51873         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)untag_ptr(o);
51874         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
51875         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
51876         Str_free(ret_str);
51877         return ret_conv;
51878 }
51879
51880 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
51881         LDKInvoice o_conv;
51882         o_conv.inner = untag_ptr(o);
51883         o_conv.is_owned = ptr_is_owned(o);
51884         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51885         o_conv.is_owned = false;
51886         LDKStr ret_str = Invoice_to_str(&o_conv);
51887         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
51888         Str_free(ret_str);
51889         return ret_conv;
51890 }
51891
51892 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
51893         LDKSignedRawInvoice o_conv;
51894         o_conv.inner = untag_ptr(o);
51895         o_conv.is_owned = ptr_is_owned(o);
51896         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51897         o_conv.is_owned = false;
51898         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
51899         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
51900         Str_free(ret_str);
51901         return ret_conv;
51902 }
51903
51904 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
51905         LDKCurrency* o_conv = (LDKCurrency*)untag_ptr(o);
51906         LDKStr ret_str = Currency_to_str(o_conv);
51907         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
51908         Str_free(ret_str);
51909         return ret_conv;
51910 }
51911
51912 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
51913         LDKSiPrefix* o_conv = (LDKSiPrefix*)untag_ptr(o);
51914         LDKStr ret_str = SiPrefix_to_str(o_conv);
51915         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
51916         Str_free(ret_str);
51917         return ret_conv;
51918 }
51919
51920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51921         LDKRapidGossipSync this_obj_conv;
51922         this_obj_conv.inner = untag_ptr(this_obj);
51923         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51925         RapidGossipSync_free(this_obj_conv);
51926 }
51927
51928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1new(JNIEnv *env, jclass clz, int64_t network_graph) {
51929         LDKNetworkGraph network_graph_conv;
51930         network_graph_conv.inner = untag_ptr(network_graph);
51931         network_graph_conv.is_owned = ptr_is_owned(network_graph);
51932         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
51933         network_graph_conv.is_owned = false;
51934         LDKRapidGossipSync ret_var = RapidGossipSync_new(&network_graph_conv);
51935         int64_t ret_ref = 0;
51936         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51937         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51938         return ret_ref;
51939 }
51940
51941 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) {
51942         LDKRapidGossipSync this_arg_conv;
51943         this_arg_conv.inner = untag_ptr(this_arg);
51944         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51946         this_arg_conv.is_owned = false;
51947         LDKu8slice update_data_ref;
51948         update_data_ref.datalen = (*env)->GetArrayLength(env, update_data);
51949         update_data_ref.data = (*env)->GetByteArrayElements (env, update_data, NULL);
51950         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
51951         *ret_conv = RapidGossipSync_update_network_graph(&this_arg_conv, update_data_ref);
51952         (*env)->ReleaseByteArrayElements(env, update_data, (int8_t*)update_data_ref.data, 0);
51953         return tag_ptr(ret_conv, true);
51954 }
51955
51956 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1is_1initial_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_arg) {
51957         LDKRapidGossipSync this_arg_conv;
51958         this_arg_conv.inner = untag_ptr(this_arg);
51959         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51961         this_arg_conv.is_owned = false;
51962         jboolean ret_conv = RapidGossipSync_is_initial_sync_complete(&this_arg_conv);
51963         return ret_conv;
51964 }
51965
51966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
51967         if (!ptr_is_owned(this_ptr)) return;
51968         void* this_ptr_ptr = untag_ptr(this_ptr);
51969         CHECK_ACCESS(this_ptr_ptr);
51970         LDKGraphSyncError this_ptr_conv = *(LDKGraphSyncError*)(this_ptr_ptr);
51971         FREE(untag_ptr(this_ptr));
51972         GraphSyncError_free(this_ptr_conv);
51973 }
51974
51975 static inline uint64_t GraphSyncError_clone_ptr(LDKGraphSyncError *NONNULL_PTR arg) {
51976         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
51977         *ret_copy = GraphSyncError_clone(arg);
51978         int64_t ret_ref = tag_ptr(ret_copy, true);
51979         return ret_ref;
51980 }
51981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51982         LDKGraphSyncError* arg_conv = (LDKGraphSyncError*)untag_ptr(arg);
51983         int64_t ret_conv = GraphSyncError_clone_ptr(arg_conv);
51984         return ret_conv;
51985 }
51986
51987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51988         LDKGraphSyncError* orig_conv = (LDKGraphSyncError*)untag_ptr(orig);
51989         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
51990         *ret_copy = GraphSyncError_clone(orig_conv);
51991         int64_t ret_ref = tag_ptr(ret_copy, true);
51992         return ret_ref;
51993 }
51994
51995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1decode_1error(JNIEnv *env, jclass clz, int64_t a) {
51996         void* a_ptr = untag_ptr(a);
51997         CHECK_ACCESS(a_ptr);
51998         LDKDecodeError a_conv = *(LDKDecodeError*)(a_ptr);
51999         a_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(a));
52000         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
52001         *ret_copy = GraphSyncError_decode_error(a_conv);
52002         int64_t ret_ref = tag_ptr(ret_copy, true);
52003         return ret_ref;
52004 }
52005
52006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1lightning_1error(JNIEnv *env, jclass clz, int64_t a) {
52007         LDKLightningError a_conv;
52008         a_conv.inner = untag_ptr(a);
52009         a_conv.is_owned = ptr_is_owned(a);
52010         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
52011         a_conv = LightningError_clone(&a_conv);
52012         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
52013         *ret_copy = GraphSyncError_lightning_error(a_conv);
52014         int64_t ret_ref = tag_ptr(ret_copy, true);
52015         return ret_ref;
52016 }
52017